mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-25 18:59:05 +02:00
Disable deployment link if there is an active deployment
This commit is contained in:
parent
6749b4fb08
commit
13dfe35d66
@ -6,6 +6,7 @@ use Icinga\Authentication\Auth;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Module\Director\Auth\Permission;
|
||||
use Icinga\Module\Director\Core\DeploymentApiInterface;
|
||||
use Icinga\Module\Director\Dashboard\Dashlet\DeploymentDashlet;
|
||||
use Icinga\Module\Director\Db;
|
||||
use Icinga\Module\Director\Deployment\DeploymentInfo;
|
||||
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
||||
@ -83,8 +84,9 @@ class DeploymentLinkForm extends DirectorForm
|
||||
);
|
||||
}
|
||||
|
||||
$this->setAttrib('class', 'gipfl-inline-form');
|
||||
$this->setAttrib('class', ['gipfl-inline-form', 'deployment-link-form']);
|
||||
$this->addHtml(Icon::create('wrench'));
|
||||
|
||||
try {
|
||||
// As this is shown for single objects, ignore errors caused by an
|
||||
// unreachable core
|
||||
@ -92,11 +94,21 @@ class DeploymentLinkForm extends DirectorForm
|
||||
} catch (\Exception $e) {
|
||||
$target = '_next';
|
||||
}
|
||||
$this->addSubmitButton($this->translate('Deploy'), [
|
||||
|
||||
$lastDeploymentPending = (new DeploymentDashlet($this->db))->lastDeploymentPending();
|
||||
$deployButtonAttributes = [
|
||||
'class' => 'link-button icon-wrench',
|
||||
'title' => $msg,
|
||||
'data-base-target' => $target,
|
||||
]);
|
||||
];
|
||||
if ($lastDeploymentPending) {
|
||||
$deployButtonAttributes['disabled'] = 'disabled';
|
||||
$deployButtonAttributes['title'] = $this->translate(
|
||||
'There is an active deployment, please wait until it is finished'
|
||||
);
|
||||
}
|
||||
|
||||
$this->addSubmitButton($this->translate('Deploy'), $deployButtonAttributes);
|
||||
}
|
||||
|
||||
protected function canDeploy()
|
||||
|
@ -7,6 +7,7 @@ use Icinga\Exception\IcingaException;
|
||||
use Icinga\Exception\InvalidPropertyException;
|
||||
use Icinga\Exception\NotFoundError;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Module\Director\Dashboard\Dashlet\DeploymentDashlet;
|
||||
use Icinga\Module\Director\Data\Db\DbObjectTypeRegistry;
|
||||
use Icinga\Module\Director\Db\Branch\Branch;
|
||||
use Icinga\Module\Director\Db\Branch\BranchedObject;
|
||||
@ -617,7 +618,11 @@ abstract class ObjectController extends ActionController
|
||||
$info,
|
||||
$this->Auth(),
|
||||
$this->api()
|
||||
)->handleRequest()
|
||||
)
|
||||
->callOnSuccess(function (DeploymentLinkForm $form) {
|
||||
$this->getResponse()->setHeader('X-Icinga-Extra-Updates', join(',', ['#col1']));
|
||||
})
|
||||
->handleRequest()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1527,6 +1527,16 @@ input[type=submit].icon-button {
|
||||
}
|
||||
}
|
||||
|
||||
form.deployment-link-form {
|
||||
input[type=submit] {
|
||||
&:disabled {
|
||||
background-color: unset;
|
||||
color: @disabled-gray;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
> .critical a { color: @text-color-inverted; background: @color-critical; }
|
||||
> .critical.handled a { color: @text-color-inverted; background: @color-critical-handled; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user