Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small changes for new client area #751

Merged
merged 8 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/Filament/Resources/ServerResource/Pages/EditServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Enums\ServerState;
use App\Filament\Resources\ServerResource;
use App\Filament\Resources\ServerResource\RelationManagers\AllocationsRelationManager;
use App\Filament\Server\Pages\Console;
use App\Models\Database;
use App\Models\DatabaseHost;
use App\Models\Egg;
Expand Down Expand Up @@ -870,7 +871,7 @@ protected function getHeaderActions(): array
Actions\Action::make('console')
->label('Console')
->icon('tabler-terminal')
->url(fn (Server $server) => "/server/$server->uuid_short"),
->url(fn (Server $server) => Console::getUrl(panel: 'server', tenant: $server)),
$this->getSaveFormAction()->formId('form'),
];

Expand Down
6 changes: 3 additions & 3 deletions app/Filament/Server/Pages/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function form(Form $form): Form
->schema([
TextInput::make('name')
->label('Server Name')
->disabled(!auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server))
->disabled(fn () => !auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server))
->required()
->columnSpan([
'default' => 1,
Expand All @@ -66,7 +66,7 @@ public function form(Form $form): Form
Textarea::make('description')
->label('Server Description')
->hidden(!config('panel.editable_server_descriptions'))
->disabled(!auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server))
->disabled(fn () => !auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server))
->columnSpan([
'default' => 1,
'sm' => 2,
Expand Down Expand Up @@ -168,7 +168,7 @@ public function form(Form $form): Form
->footerActions([
Action::make('reinstall')
->color('danger')
->disabled(!auth()->user()->can(Permission::ACTION_SETTINGS_REINSTALL, $server))
->disabled(fn () => !auth()->user()->can(Permission::ACTION_SETTINGS_REINSTALL, $server))
->label('Reinstall')
->requiresConfirmation()
->modalHeading('Are you sure you want to reinstall the server?')
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Server/Pages/Startup.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function form(Form $form): Form
->label('Docker Image')
->live()
->visible(fn (Server $server) => in_array($server->image, $server->egg->docker_images))
->disabled(!auth()->user()->can(Permission::ACTION_STARTUP_DOCKER_IMAGE, $server))
->disabled(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_DOCKER_IMAGE, $server))
->afterStateUpdated(function ($state, Server $server) {
$original = $server->image;
$server->forceFill(['image' => $state])->saveOrFail();
Expand Down Expand Up @@ -97,7 +97,7 @@ public function form(Form $form): Form
->label('')
->relationship('viewableServerVariables')
->grid()
->disabled(!auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
->disabled(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
->reorderable(false)->addable(false)->deletable(false)
->schema(function () {
$text = TextInput::make('variable_value')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function table(Table $table): Table
TextColumn::make('port'),
TextInputColumn::make('notes')
->disabled(fn () => !auth()->user()->can(Permission::ACTION_ALLOCATION_UPDATE, $server))
->label('Notes'),
->label('Notes')
->placeholder('No Notes'),
IconColumn::make('primary')
->icon(fn ($state) => match ($state) {
true => 'tabler-star-filled',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function form(Form $form): Form
->footerActions([
Action::make('save')
->label('Save Changes')
->authorize(auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
->icon('tabler-device-floppy')
->keyBindings('mod+s')
->action(function () use ($server) {
Expand Down
1 change: 1 addition & 0 deletions app/Filament/Server/Resources/ScheduleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public static function form(Form $form): Form
->default('*')
->required(),
Section::make('Presets')
->hiddenOn('view')
->schema([
Actions::make([
Action::make('hourly')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function table(Table $table): Table
->sortable(),
DateTimeColumn::make('last_run_at')
->label('Last run')
->placeholder('Never')
->since()
->sortable(),
DateTimeColumn::make('next_run_at')
Expand Down
9 changes: 9 additions & 0 deletions app/Providers/Filament/ServerPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Filament\App\Resources\ServerResource\Pages\ListServers;
use App\Filament\Pages\Auth\Login;
use App\Filament\Resources\ServerResource\Pages\EditServer;
use App\Filament\Resources\UserResource\Pages\EditProfile;
use App\Http\Middleware\Activity\ServerSubject;
use App\Models\Server;
Expand All @@ -12,6 +13,7 @@
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Navigation\MenuItem;
use Filament\Navigation\NavigationItem;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Enums\MaxWidth;
Expand Down Expand Up @@ -54,6 +56,13 @@ public function panel(Panel $panel): Panel
->sort(5)
->visible(fn (): bool => auth()->user()->canAccessPanel(Filament::getPanel('admin'))),
])
->navigationItems([
NavigationItem::make('Open in Admin')
->url(fn () => EditServer::getUrl(['record' => Filament::getTenant()], panel: 'admin', tenant: null), true)
->visible(fn () => auth()->user()->can('view server', Filament::getTenant()))
->icon('tabler-arrow-back')
->sort(99),
])
->discoverResources(in: app_path('Filament/Server/Resources'), for: 'App\\Filament\\Server\\Resources')
->discoverPages(in: app_path('Filament/Server/Pages'), for: 'App\\Filament\\Server\\Pages')
->discoverWidgets(in: app_path('Filament/Server/Widgets'), for: 'App\\Filament\\Server\\Widgets')
Expand Down
Loading