Adjust disabled input style sheets & remove unnecessary control structure within the WelcomeForm::onSuccess() method

This commit is contained in:
Yonas Habteab 2022-06-07 14:30:15 +02:00
parent af062b8cb2
commit 0c91a8a283
2 changed files with 23 additions and 23 deletions

View File

@ -28,7 +28,7 @@ class WelcomeForm extends Form
public function hasBeenSubmitted()
{
return parent::hasBeenSubmitted() || $this->getPressedSubmitElement();
return parent::hasBeenSent() && $this->getPopulatedValue('btn_use_defaults');
}
protected function assemble()
@ -53,28 +53,26 @@ class WelcomeForm extends Form
protected function onSuccess()
{
if ($this->getPopulatedValue('btn_use_defaults')) {
$home = $this->dashboard->getEntry(DashboardHome::DEFAULT_HOME);
$conn = DBUtils::getConn();
$conn->beginTransaction();
$home = $this->dashboard->getEntry(DashboardHome::DEFAULT_HOME);
$conn = DBUtils::getConn();
$conn->beginTransaction();
try {
// Default Home might have been disabled, so we have to update it first
$this->dashboard->manageEntry($home);
$home->manageEntry(Modules\DashletManager::getSystemDefaults(), null, true);
try {
// Default Home might have been disabled, so we have to update it first
$this->dashboard->manageEntry($home);
$home->manageEntry(Modules\DashletManager::getSystemDefaults(), null, true);
$conn->commitTransaction();
} catch (\Exception $err) {
$conn->rollBackTransaction();
$conn->commitTransaction();
} catch (\Exception $err) {
$conn->rollBackTransaction();
Logger::error('Unable to apply the system defaults into the DB. An error occurred: %s', $err);
Logger::error('Unable to apply the system defaults into the DB. An error occurred: %s', $err);
Notification::error(t('Failed to successfully save the data. Please check the logs for details.'));
Notification::error(t('Failed to successfully save the data. Please check the logs for details.'));
return;
}
Notification::success(t('Imported system defaults successfully.'));
return;
}
Notification::success(t('Imported system defaults successfully.'));
}
}

View File

@ -1,3 +1,5 @@
/*! Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
// Welcome view and introduction
.welcome-view {
@ -35,14 +37,14 @@
}
}
input[disabled] {
input[name="btn_use_defaults"]:disabled {
cursor: default;
border: 1px solid @control-disabled-color;
}
input[disabled], input[disabled]:hover {
background: @body-bg-color;
color: @control-disabled-color;
&, &:hover {
background: @body-bg-color;
color: @control-disabled-color;
}
}
}