user()?->can('viewAny', Script::class) ?? false; } public function getWidgets(): array { return [ [Widgets\ScriptsList::class], ]; } protected function getHeaderActions(): array { return [ Action::make('read-the-docs') ->label('Read the Docs') ->icon('heroicon-o-document-text') ->color('gray') ->url('https://vitodeploy.com/other/scripts.html') ->openUrlInNewTab(), Action::make('create') ->label('Create a Script') ->icon('heroicon-o-plus') ->authorize('create', Script::class) ->modalWidth(MaxWidth::ThreeExtraLarge) ->form([ TextInput::make('name') ->rules(CreateScript::rules()['name']), CodeEditorField::make('content') ->rules(CreateScript::rules()['content']) ->helperText('You can use variables like ${VARIABLE_NAME} in the script. The variables will be asked when executing the script'), Checkbox::make('global') ->label('Is Global (Accessible in all projects)'), ]) ->modalSubmitActionLabel('Create') ->action(function (array $data) { run_action($this, function () use ($data) { app(CreateScript::class)->create(auth()->user(), $data); $this->dispatch('$refresh'); }); }), ]; } }