BranchedObjectsHint: new hints for lists

This commit is contained in:
Thomas Gelf 2021-08-23 08:56:16 +02:00
parent 48ac87cff5
commit 085cec0eb7
2 changed files with 30 additions and 0 deletions

View File

@ -23,6 +23,7 @@ use Icinga\Module\Director\Web\Tabs\ObjectsTabs;
use Icinga\Module\Director\Web\Tree\TemplateTreeRenderer;
use gipfl\IcingaWeb2\Link;
use Icinga\Module\Director\Web\Widget\AdditionalTableActions;
use Icinga\Module\Director\Web\Widget\BranchedObjectsHint;
abstract class ObjectsController extends ActionController
{
@ -119,6 +120,8 @@ abstract class ObjectsController extends ActionController
->addTitle($this->translate(ucfirst($this->getPluralType())))
->actions(new ObjectsActionBar($this->getBaseObjectUrl(), $this->url()));
$this->content()->add(new BranchedObjectsHint($this->getBranch(), $this->Auth()));
if ($type === 'command' && $this->params->get('type') === 'external_object') {
$this->tabs()->activate('external');
}

View File

@ -0,0 +1,27 @@
<?php
namespace Icinga\Module\Director\Web\Widget;
use gipfl\Translation\TranslationHelper;
use gipfl\Web\Widget\Hint;
use Icinga\Authentication\Auth;
use Icinga\Module\Director\Db\Branch\Branch;
use ipl\Html\Html;
use ipl\Html\HtmlDocument;
class BranchedObjectsHint extends HtmlDocument
{
use TranslationHelper;
public function __construct(Branch $branch, Auth $auth)
{
if (! $branch->isBranch()) {
return;
}
$hook = Branch::requireHook();
$this->add(Hint::info(Html::sprintf(
$this->translate('Showing a branched view, with potential changes being visible only in this %s'),
$hook->linkToBranch($branch, $auth, $this->translate('configuration branch'))
)));
}
}