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')
->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();

View File

@ -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') . '<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([
Actions::make([
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_timezone' => 'Next run in your timezone (:timezone): <b> :next_run </b>',
'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',
],
];