From 2b24e9bcf8c595fabc043d8bd3651298290683ac Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 5 Oct 2021 19:13:57 +0200 Subject: [PATCH] BranchedObjectHint: move, support BranchedObject --- .../Web/Controller/ObjectController.php | 2 +- ...nBranchHint.php => BranchedObjectHint.php} | 23 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) rename library/Director/Web/Widget/{ObjectModificationBranchHint.php => BranchedObjectHint.php} (79%) diff --git a/library/Director/Web/Controller/ObjectController.php b/library/Director/Web/Controller/ObjectController.php index 59a2b43e..f27dddd9 100644 --- a/library/Director/Web/Controller/ObjectController.php +++ b/library/Director/Web/Controller/ObjectController.php @@ -28,7 +28,7 @@ use Icinga\Module\Director\Web\Table\ActivityLogTable; use Icinga\Module\Director\Web\Table\GroupMemberTable; use Icinga\Module\Director\Web\Table\IcingaObjectDatafieldTable; use Icinga\Module\Director\Web\Tabs\ObjectTabs; -use Icinga\Module\Director\Web\Widget\ObjectModificationBranchHint; +use Icinga\Module\Director\Web\Widget\BranchedObjectHint; use gipfl\IcingaWeb2\Link; abstract class ObjectController extends ActionController diff --git a/library/Director/Web/Widget/ObjectModificationBranchHint.php b/library/Director/Web/Widget/BranchedObjectHint.php similarity index 79% rename from library/Director/Web/Widget/ObjectModificationBranchHint.php rename to library/Director/Web/Widget/BranchedObjectHint.php index 5e6f3715..89b3556f 100644 --- a/library/Director/Web/Widget/ObjectModificationBranchHint.php +++ b/library/Director/Web/Widget/BranchedObjectHint.php @@ -5,17 +5,16 @@ namespace Icinga\Module\Director\Web\Widget; use gipfl\Translation\TranslationHelper; use gipfl\Web\Widget\Hint; use Icinga\Authentication\Auth; -use Icinga\Module\Director\Data\Db\DbObject; use Icinga\Module\Director\Db\Branch\Branch; -use Icinga\Module\Director\Db\Branch\ObjectModification; +use Icinga\Module\Director\Db\Branch\BranchedObject; use ipl\Html\Html; use ipl\Html\HtmlDocument; -class ObjectModificationBranchHint extends HtmlDocument +class BranchedObjectHint extends HtmlDocument { use TranslationHelper; - public function __construct(Branch $branch, Auth $auth, DbObject $object, ObjectModification $modification = null) + public function __construct(Branch $branch, Auth $auth, BranchedObject $object) { if (! $branch->isBranch()) { return; @@ -30,7 +29,7 @@ class ObjectModificationBranchHint extends HtmlDocument } $link = $hook->linkToBranch($branch, $auth, $label); - if ($modification === null) { + if (! $object->hasBeenTouchedByBranch()) { $this->add(Hint::info(Html::sprintf($this->translate( 'Your changes will be stored in %s. The\'ll not be part of any deployment' . ' unless being merged' @@ -38,23 +37,23 @@ class ObjectModificationBranchHint extends HtmlDocument return; } - if ($modification->isDeletion()) { + if ($object->hasBeenDeletedByBranch()) { $this->add(Hint::info(Html::sprintf( $this->translate('This object has been deleted in %s'), $link ))); - } elseif ($modification->isModification()) { + } elseif ($object->hasBeenCreatedByBranch()) { + $this->add(Hint::info(Html::sprintf( + $this->translate('This object has been created in %s'), + $link + ))); + } else { $this->add(Hint::info(Html::sprintf( $this->translate('This object has modifications visible only in %s'), // TODO: Also link to object modifications // $hook->linkToBranchedObject($this->translate('modifications'), $branch, $object, $auth), $link ))); - } else { - $this->add(Hint::info(Html::sprintf( - $this->translate('This object has been created in %s'), - $link - ))); } } }