Update guest PWA v2 UI and likes
This commit is contained in:
@@ -28,6 +28,7 @@ use Filament\Schemas\Schema;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Arr;
|
||||
use UnitEnum;
|
||||
|
||||
class EventResource extends Resource
|
||||
@@ -264,6 +265,67 @@ class EventResource extends Resource
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
Actions\Action::make('set_demo_read_only')
|
||||
->label(__('admin.events.join_link.demo_read_only_action'))
|
||||
->icon('heroicon-o-lock-closed')
|
||||
->color('gray')
|
||||
->size('xs')
|
||||
->modalHeading(function (Actions\Action $action, Event $record): string {
|
||||
$token = static::resolveJoinTokenFromAction($record, $action);
|
||||
|
||||
return $token
|
||||
? __('admin.events.join_link.demo_read_only_heading', [
|
||||
'label' => $token->label ?: __('admin.events.join_link.token_default', ['id' => $token->id]),
|
||||
])
|
||||
: __('admin.events.join_link.demo_read_only_heading_fallback');
|
||||
})
|
||||
->schema([
|
||||
Toggle::make('demo_read_only')
|
||||
->label(__('admin.events.join_link.demo_read_only_label'))
|
||||
->helperText(__('admin.events.join_link.demo_read_only_help')),
|
||||
])
|
||||
->fillForm(function (Actions\Action $action, Event $record): array {
|
||||
$token = static::resolveJoinTokenFromAction($record, $action);
|
||||
|
||||
return [
|
||||
'demo_read_only' => (bool) Arr::get($token?->metadata ?? [], 'demo_read_only', false),
|
||||
];
|
||||
})
|
||||
->action(function (array $data, Actions\Action $action, Event $record): void {
|
||||
$token = static::resolveJoinTokenFromAction($record, $action);
|
||||
|
||||
if (! $token) {
|
||||
Notification::make()
|
||||
->title(__('admin.events.join_link.demo_read_only_missing'))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$metadata = is_array($token->metadata) ? $token->metadata : [];
|
||||
$enabled = (bool) ($data['demo_read_only'] ?? false);
|
||||
|
||||
if ($enabled) {
|
||||
$metadata['demo_read_only'] = true;
|
||||
} else {
|
||||
unset($metadata['demo_read_only']);
|
||||
}
|
||||
|
||||
$token->metadata = empty($metadata) ? null : $metadata;
|
||||
$token->save();
|
||||
|
||||
app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||
'updated',
|
||||
$token,
|
||||
source: static::class
|
||||
);
|
||||
|
||||
Notification::make()
|
||||
->title(__('admin.events.join_link.demo_read_only_success'))
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
])
|
||||
->modalContent(function (Actions\Action $action, $record) {
|
||||
$tokens = $record->joinTokens()
|
||||
@@ -335,6 +397,7 @@ class EventResource extends Resource
|
||||
'expires_at' => optional($token->expires_at)->toIso8601String(),
|
||||
'revoked_at' => optional($token->revoked_at)->toIso8601String(),
|
||||
'is_active' => $token->isActive(),
|
||||
'demo_read_only' => (bool) Arr::get($token->metadata ?? [], 'demo_read_only', false),
|
||||
'created_at' => optional($token->created_at)->toIso8601String(),
|
||||
'layouts' => $layouts,
|
||||
'layouts_url' => route('api.v1.tenant.events.join-tokens.layouts.index', [
|
||||
|
||||
Reference in New Issue
Block a user