mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
parent
0db7240c96
commit
c643959d06
@ -18,6 +18,10 @@ This version hasn't been released yet
|
|||||||
### Icinga Configuration
|
### Icinga Configuration
|
||||||
* FIX: render Set Services to individual zones where required (#1589, #2356)
|
* FIX: render Set Services to individual zones where required (#1589, #2356)
|
||||||
|
|
||||||
|
### Configuration Branches
|
||||||
|
* FEATURE: with this release, directorbranches v1.3 supports a "default branch" (#2688)
|
||||||
|
* FEATURE: users with default branches get warnings in the main branch (#2689)
|
||||||
|
|
||||||
### Health Check
|
### Health Check
|
||||||
* FIX: complaint about overdue jobs was not correct (#2680, #2681)
|
* FIX: complaint about overdue jobs was not correct (#2680, #2681)
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ use gipfl\Web\Widget\Hint;
|
|||||||
use Icinga\Application\Hook;
|
use Icinga\Application\Hook;
|
||||||
use Icinga\Module\Director\Db\Branch\Branch;
|
use Icinga\Module\Director\Db\Branch\Branch;
|
||||||
use Icinga\Module\Director\Db\Branch\BranchStore;
|
use Icinga\Module\Director\Db\Branch\BranchStore;
|
||||||
|
use Icinga\Module\Director\Db\Branch\PreferredBranchSupport;
|
||||||
use Icinga\Module\Director\Hook\BranchSupportHook;
|
use Icinga\Module\Director\Hook\BranchSupportHook;
|
||||||
use ipl\Html\Html;
|
use ipl\Html\Html;
|
||||||
|
|
||||||
@ -19,6 +20,12 @@ class BranchesDashboard extends Dashboard
|
|||||||
$this->translate('You\'re currently working in a Configuration Branch: %s'),
|
$this->translate('You\'re currently working in a Configuration Branch: %s'),
|
||||||
Branch::requireHook()->linkToBranch($branch, $this->getAuth(), $branch->getName())
|
Branch::requireHook()->linkToBranch($branch, $this->getAuth(), $branch->getName())
|
||||||
)));
|
)));
|
||||||
|
} else {
|
||||||
|
if (($implementation = Branch::optionalHook()) && $implementation instanceof PreferredBranchSupport) {
|
||||||
|
$this->prepend(Hint::warning(
|
||||||
|
$this->translate('You\'re currently working in the main Configuration Branch'),
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->translate('Prepare your configuration in a safe Environment');
|
return $this->translate('Prepare your configuration in a safe Environment');
|
||||||
|
10
library/Director/Db/Branch/PreferredBranchSupport.php
Normal file
10
library/Director/Db/Branch/PreferredBranchSupport.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Director\Db\Branch;
|
||||||
|
|
||||||
|
use Icinga\Authentication\Auth;
|
||||||
|
|
||||||
|
interface PreferredBranchSupport
|
||||||
|
{
|
||||||
|
public function hasPreferredBranch(Auth $auth): bool;
|
||||||
|
}
|
@ -3,10 +3,10 @@
|
|||||||
namespace Icinga\Module\Director\Web\Controller;
|
namespace Icinga\Module\Director\Web\Controller;
|
||||||
|
|
||||||
use Icinga\Module\Director\Data\Db\DbObjectStore;
|
use Icinga\Module\Director\Data\Db\DbObjectStore;
|
||||||
use Icinga\Module\Director\Data\Db\DbObjectTypeRegistry;
|
|
||||||
use Icinga\Module\Director\Db\Branch\Branch;
|
use Icinga\Module\Director\Db\Branch\Branch;
|
||||||
use Icinga\Module\Director\Db\Branch\BranchStore;
|
use Icinga\Module\Director\Db\Branch\BranchStore;
|
||||||
use Icinga\Module\Director\Db\Branch\BranchSupport;
|
use Icinga\Module\Director\Db\Branch\BranchSupport;
|
||||||
|
use Icinga\Module\Director\Db\Branch\PreferredBranchSupport;
|
||||||
use Icinga\Module\Director\Objects\IcingaObject;
|
use Icinga\Module\Director\Objects\IcingaObject;
|
||||||
use Icinga\Module\Director\Web\Widget\NotInBranchedHint;
|
use Icinga\Module\Director\Web\Widget\NotInBranchedHint;
|
||||||
|
|
||||||
@ -18,6 +18,9 @@ trait BranchHelper
|
|||||||
/** @var BranchStore */
|
/** @var BranchStore */
|
||||||
protected $branchStore;
|
protected $branchStore;
|
||||||
|
|
||||||
|
/** @var ?bool */
|
||||||
|
protected $hasPreferredBranch = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return false|\Ramsey\Uuid\UuidInterface
|
* @return false|\Ramsey\Uuid\UuidInterface
|
||||||
*/
|
*/
|
||||||
@ -73,4 +76,18 @@ trait BranchHelper
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function hasPreferredBranch()
|
||||||
|
{
|
||||||
|
if ($this->hasPreferredBranch === null) {
|
||||||
|
$implementation = Branch::optionalHook();
|
||||||
|
if ($implementation instanceof PreferredBranchSupport) {
|
||||||
|
$this->hasPreferredBranch = $implementation->hasPreferredBranch($this->Auth());
|
||||||
|
} else {
|
||||||
|
$this->hasPreferredBranch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->hasPreferredBranch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ use Icinga\Exception\ProgrammingError;
|
|||||||
use Icinga\Module\Director\Data\Db\DbObjectTypeRegistry;
|
use Icinga\Module\Director\Data\Db\DbObjectTypeRegistry;
|
||||||
use Icinga\Module\Director\Db\Branch\Branch;
|
use Icinga\Module\Director\Db\Branch\Branch;
|
||||||
use Icinga\Module\Director\Db\Branch\BranchedObject;
|
use Icinga\Module\Director\Db\Branch\BranchedObject;
|
||||||
|
use Icinga\Module\Director\Db\Branch\BranchSupport;
|
||||||
use Icinga\Module\Director\Db\Branch\UuidLookup;
|
use Icinga\Module\Director\Db\Branch\UuidLookup;
|
||||||
use Icinga\Module\Director\Deployment\DeploymentInfo;
|
use Icinga\Module\Director\Deployment\DeploymentInfo;
|
||||||
use Icinga\Module\Director\DirectorObject\Automation\ExportInterface;
|
use Icinga\Module\Director\DirectorObject\Automation\ExportInterface;
|
||||||
@ -151,8 +152,11 @@ abstract class ObjectController extends ActionController
|
|||||||
$this->addObject();
|
$this->addObject();
|
||||||
}
|
}
|
||||||
$branch = $this->getBranch();
|
$branch = $this->getBranch();
|
||||||
if ($branch->isBranch() && ! $this->getRequest()->isApiRequest()) {
|
if (! $this->getRequest()->isApiRequest()) {
|
||||||
$this->content()->add(new BranchedObjectHint($branch, $this->Auth()));
|
$hasPreferred = $this->hasPreferredBranch();
|
||||||
|
if ($branch->isBranch() || $hasPreferred) {
|
||||||
|
$this->content()->add(new BranchedObjectHint($branch, $this->Auth(), null, $hasPreferred));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->handleRequest();
|
$form->handleRequest();
|
||||||
@ -558,8 +562,16 @@ abstract class ObjectController extends ActionController
|
|||||||
if (! $this->allowsObject($object)) {
|
if (! $this->allowsObject($object)) {
|
||||||
throw new NotFoundError('No such object available');
|
throw new NotFoundError('No such object available');
|
||||||
}
|
}
|
||||||
if ($showHint && $branch->isBranch() && $object->isObject() && ! $this->getRequest()->isApiRequest()) {
|
if ($showHint) {
|
||||||
$this->content()->add(new BranchedObjectHint($branch, $this->Auth(), $branchedObject));
|
$hasPreferredBranch = $this->hasPreferredBranch();
|
||||||
|
if (($hasPreferredBranch || $branch->isBranch())
|
||||||
|
&& $object->isObject()
|
||||||
|
&& ! $this->getRequest()->isApiRequest()
|
||||||
|
) {
|
||||||
|
$this->content()->add(
|
||||||
|
new BranchedObjectHint($branch, $this->Auth(), $branchedObject, $hasPreferredBranch)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
|
@ -124,7 +124,7 @@ abstract class ObjectsController extends ActionController
|
|||||||
->addTitle($this->translate(ucfirst($this->getPluralType())))
|
->addTitle($this->translate(ucfirst($this->getPluralType())))
|
||||||
->actions(new ObjectsActionBar($this->getBaseObjectUrl(), $this->url()));
|
->actions(new ObjectsActionBar($this->getBaseObjectUrl(), $this->url()));
|
||||||
|
|
||||||
$this->content()->add(new BranchedObjectsHint($this->getBranch(), $this->Auth()));
|
$this->content()->add(new BranchedObjectsHint($this->getBranch(), $this->Auth(), $this->hasPreferredBranch()));
|
||||||
|
|
||||||
if ($type === 'command' && $this->params->get('type') === 'external_object') {
|
if ($type === 'command' && $this->params->get('type') === 'external_object') {
|
||||||
$this->tabs()->activate('external');
|
$this->tabs()->activate('external');
|
||||||
|
@ -15,33 +15,45 @@ class BranchedObjectHint extends HtmlDocument
|
|||||||
{
|
{
|
||||||
use TranslationHelper;
|
use TranslationHelper;
|
||||||
|
|
||||||
public function __construct(Branch $branch, Auth $auth, BranchedObject $object = null)
|
public function __construct(Branch $branch, Auth $auth, BranchedObject $object = null, $hasPreferredBranch = false)
|
||||||
{
|
{
|
||||||
if (! $branch->isBranch()) {
|
if (! $branch->isBranch()) {
|
||||||
return;
|
if ($hasPreferredBranch) {
|
||||||
}
|
$main = true;
|
||||||
$hook = Branch::requireHook();
|
$hintMethod = 'warning';
|
||||||
|
$link = $this->translate('the main configuration branch');
|
||||||
$name = $branch->getName();
|
$deployHint = ' ' . $this->translate('This will be part of the next deployment');
|
||||||
if (substr($name, 0, 1) === '/') {
|
} else {
|
||||||
$label = $this->translate('this configuration branch');
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$label = $name;
|
$main = false;
|
||||||
|
$hintMethod = 'info';
|
||||||
|
$deployHint = ' ' . $this->translate('This will not be part of any deployment, unless being merged');
|
||||||
|
$hook = Branch::requireHook();
|
||||||
|
$name = $branch->getName();
|
||||||
|
if (substr($name, 0, 1) === '/') {
|
||||||
|
$label = $this->translate('this configuration branch');
|
||||||
|
} else {
|
||||||
|
$label = $name;
|
||||||
|
}
|
||||||
|
$link = $hook->linkToBranch($branch, $auth, $label);
|
||||||
}
|
}
|
||||||
$link = $hook->linkToBranch($branch, $auth, $label);
|
|
||||||
if ($object === null) {
|
if ($object === null) {
|
||||||
$this->add(Hint::info(Html::sprintf($this->translate(
|
$this->add(Hint::$hintMethod(Html::sprintf($this->translate(
|
||||||
'This object will be created in %s. It will not be part of any deployment'
|
'This object will be created in %s.'
|
||||||
. ' unless being merged'
|
) . $deployHint, $link)));
|
||||||
), $link)));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $object->hasBeenTouchedByBranch()) {
|
if (! $object->hasBeenTouchedByBranch()) {
|
||||||
$this->add(Hint::info(Html::sprintf($this->translate(
|
$this->add(Hint::$hintMethod(Html::sprintf($this->translate(
|
||||||
'Your changes will be stored in %s. The\'ll not be part of any deployment'
|
'Your changes are going to be stored in %s.'
|
||||||
. ' unless being merged'
|
) . $deployHint, $link)));
|
||||||
), $link)));
|
return;
|
||||||
|
}
|
||||||
|
if ($main) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,9 +13,14 @@ class BranchedObjectsHint extends HtmlDocument
|
|||||||
{
|
{
|
||||||
use TranslationHelper;
|
use TranslationHelper;
|
||||||
|
|
||||||
public function __construct(Branch $branch, Auth $auth)
|
public function __construct(Branch $branch, Auth $auth, $hasPreferredBranch = false)
|
||||||
{
|
{
|
||||||
if (! $branch->isBranch()) {
|
if (! $branch->isBranch()) {
|
||||||
|
if ($hasPreferredBranch) {
|
||||||
|
$this->add(Hint::warning($this->translate(
|
||||||
|
"You're currently in the master branch, your changes will make part of the next Deployment"
|
||||||
|
)));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$hook = Branch::requireHook();
|
$hook = Branch::requireHook();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user