From 3401750b05bdcbb6097fc1d06b00387dc4fa32a7 Mon Sep 17 00:00:00 2001 From: Florian Thoma Date: Fri, 26 Apr 2024 10:14:28 +1000 Subject: [PATCH] display publish button within MajorActions if available --- src/Extensions/ElementalAreasContainer.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Extensions/ElementalAreasContainer.php b/src/Extensions/ElementalAreasContainer.php index bbd29e4..43df3e6 100644 --- a/src/Extensions/ElementalAreasContainer.php +++ b/src/Extensions/ElementalAreasContainer.php @@ -42,13 +42,19 @@ public function onAfterDuplicate(DataObject $original, bool $doWrite): void public function updateCMSActions(FieldList $actions) { - $actions->push( - $action = CustomAction::create('doPublishWithAreas', 'Publish (including all blocks)') - ->setShouldRefresh(true) - ->addExtraClass('btn-outline-primary') - ->removeExtraClass('btn-info') - ); - $action->setAttribute('style', 'margin-left:auto;'); + $action = CustomAction::create('doPublishWithAreas', 'Publish (including all blocks)') + ->setShouldRefresh(true) + ->addExtraClass('btn-outline-primary') + ->removeExtraClass('btn-info'); + + $MajorActions = $actions->fieldByName('MajorActions'); + + if ($MajorActions) { + $MajorActions->push($action); + } else { + $actions->push($action); + $action->setAttribute('style', 'margin-left:auto;'); + } } public function doPublishWithAreas()