-
-
Notifications
You must be signed in to change notification settings - Fork 254
View pages #1998
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
Draft
JoanFo1456
wants to merge
11
commits into
pelican-dev:main
Choose a base branch
from
JoanFo1456:admin/view-pages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,604
−2,244
Draft
View pages #1998
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ec3f500
Server view page
JoanFo1456 0fbcba1
Node view page
JoanFo1456 a9a9469
Fixed a bunch of permissions missing & egg view
JoanFo1456 1abb046
phpstan and pint, jesus...
JoanFo1456 a0528de
Oops forgot this
JoanFo1456 e312492
Permission fix 2
JoanFo1456 89c25c6
Fixed Actions working on view
JoanFo1456 3568d34
Star was permitted phpstan and pint
JoanFo1456 bd3ad34
Rabbit suggestions applied
JoanFo1456 5b69856
Really?
JoanFo1456 0bb6947
Merge remote-tracking branch 'origin/main' into admin/view-pages
JoanFo1456 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?php | ||
|
|
||
| namespace App\Filament\Admin\Resources\Eggs\Pages; | ||
|
|
||
| use App\Filament\Admin\Resources\Eggs\EggResource; | ||
| use App\Traits\Filament\CanCustomizeHeaderActions; | ||
| use App\Traits\Filament\CanCustomizeHeaderWidgets; | ||
| use Filament\Resources\Pages\ViewRecord; | ||
| use Filament\Schemas\Schema; | ||
|
|
||
| class ViewEgg extends ViewRecord | ||
| { | ||
| use CanCustomizeHeaderActions; | ||
| use CanCustomizeHeaderWidgets; | ||
|
|
||
| protected static string $resource = EggResource::class; | ||
|
|
||
| public function form(Schema $schema): Schema | ||
| { | ||
| return EggResource::schema($schema); | ||
| } | ||
| } |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <?php | ||
|
|
||
| namespace App\Filament\Admin\Resources\Nodes\Pages; | ||
|
|
||
| use App\Filament\Admin\Resources\Nodes\NodeResource; | ||
| use App\Filament\Admin\Resources\Nodes\RelationManagers\AllocationsRelationManager; | ||
| use App\Filament\Admin\Resources\Nodes\RelationManagers\ServersRelationManager; | ||
| use App\Traits\Filament\CanCustomizeHeaderActions; | ||
| use App\Traits\Filament\CanCustomizeHeaderWidgets; | ||
| use Filament\Notifications\Notification; | ||
| use Filament\Resources\Pages\ViewRecord; | ||
| use Filament\Schemas\Schema; | ||
|
|
||
| class ViewNode extends ViewRecord | ||
| { | ||
| use CanCustomizeHeaderActions; | ||
| use CanCustomizeHeaderWidgets; | ||
|
|
||
| protected static string $resource = NodeResource::class; | ||
|
|
||
| public function form(Schema $schema): Schema | ||
| { | ||
| return NodeResource::schema($schema); | ||
| } | ||
|
|
||
| public function getRelationManagers(): array | ||
| { | ||
| return [ | ||
| AllocationsRelationManager::class, | ||
| ServersRelationManager::class, | ||
| ]; | ||
| } | ||
|
|
||
| protected function getSavedNotification(): ?Notification | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| protected function getColumnSpan(): ?int | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| protected function getColumnStart(): ?int | ||
| { | ||
| return null; | ||
| } | ||
| } |
1,083 changes: 8 additions & 1,075 deletions
1,083
app/Filament/Admin/Resources/Servers/Pages/EditServer.php
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
app/Filament/Admin/Resources/Servers/Pages/ViewServer.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| <?php | ||
|
|
||
| namespace App\Filament\Admin\Resources\Servers\Pages; | ||
|
|
||
| use App\Filament\Admin\Resources\Servers\RelationManagers\AllocationsRelationManager; | ||
| use App\Filament\Admin\Resources\Servers\RelationManagers\DatabasesRelationManager; | ||
| use App\Filament\Admin\Resources\Servers\ServerResource; | ||
| use App\Filament\Server\Pages\Console; | ||
| use App\Models\Server; | ||
| use App\Services\Servers\ServerDeletionService; | ||
| use App\Traits\Filament\CanCustomizeHeaderActions; | ||
| use App\Traits\Filament\CanCustomizeHeaderWidgets; | ||
| use Filament\Actions\Action; | ||
| use Filament\Actions\ActionGroup; | ||
| use Filament\Actions\EditAction; | ||
| use Filament\Notifications\Notification; | ||
| use Filament\Resources\Pages\ViewRecord; | ||
| use Filament\Schemas\Schema; | ||
| use Filament\Support\Enums\IconSize; | ||
| use Illuminate\Http\Client\ConnectionException; | ||
| use Predis\Connection\ConnectionException as PredisConnectionException; | ||
|
|
||
| class ViewServer extends ViewRecord | ||
| { | ||
| use CanCustomizeHeaderActions; | ||
| use CanCustomizeHeaderWidgets; | ||
|
|
||
| protected static string $resource = ServerResource::class; | ||
|
|
||
| /** | ||
| * @throws \Random\RandomException | ||
| * @throws \Exception | ||
| */ | ||
| public function form(Schema $schema): Schema | ||
| { | ||
| return ServerResource::schema($schema); | ||
| } | ||
|
|
||
| public function getRelationManagers(): array | ||
| { | ||
| return [ | ||
| AllocationsRelationManager::class, | ||
| DatabasesRelationManager::class, | ||
| ]; | ||
| } | ||
|
|
||
| /** @return array<Action|ActionGroup> */ | ||
| protected function getDefaultHeaderActions(): array | ||
| { | ||
| /** @var Server $server */ | ||
| $server = $this->getRecord(); | ||
|
|
||
| $canForceDelete = cache()->get("servers.$server->uuid.canForceDelete", false); | ||
|
|
||
| return [ | ||
| Action::make('console') | ||
| ->label(trans('admin/server.console')) | ||
| ->icon('tabler-terminal') | ||
| ->iconButton()->iconSize(IconSize::ExtraLarge) | ||
| ->url(fn (Server $server) => Console::getUrl(panel: 'server', tenant: $server)), | ||
| Action::make('Delete') | ||
| ->color('danger') | ||
| ->label(trans('filament-actions::delete.single.label')) | ||
| ->modalHeading(trans('filament-actions::delete.single.modal.heading', ['label' => $server->name])) | ||
| ->modalSubmitActionLabel(trans('filament-actions::delete.single.label')) | ||
| ->requiresConfirmation() | ||
| ->action(function (Server $server, ServerDeletionService $service) { | ||
| try { | ||
| $service->handle($server); | ||
|
|
||
| return redirect(ListServers::getUrl(panel: 'admin')); | ||
| } catch (ConnectionException|PredisConnectionException) { | ||
| cache()->put("servers.$server->uuid.canForceDelete", true, now()->addMinutes(5)); | ||
|
|
||
| return Notification::make() | ||
| ->title(trans('admin/server.notifications.error_server_delete')) | ||
| ->body(trans('admin/server.notifications.error_server_delete_body')) | ||
| ->color('warning') | ||
| ->icon('tabler-database') | ||
| ->warning() | ||
| ->send(); | ||
| } | ||
| }) | ||
| ->hidden(fn () => $canForceDelete) | ||
| ->authorize(fn (Server $server) => user()?->can('delete server', $server)) | ||
| ->icon('tabler-trash') | ||
| ->iconButton()->iconSize(IconSize::ExtraLarge), | ||
| Action::make('ForceDelete') | ||
| ->color('danger') | ||
| ->label(trans('filament-actions::force-delete.single.label')) | ||
| ->modalHeading(trans('filament-actions::force-delete.single.modal.heading', ['label' => $server->name])) | ||
| ->modalSubmitActionLabel(trans('filament-actions::force-delete.single.label')) | ||
| ->requiresConfirmation() | ||
| ->action(function (Server $server, ServerDeletionService $service) { | ||
| try { | ||
| $service->withForce()->handle($server); | ||
|
|
||
| return redirect(ListServers::getUrl(panel: 'admin')); | ||
| } catch (ConnectionException|PredisConnectionException) { | ||
| return cache()->forget("servers.$server->uuid.canForceDelete"); | ||
| } | ||
| }) | ||
| ->visible(fn () => $canForceDelete) | ||
| ->authorize(fn (Server $server) => user()?->can('delete server', $server)), | ||
| EditAction::make() | ||
| ->icon('tabler-pencil') | ||
| ->iconButton()->iconSize(IconSize::ExtraLarge), | ||
| ]; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silent failure on ForceDelete connection error.
When
ForceDeletefails due to a connection exception, the cache flag is cleared but no notification is shown to the user. This could leave the user confused about why the action didn't complete.->action(function (Server $server, ServerDeletionService $service) { try { $service->withForce()->handle($server); return redirect(ListServers::getUrl(panel: 'admin')); } catch (ConnectionException|PredisConnectionException) { - return cache()->forget("servers.$server->uuid.canForceDelete"); + cache()->forget("servers.$server->uuid.canForceDelete"); + + return Notification::make() + ->title(trans('admin/server.notifications.error_server_delete')) + ->body(trans('admin/server.notifications.error_server_delete_body')) + ->color('danger') + ->icon('tabler-database') + ->danger() + ->send(); } })🤖 Prompt for AI Agents