diff --git a/app/Filament/Components/Actions/ImportScheduleAction.php b/app/Filament/Components/Actions/ImportScheduleAction.php index 37e934c0e..27824c90b 100644 --- a/app/Filament/Components/Actions/ImportScheduleAction.php +++ b/app/Filament/Components/Actions/ImportScheduleAction.php @@ -39,26 +39,26 @@ class ImportScheduleAction extends Action Tabs::make('Tabs') ->contained(false) ->tabs([ - Tab::make(trans('admin/schedule.import.file')) + Tab::make(trans('server/schedule.import_action.file')) ->icon('tabler-file-upload') ->schema([ FileUpload::make('files') - ->label(trans('admin/schedule.model_label')) - ->hint(trans('admin/schedule.import.schedule_help')) + ->hiddenLabel() + ->hint(trans('server/schedule.import_action.schedule_help')) ->acceptedFileTypes(['application/json']) ->preserveFilenames() ->previewable(false) ->storeFiles(false) ->multiple(true), ]), - Tab::make(trans('admin/schedule.import.url')) + Tab::make(trans('server/schedule.import_action.url')) ->icon('tabler-world-upload') ->schema([ Repeater::make('urls') - ->label('') + ->hiddenLabel() ->itemLabel(fn (array $state) => str($state['url'])->afterLast('/schedule-')->before('.json')->headline()) - ->hint(trans('admin/schedule.import.url_help')) - ->addActionLabel(trans('admin/schedule.import.add_url')) + ->hint(trans('server/schedule.import_action.url_help')) + ->addActionLabel(trans('server/schedule.import_action.add_url')) ->grid(2) ->reorderable(false) ->addable(true) @@ -66,10 +66,10 @@ class ImportScheduleAction extends Action ->schema([ TextInput::make('url') ->live() - ->label(trans('admin/schedule.import.url')) + ->label(trans('server/schedule.import_action.url')) ->url() ->endsWith('.json') - ->validationAttribute(trans('admin/schedule.import.url')), + ->validationAttribute(trans('server/schedule.import_action.url')), ]), ]), ]), @@ -104,14 +104,14 @@ class ImportScheduleAction extends Action if ($failed->count() > 0) { Notification::make() - ->title(trans('admin/schedule.import.import_failed')) + ->title(trans('server/schedule.import_action.import_failed')) ->body($failed->join(', ')) ->danger() ->send(); } if ($success->count() > 0) { Notification::make() - ->title(trans('admin/schedule.import.import_success')) + ->title(trans('server/schedule.import_action.import_success')) ->body($success->join(', ')) ->success() ->send(); diff --git a/app/Filament/Server/Resources/ScheduleResource.php b/app/Filament/Server/Resources/ScheduleResource.php index a5143ddd6..cd186e96c 100644 --- a/app/Filament/Server/Resources/ScheduleResource.php +++ b/app/Filament/Server/Resources/ScheduleResource.php @@ -115,7 +115,15 @@ class ScheduleResource extends Resource ->visibleOn('view'), Section::make('Cron') ->label(trans('server/schedule.cron')) - ->description(fn (Get $get) => new HtmlString(trans('server/schedule.cron_body') . '
' . trans('server/schedule.cron_timezone', ['timezone' => auth()->user()->timezone, 'next_run' => Utilities::getScheduleNextRunDate($get('cron_minute'), $get('cron_hour'), $get('cron_day_of_month'), $get('cron_month'), $get('cron_day_of_week'))->timezone(auth()->user()->timezone)]))) + ->description(function (Get $get) { + try { + $nextRun = Utilities::getScheduleNextRunDate($get('cron_minute'), $get('cron_hour'), $get('cron_day_of_month'), $get('cron_month'), $get('cron_day_of_week'))->timezone(auth()->user()->timezone); + } catch (Exception) { + $nextRun = trans('server/schedule.invalid'); + } + + return new HtmlString(trans('server/schedule.cron_body') . '
' . trans('server/schedule.cron_timezone', ['timezone' => auth()->user()->timezone, 'next_run' => $nextRun])); + }) ->schema([ Actions::make([ CronPresetAction::make('hourly') diff --git a/lang/en/admin/schedule.php b/lang/en/admin/schedule.php deleted file mode 100644 index 79e6b449b..000000000 --- a/lang/en/admin/schedule.php +++ /dev/null @@ -1,15 +0,0 @@ - 'Schedule', - 'model_label_plural' => 'Schedule', - 'import' => [ - 'file' => 'File', - 'url' => 'URL', - 'schedule_help' => 'This should be the raw .json file ( schedule-daily-restart.json )', - 'url_help' => 'URLs must point directly to the raw .json file', - 'add_url' => 'New URL', - 'import_failed' => 'Import Failed', - 'import_success' => 'Import Success', - ], -]; diff --git a/lang/en/server/schedule.php b/lang/en/server/schedule.php index 87507bc83..fbb49637e 100644 --- a/lang/en/server/schedule.php +++ b/lang/en/server/schedule.php @@ -30,6 +30,8 @@ return [ 'cron_body' => 'Please keep in mind that the cron inputs below always assume UTC.', 'cron_timezone' => 'Next run in your timezone (:timezone): :next_run ', + 'invalid' => 'Invalid', + 'time' => [ 'minute' => 'Minute', 'hour' => 'Hour', @@ -104,4 +106,13 @@ return [ 'notification_invalid_cron' => 'The cron data provided does not evaluate to a valid expression', + 'import_action' => [ + 'file' => 'File', + 'url' => 'URL', + 'schedule_help' => 'This should be the raw .json file ( schedule-daily-restart.json )', + 'url_help' => 'URLs must point directly to the raw .json file', + 'add_url' => 'New URL', + 'import_failed' => 'Import Failed', + 'import_success' => 'Import Success', + ], ];