From e4f584d509a3e4256f7c36129133cfdcba94ccbb Mon Sep 17 00:00:00 2001 From: antoine Date: Wed, 21 Jan 2026 19:39:31 +0100 Subject: [PATCH 1/2] wip allow show primary commands --- demo/app/Sharp/Posts/PostShow.php | 6 +- resources/js/Pages/Show/Show.vue | 65 ++++++++++++------- resources/js/show/Show.ts | 43 +++++++++--- .../Traits/HandleDashboardCommands.php | 7 +- .../Traits/HandleEntityCommands.php | 17 ++--- .../Traits/HandleInstanceCommands.php | 9 +-- .../Traits/HandleInstancePrimaryCommands.php | 17 +++++ .../Traits/Utils/CommonCommandUtils.php | 5 +- src/Show/SharpShow.php | 2 + tests/Unit/Dashboard/DashboardCommandTest.php | 2 + .../EntityList/SharpEntityListCommandTest.php | 2 + 11 files changed, 117 insertions(+), 58 deletions(-) create mode 100644 src/EntityList/Traits/HandleInstancePrimaryCommands.php diff --git a/demo/app/Sharp/Posts/PostShow.php b/demo/app/Sharp/Posts/PostShow.php index 74a99018c..efc3a033f 100644 --- a/demo/app/Sharp/Posts/PostShow.php +++ b/demo/app/Sharp/Posts/PostShow.php @@ -109,7 +109,10 @@ public function buildShowConfig(): void ->configureEntityState('state', PostStateHandler::class) ->configureBreadcrumbCustomLabelAttribute('breadcrumb') ->configurePageTitleAttribute('title', localized: true) - ->configureDeleteConfirmationText('Are you sure you want to delete this post (this will permanently delete its data)?'); + ->configureDeleteConfirmationText('Are you sure you want to delete this post (this will permanently delete its data)?') + ->configurePrimaryInstanceCommands([ + PreviewPostCommand::class, + ]); } protected function buildPageAlert(PageAlert $pageAlert): void @@ -132,7 +135,6 @@ public function getInstanceCommands(): ?array PreviewPostCommand::class, ], EvaluateDraftPostWizardCommand::class, - PreviewPostCommand::class, ]; } diff --git a/resources/js/Pages/Show/Show.vue b/resources/js/Pages/Show/Show.vue index 93f3a37b8..461386072 100644 --- a/resources/js/Pages/Show/Show.vue +++ b/resources/js/Pages/Show/Show.vue @@ -65,7 +65,7 @@ if(show.layout.sections[0] && ( show.sectionHasField(show.layout.sections[0], 'entityList') || show.layout.sections[0].title - || show.sectionCommands(show.layout.sections[0])?.flat().length + || show.sectionAllowedCommands(show.layout.sections[0])?.flat().length ) || !show.layout.sections.length) { return [ @@ -207,7 +207,7 @@