ConfigController: some hints for branch activity

This commit is contained in:
Thomas Gelf 2021-08-23 08:49:39 +02:00
parent 1470a134f4
commit 53b2167925

View File

@ -8,6 +8,7 @@ use gipfl\Web\Widget\Hint;
use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\Filter;
use Icinga\Exception\IcingaException; use Icinga\Exception\IcingaException;
use Icinga\Exception\NotFoundError; use Icinga\Exception\NotFoundError;
use Icinga\Module\Director\Db\Branch\Branch;
use Icinga\Module\Director\Deployment\DeploymentStatus; use Icinga\Module\Director\Deployment\DeploymentStatus;
use Icinga\Module\Director\Forms\DeployConfigForm; use Icinga\Module\Director\Forms\DeployConfigForm;
use Icinga\Module\Director\Forms\SettingsForm; use Icinga\Module\Director\Forms\SettingsForm;
@ -151,11 +152,7 @@ class ConfigController extends ActionController
return; return;
} }
$this->assertPermission('director/audit'); $this->assertPermission('director/audit');
if ($branchUuid = $this->getBranchUuid()) { $this->showOptionalBranchActivity();
$table = new BranchActivityTable($branchUuid, $this->db());
$this->content()->add($table);
}
$this->setAutorefreshInterval(10); $this->setAutorefreshInterval(10);
$this->tabs(new InfraTabs($this->Auth()))->activate('activitylog'); $this->tabs(new InfraTabs($this->Auth()))->activate('activitylog');
$this->addTitle($this->translate('Activity Log')); $this->addTitle($this->translate('Activity Log'));
@ -430,6 +427,29 @@ class ConfigController extends ActionController
))); )));
} }
protected function showOptionalBranchActivity()
{
$branch = $this->getBranch();
if ($branch->isBranch() && (int) $this->params->get('page', '1') === 1) {
$table = new BranchActivityTable($branch->getUuid(), $this->db());
if (count($table) > 0) {
$this->content()->add(Hint::info(Html::sprintf($this->translate(
'The following modifications are visible in this %s only...'
), Branch::requireHook()->linkToBranch(
$branch,
$this->Auth(),
$this->translate('configuration branch')
))));
$table = new BranchActivityTable($branch->getUuid(), $this->db());
$this->content()->add($table);
$this->content()->add(Html::tag('br'));
$this->content()->add(Hint::ok($this->translate(
'...and the modifications below are already in the main branch:'
)));
}
}
}
/** /**
* @param $checksum * @param $checksum
*/ */