BranchedObjectHint: move, support BranchedObject

This commit is contained in:
Thomas Gelf 2021-10-05 19:13:57 +02:00
parent 2f1a47c34a
commit 2b24e9bcf8
2 changed files with 12 additions and 13 deletions

View File

@ -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

View File

@ -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
)));
}
}
}