From cedacfa7970ad81a334009e1cc43f967cad20ecc Mon Sep 17 00:00:00 2001 From: KimSpeer Date: Fri, 7 Jun 2024 12:31:06 +0200 Subject: [PATCH] Feat[Backup Server Ui]: added Hintaction --- config/backup-server-ui.php | 93 +++++++++ .../config/backup-server-ui.php | 88 +++++++++ .../src/Resources/SourceResource.php | 179 +++++++++++++++++- 3 files changed, 352 insertions(+), 8 deletions(-) create mode 100644 config/backup-server-ui.php diff --git a/config/backup-server-ui.php b/config/backup-server-ui.php new file mode 100644 index 0000000..0c240b8 --- /dev/null +++ b/config/backup-server-ui.php @@ -0,0 +1,93 @@ + [ + 'inline_help' => [ + 'fields' => [ + 'name' => + [ + 'title' => '', + 'url' => '', + ], + 'host' => [ + 'title' => '', + 'url' => '', + ], + 'ssh_user' => [ + 'title' => '', + 'url' => '', + ], + 'ssh_port' => [ + 'title' => '', + 'url' => '', + ], + 'ssh_private_key_file' => [ + 'title' => '', + 'url' => '', + ], + 'cron_expression' => [ + 'title' => '', + 'url' => '', + ], + 'destination_id' => [ + 'title' => '', + 'url' => '', + ], + 'pre_backup_commands' => [ + 'title' => '', + 'url' => 'https://github.com/mooxphp/backup-server-ui/#pre_backup_commands', + ], + 'post_backup_commands' => [ + 'title' => '', + 'url' => 'https://moox.org/docs/backup-server-ui/#post_backup_commands', + ], + 'includes' => [ + 'title' => '', + 'url' => 'includes', + ], + 'excludes' => [ + 'title' => '', + 'url' => '', + ], + 'cleanup_strategy_class' => [ + 'title' => '', + 'url' => '', + ], + 'keep_all_backups_for_days' => [ + 'title' => '', + 'url' => '', + ], + 'keep_daily_backups_for_days' => [ + 'title' => '', + 'url' => '', + ], + 'keep_weekly_backups_for_weeks' => [ + 'title' => '', + 'url' => '', + ], + 'keep_monthly_backups_for_months' => [ + 'title' => '', + 'url' => '', + ], + 'keep_yearly_backups_for_years' => [ + 'title' => '', + 'url' => '', + ], + 'delete_oldest_backups_when_using_more_megabytes_than' => [ + 'title' => '', + 'url' => '', + ], + 'healthy_maximum_backup_age_in_days' => [ + 'title' => '', + 'url' => 'url', + ], + 'healthy_maximum_storage_in_mb' => [ + 'title' => '', + 'url' => '', + ], + ], + 'icon' => 'heroicon-c-question-mark-circle', + ], + ], + +]; diff --git a/packages/backup-server-ui/config/backup-server-ui.php b/packages/backup-server-ui/config/backup-server-ui.php index ca5d8ed..0c240b8 100644 --- a/packages/backup-server-ui/config/backup-server-ui.php +++ b/packages/backup-server-ui/config/backup-server-ui.php @@ -1,5 +1,93 @@ [ + 'inline_help' => [ + 'fields' => [ + 'name' => + [ + 'title' => '', + 'url' => '', + ], + 'host' => [ + 'title' => '', + 'url' => '', + ], + 'ssh_user' => [ + 'title' => '', + 'url' => '', + ], + 'ssh_port' => [ + 'title' => '', + 'url' => '', + ], + 'ssh_private_key_file' => [ + 'title' => '', + 'url' => '', + ], + 'cron_expression' => [ + 'title' => '', + 'url' => '', + ], + 'destination_id' => [ + 'title' => '', + 'url' => '', + ], + 'pre_backup_commands' => [ + 'title' => '', + 'url' => 'https://github.com/mooxphp/backup-server-ui/#pre_backup_commands', + ], + 'post_backup_commands' => [ + 'title' => '', + 'url' => 'https://moox.org/docs/backup-server-ui/#post_backup_commands', + ], + 'includes' => [ + 'title' => '', + 'url' => 'includes', + ], + 'excludes' => [ + 'title' => '', + 'url' => '', + ], + 'cleanup_strategy_class' => [ + 'title' => '', + 'url' => '', + ], + 'keep_all_backups_for_days' => [ + 'title' => '', + 'url' => '', + ], + 'keep_daily_backups_for_days' => [ + 'title' => '', + 'url' => '', + ], + 'keep_weekly_backups_for_weeks' => [ + 'title' => '', + 'url' => '', + ], + 'keep_monthly_backups_for_months' => [ + 'title' => '', + 'url' => '', + ], + 'keep_yearly_backups_for_years' => [ + 'title' => '', + 'url' => '', + ], + 'delete_oldest_backups_when_using_more_megabytes_than' => [ + 'title' => '', + 'url' => '', + ], + 'healthy_maximum_backup_age_in_days' => [ + 'title' => '', + 'url' => 'url', + ], + 'healthy_maximum_storage_in_mb' => [ + 'title' => '', + 'url' => '', + ], + ], + 'icon' => 'heroicon-c-question-mark-circle', + ], + ], ]; diff --git a/packages/backup-server-ui/src/Resources/SourceResource.php b/packages/backup-server-ui/src/Resources/SourceResource.php index 1c8b0c0..56eddb2 100644 --- a/packages/backup-server-ui/src/Resources/SourceResource.php +++ b/packages/backup-server-ui/src/Resources/SourceResource.php @@ -2,24 +2,27 @@ namespace Moox\BackupServerUi\Resources; +use Filament\Forms\Form; +use Filament\Tables\Table; +use Filament\Forms\Components\Actions\Action; +use Filament\Resources\Resource; use Filament\Forms\Components\Grid; use Filament\Forms\Components\Hidden; -use Filament\Forms\Components\KeyValue; -use Filament\Forms\Components\Section; use Filament\Forms\Components\Select; -use Filament\Forms\Components\TextInput; -use Filament\Forms\Form; -use Filament\Resources\Resource; -use Filament\Tables\Actions\DeleteBulkAction; +use Filament\Forms\Components\Section; +use Spatie\BackupServer\Models\Source; +use Filament\Forms\Components\KeyValue; use Filament\Tables\Actions\EditAction; use Filament\Tables\Actions\ViewAction; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; +use Filament\Forms\Components\TextInput; use Filament\Tables\Filters\SelectFilter; -use Filament\Tables\Table; +use Filament\Tables\Actions\DeleteBulkAction; +use Illuminate\Support\Facades\Config; +use Moox\BackupServerUi\Form\Components\HintAction; use Moox\BackupServerUi\Resources\SourceResource\Pages; use Moox\BackupServerUi\Resources\SourceResource\RelationManagers\BackupsRelationManager; -use Spatie\BackupServer\Models\Source; class SourceResource extends Resource { @@ -51,6 +54,14 @@ public static function form(Form $form): Form ->default('2'), TextInput::make('name') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.name') != ""){ + return HintAction::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.name.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.name.url'),true); + } + }) ->rules(['max:255', 'string']) ->required() ->placeholder('Name') @@ -61,6 +72,14 @@ public static function form(Form $form): Form ]), TextInput::make('host') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.host') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.host.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.host.url'),true); + } + }) ->rules(['max:255', 'string']) ->required() ->placeholder('Host') @@ -71,6 +90,14 @@ public static function form(Form $form): Form ]), TextInput::make('ssh_user') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.ssh_user') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.ssh_user.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.ssh_user.url'),true); + } + }) ->rules(['max:255', 'string']) ->required() ->placeholder('Ssh User') @@ -81,6 +108,14 @@ public static function form(Form $form): Form ]), TextInput::make('ssh_port') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.ssh_port') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.ssh_port.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.ssh_port.url'),true); + } + }) ->rules(['numeric']) ->required() ->numeric() @@ -92,6 +127,14 @@ public static function form(Form $form): Form ]), TextInput::make('ssh_private_key_file') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.ssh_private_key_file') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.ssh_private_key_file.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.ssh_private_key_file.url'),true); + } + }) ->rules(['max:255', 'string']) ->nullable() ->placeholder('Ssh Private Key File') @@ -102,6 +145,14 @@ public static function form(Form $form): Form ]), TextInput::make('cron_expression') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.cron_expression') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.cron_expression.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.cron_expression.url'),true); + } + }) ->rules(['max:255', 'string']) ->required() ->placeholder('Cron Expression') @@ -112,6 +163,14 @@ public static function form(Form $form): Form ]), Select::make('destination_id') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.destination_id') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.destination_id.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.destination_id.url'),true); + } + }) ->rules(['exists:backup_server_destinations,id']) ->relationship('destination', 'name') ->searchable() @@ -125,6 +184,14 @@ public static function form(Form $form): Form ]), KeyValue::make('pre_backup_commands') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.pre_backup_commands') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.pre_backup_commands.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.pre_backup_commands.url'),true); + } + }) ->nullable() ->columnSpan([ 'default' => 12, @@ -133,6 +200,14 @@ public static function form(Form $form): Form ]), KeyValue::make('post_backup_commands') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.post_backup_commands') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.post_backup_commands.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.post_backup_commands.url'),true); + } + }) ->nullable() ->columnSpan([ 'default' => 12, @@ -141,6 +216,14 @@ public static function form(Form $form): Form ]), KeyValue::make('includes') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.includes') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.includes.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.includes.url'),true); + } + }) ->nullable() ->columnSpan([ 'default' => 12, @@ -149,6 +232,14 @@ public static function form(Form $form): Form ]), KeyValue::make('excludes') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.excludes') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.excludes.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.excludes.url'),true); + } + }) ->nullable() ->columnSpan([ 'default' => 12, @@ -157,6 +248,14 @@ public static function form(Form $form): Form ]), TextInput::make('cleanup_strategy_class') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.cleanup_strategy_class') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.cleanup_strategy_class.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.cleanup_strategy_class.url'),true); + } + }) ->rules(['max:255', 'string']) ->nullable() ->placeholder('Cleanup Strategy Class') @@ -167,6 +266,14 @@ public static function form(Form $form): Form ]), TextInput::make('keep_all_backups_for_days') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.keep_all_backups_for_days') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.cleanup_strkeep_all_backups_for_daysategy_class.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.keep_all_backups_for_days.url'),true); + } + }) ->rules(['numeric']) ->nullable() ->numeric() @@ -178,6 +285,14 @@ public static function form(Form $form): Form ]), TextInput::make('keep_daily_backups_for_days') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.keep_daily_backups_for_days') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.keep_daily_backups_for_days.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.keep_daily_backups_for_days.url'),true); + } + }) ->rules(['numeric']) ->nullable() ->numeric() @@ -189,6 +304,14 @@ public static function form(Form $form): Form ]), TextInput::make('keep_weekly_backups_for_weeks') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.keep_weekly_backups_for_weeks') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.keep_weekly_backups_for_weeks.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.keep_weekly_backups_for_weeks.url'),true); + } + }) ->rules(['numeric']) ->nullable() ->numeric() @@ -200,6 +323,14 @@ public static function form(Form $form): Form ]), TextInput::make('keep_monthly_backups_for_months') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.keep_monthly_backups_for_months') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.keep_monthly_backups_for_months.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.keep_monthly_backups_for_months.url'),true); + } + }) ->rules(['numeric']) ->nullable() ->numeric() @@ -211,6 +342,14 @@ public static function form(Form $form): Form ]), TextInput::make('keep_yearly_backups_for_years') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.keep_yearly_backups_for_years') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.keep_yearly_backups_for_years.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.keep_yearly_backups_for_years.url'),true); + } + }) ->rules(['numeric']) ->nullable() ->numeric() @@ -224,6 +363,14 @@ public static function form(Form $form): Form TextInput::make( 'delete_oldest_backups_when_using_more_megabytes_than' ) + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.delete_oldest_backups_when_using_more_megabytes_than') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.delete_oldest_backups_when_using_more_megabytes_than.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.delete_oldest_backups_when_using_more_megabytes_than.url'),true); + } + }) ->rules(['numeric']) ->nullable() ->numeric() @@ -237,6 +384,14 @@ public static function form(Form $form): Form ]), TextInput::make('healthy_maximum_backup_age_in_days') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.healthy_maximum_backup_age_in_days') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.healthy_maximum_backup_age_in_days.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.healthy_maximum_backup_age_in_days.url'),true); + } + }) ->rules(['numeric']) ->nullable() ->numeric() @@ -248,6 +403,14 @@ public static function form(Form $form): Form ]), TextInput::make('healthy_maximum_storage_in_mb') + ->hintAction(function(){ + if(config('backup-server-ui.backup_source.inline_help.fields.healthy_maximum_storage_in_mb') != ""){ + return Action::make('help') + ->label(Config::get('backup-server-ui.backup_source.inline_help.fields.healthy_maximum_storage_in_mb.title','')) + ->icon(Config::get('backup-server-ui.backup_source.inline_help.icon','heroicon-o-question-mark-circle')) + ->url(Config::get('backup-server-ui.backup_source.inline_help.fields.healthy_maximum_storage_in_mb.url'),true); + } + }) ->rules(['numeric']) ->nullable() ->numeric()