Fix translation for invalid schedule cron + cleanup translations for import modal (#1618)

This commit is contained in:
Boy132 2025-08-18 23:54:25 +02:00 committed by GitHub
parent bc4dfb3e92
commit 42db5b328a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 27 deletions

View File

@ -39,26 +39,26 @@ class ImportScheduleAction extends Action
Tabs::make('Tabs') Tabs::make('Tabs')
->contained(false) ->contained(false)
->tabs([ ->tabs([
Tab::make(trans('admin/schedule.import.file')) Tab::make(trans('server/schedule.import_action.file'))
->icon('tabler-file-upload') ->icon('tabler-file-upload')
->schema([ ->schema([
FileUpload::make('files') FileUpload::make('files')
->label(trans('admin/schedule.model_label')) ->hiddenLabel()
->hint(trans('admin/schedule.import.schedule_help')) ->hint(trans('server/schedule.import_action.schedule_help'))
->acceptedFileTypes(['application/json']) ->acceptedFileTypes(['application/json'])
->preserveFilenames() ->preserveFilenames()
->previewable(false) ->previewable(false)
->storeFiles(false) ->storeFiles(false)
->multiple(true), ->multiple(true),
]), ]),
Tab::make(trans('admin/schedule.import.url')) Tab::make(trans('server/schedule.import_action.url'))
->icon('tabler-world-upload') ->icon('tabler-world-upload')
->schema([ ->schema([
Repeater::make('urls') Repeater::make('urls')
->label('') ->hiddenLabel()
->itemLabel(fn (array $state) => str($state['url'])->afterLast('/schedule-')->before('.json')->headline()) ->itemLabel(fn (array $state) => str($state['url'])->afterLast('/schedule-')->before('.json')->headline())
->hint(trans('admin/schedule.import.url_help')) ->hint(trans('server/schedule.import_action.url_help'))
->addActionLabel(trans('admin/schedule.import.add_url')) ->addActionLabel(trans('server/schedule.import_action.add_url'))
->grid(2) ->grid(2)
->reorderable(false) ->reorderable(false)
->addable(true) ->addable(true)
@ -66,10 +66,10 @@ class ImportScheduleAction extends Action
->schema([ ->schema([
TextInput::make('url') TextInput::make('url')
->live() ->live()
->label(trans('admin/schedule.import.url')) ->label(trans('server/schedule.import_action.url'))
->url() ->url()
->endsWith('.json') ->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) { if ($failed->count() > 0) {
Notification::make() Notification::make()
->title(trans('admin/schedule.import.import_failed')) ->title(trans('server/schedule.import_action.import_failed'))
->body($failed->join(', ')) ->body($failed->join(', '))
->danger() ->danger()
->send(); ->send();
} }
if ($success->count() > 0) { if ($success->count() > 0) {
Notification::make() Notification::make()
->title(trans('admin/schedule.import.import_success')) ->title(trans('server/schedule.import_action.import_success'))
->body($success->join(', ')) ->body($success->join(', '))
->success() ->success()
->send(); ->send();

View File

@ -115,7 +115,15 @@ class ScheduleResource extends Resource
->visibleOn('view'), ->visibleOn('view'),
Section::make('Cron') Section::make('Cron')
->label(trans('server/schedule.cron')) ->label(trans('server/schedule.cron'))
->description(fn (Get $get) => new HtmlString(trans('server/schedule.cron_body') . '<br>' . 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') . '<br>' . trans('server/schedule.cron_timezone', ['timezone' => auth()->user()->timezone, 'next_run' => $nextRun]));
})
->schema([ ->schema([
Actions::make([ Actions::make([
CronPresetAction::make('hourly') CronPresetAction::make('hourly')

View File

@ -1,15 +0,0 @@
<?php
return [
'model_label' => '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',
],
];

View File

@ -30,6 +30,8 @@ return [
'cron_body' => 'Please keep in mind that the cron inputs below always assume UTC.', 'cron_body' => 'Please keep in mind that the cron inputs below always assume UTC.',
'cron_timezone' => 'Next run in your timezone (:timezone): <b> :next_run </b>', 'cron_timezone' => 'Next run in your timezone (:timezone): <b> :next_run </b>',
'invalid' => 'Invalid',
'time' => [ 'time' => [
'minute' => 'Minute', 'minute' => 'Minute',
'hour' => 'Hour', 'hour' => 'Hour',
@ -104,4 +106,13 @@ return [
'notification_invalid_cron' => 'The cron data provided does not evaluate to a valid expression', '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',
],
]; ];