css, various places: use Hint class

This commit is contained in:
Thomas Gelf 2020-10-26 18:50:13 +01:00
parent 24a5411a93
commit 456832e7d1
20 changed files with 74 additions and 182 deletions

View File

@ -5,6 +5,7 @@ namespace Icinga\Module\Director\Controllers;
use gipfl\IcingaWeb2\Link;
use gipfl\IcingaWeb2\Widget\NameValueTable;
use Exception;
use gipfl\Web\Widget\Hint;
use Icinga\Date\DateFormatter;
use Icinga\Module\Director\ConfigDiff;
use Icinga\Module\Director\Core\Json;
@ -57,9 +58,7 @@ class BasketController extends ActionController
$this->basketTabs()->activate('show');
$this->addTitle($basket->get('basket_name'));
if ($basket->isEmpty()) {
$this->content()->add(Html::tag('p', [
'class' => 'information'
], $this->translate('This basket is empty')));
$this->content()->add(Hint::info($this->translate('This basket is empty')));
}
$this->content()->add(
(new BasketForm())->setObject($basket)->handleRequest()
@ -330,9 +329,7 @@ class BasketController extends ActionController
$key = $this->params->get('key');
$this->addTitle($this->translate('Single Object Diff'));
$this->content()->add(Html::tag('p', [
'class' => 'information'
], Html::sprintf(
$this->content()->add(Hint::info(Html::sprintf(
$this->translate('Comparing %s "%s" from Snapshot "%s" to current config'),
$type,
$key,

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Controllers;
use gipfl\Web\Widget\Hint;
use ipl\Html\Html;
use Icinga\Module\Director\Forms\IcingaCommandArgumentForm;
use Icinga\Module\Director\Objects\IcingaCommand;
@ -64,19 +65,14 @@ class CommandController extends ObjectController
$command = $this->object;
if ($command->isInUse()) {
$usage = new CommandUsage($command);
$this->content()->add(Html::tag('p', [
'class' => 'information',
'data-base-target' => '_next'
], Html::sprintf(
$this->content()->add(Hint::info(Html::sprintf(
$this->translate('This Command is currently being used by %s'),
Html::tag('span', null, $usage->getLinks())->setSeparator(', ')
)));
))->addAttributes([
'data-base-target' => '_next'
]));
} else {
$this->content()->add(Html::tag(
'p',
['class' => 'warning'],
$this->translate('This Command is currently not in use')
));
$this->content()->add(Hint::warning($this->translate('This Command is currently not in use')));
}
}

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Controllers;
use gipfl\Web\Widget\Hint;
use Icinga\Data\Filter\Filter;
use Icinga\Exception\IcingaException;
use Icinga\Exception\NotFoundError;
@ -56,9 +57,7 @@ class ConfigController extends ActionController
$this->setAutorefreshInterval(20);
}
} catch (Exception $e) {
$this->content()->prepend(
Html::tag('p', ['class' => 'warning'], $e->getMessage())
);
$this->content()->prepend(Hint::warning($e->getMessage()));
// No problem, Icinga might be reloading
}

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Controllers;
use gipfl\Web\Widget\Hint;
use ipl\Html\Html;
use gipfl\IcingaWeb2\Link;
use gipfl\IcingaWeb2\Url;
@ -116,12 +117,10 @@ class HostController extends ObjectController
*/
public function invalidserviceAction()
{
$this->content()->add(
Html::tag('p', ['class' => 'error'], sprintf(
$this->translate('No such service: %s'),
$this->params->get('service')
))
);
$this->content()->add(Hint::error(sprintf(
$this->translate('No such service: %s'),
$this->params->get('service')
)));
$this->servicesAction();
}

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Controllers;
use Exception;
use gipfl\Web\Widget\Hint;
use Icinga\Module\Director\Db\Migrations;
use Icinga\Module\Director\Forms\ApplyMigrationsForm;
use Icinga\Module\Director\Forms\KickstartForm;
@ -30,7 +31,7 @@ class IndexController extends DashboardController
->handleRequest()
);
} elseif ($migrations->hasBeenDowngraded()) {
$this->content()->add(Html::tag('p', ['class' => 'state-hint warning'], sprintf($this->translate(
$this->content()->add(Hint::warning(sprintf($this->translate(
'Your DB schema (migration #%d) is newer than your code base.'
. ' Downgrading Icinga Director is not supported and might'
. ' lead to unexpected problems.'

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Controllers;
use gipfl\Web\Widget\Hint;
use Icinga\Module\Director\Web\Widget\UnorderedList;
use Icinga\Module\Director\ConfigDiff;
use Icinga\Module\Director\Db\Cache\PrefetchCache;
@ -58,7 +59,7 @@ class SyncruleController extends ActionController
}
$this->addMainActions();
if (! $run) {
$this->warning($this->translate('This Sync Rule has never been run before.'));
$c->add(Hint::warning($this->translate('This Sync Rule has never been run before.')));
}
switch ($rule->get('sync_state')) {
@ -80,19 +81,19 @@ class SyncruleController extends ActionController
*/
break;
case 'pending-changes':
$this->warning($this->translate(
$c->add(Hint::warning($this->translate(
'There are pending changes for this Sync Rule. You should trigger a new'
. ' Sync Run.'
));
)));
break;
case 'failing':
$this->error(sprintf(
$c->add(Hint::error(sprintf(
$this->translate(
'This Sync Rule failed when last checked at %s: %s'
),
$rule->get('last_attempt'),
$rule->get('last_error_message')
));
)));
break;
}
@ -116,30 +117,14 @@ class SyncruleController extends ActionController
*/
protected function addPropertyHint(SyncRule $rule)
{
$this->warning(Html::sprintf(
$this->content()->add(Hint::warning(Html::sprintf(
$this->translate('You must define some %s before you can run this Sync Rule'),
new Link(
$this->translate('Sync Properties'),
'director/syncrule/property',
['rule_id' => $rule->get('id')]
)
));
}
/**
* @param $msg
*/
protected function warning($msg)
{
$this->content()->add(Html::tag('p', ['class' => 'state-hint warning'], $msg));
}
/**
* @param $msg
*/
protected function error($msg)
{
$this->content()->add(Html::tag('p', ['class' => 'state-hint error'], $msg));
)));
}
/**
@ -164,19 +149,15 @@ class SyncruleController extends ActionController
try {
$modifications = $sync->getExpectedModifications();
} catch (\Exception $e) {
$this->content()->add(
Html::tag('p', [
'class' => 'state-hint error'
], $e->getMessage())
);
$this->content()->add(Hint::error($e->getMessage()));
return;
}
if (empty($modifications)) {
$this->content()->add(Html::tag('p', [
'class' => 'state-hint ok'
], $this->translate('This Sync Rule is in sync and would currently not apply any changes')));
$this->content()->add(Hint::ok($this->translate(
'This Sync Rule is in sync and would currently not apply any changes'
)));
return;
}

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Forms;
use gipfl\Web\Widget\Hint;
use ipl\Html\Html;
use ipl\Html\HtmlDocument;
use gipfl\IcingaWeb2\Link;
@ -112,9 +113,7 @@ class AddToBasketForm extends DirectorForm
), $basketName));
return parent::onSuccess();
} else {
$this->addHtmlHint(Html::tag('p', [
'class' => 'error'
], Html::sprintf($this->translate(
$this->addHtmlHint(Hint::error(Html::sprintf($this->translate(
'Please check your Basket configuration, %s does not support'
. ' single "%s" configuration objects'
), Link::create(

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Forms;
use gipfl\Web\Widget\Hint;
use Icinga\Module\Director\Core\CoreApi;
use ipl\Html\Html;
@ -89,7 +90,7 @@ trait DeployFormsBug7530
$this->db->settings()->set('ignore_bug7530', 'y');
}
if ($this->shouldWarnAboutBug7530()) {
$this->addHtml(Html::tag('p', ['class' => 'state-hint warning'], Html::sprintf($this->translate(
$this->addHtml(Hint::warning(Html::sprintf($this->translate(
"Warning: you're running Icinga v2.11.0 and our configuration looks"
. " like you could face issue %s. We're already working on a solution."
. " The GitHub Issue and our %s contain related details."

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Forms;
use gipfl\Web\Widget\Hint;
use Icinga\Data\Filter\Filter;
use Icinga\Exception\IcingaException;
use Icinga\Exception\ProgrammingError;
@ -129,11 +130,7 @@ class IcingaServiceForm extends DirectorObjectForm
if ($this->hasBeenBlacklisted()) {
$this->addHtml(
Html::tag(
'p',
['class' => 'warning'],
$this->translate('This Service has been deactivated on this host')
),
Hint::warning($this->translate('This Service has been deactivated on this host')),
['name' => 'HINT_blacklisted']
);
$group = null;

View File

@ -9,7 +9,7 @@ use Icinga\Application\Modules\Manager;
</div>
<div class="content">
<p class="state-hint error"><?= $this->escape($this->message) ?></p>
<p class="legacy-error"><?= $this->escape($this->message) ?></p>
<table class="common-table table-row-selectable">
<thead>
<tr>

View File

@ -4,5 +4,5 @@
</div>
<div class="content">
<p class="state-hint error"><?= $this->escape($this->message) ?></p>
<p class="legacy-error"><?= $this->escape($this->message) ?></p>
</div>

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Import;
use gipfl\Web\Widget\Hint;
use Icinga\Data\Db\DbConnection;
use Icinga\Module\Director\Forms\ImportSourceForm;
use Icinga\Module\Director\Hook\ImportSourceHook;
@ -50,13 +51,9 @@ class ImportSourceSql extends ImportSourceHook
if ($columns = $current->getSetting('column_cache')) {
$form->addHtmlHint('Columns: ' . $columns);
} else {
$form->addHtmlHint(Html::tag(
'p',
['class' => 'warning'],
$form->translate(
'Please click "Store" once again to determine query columns'
)
));
$form->addHtmlHint(Hint::warning($form->translate(
'Please click "Store" once again to determine query columns'
)));
}
}
return $form;

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Controller;
use gipfl\Web\Widget\Hint;
use ipl\Html\Html;
use Icinga\Exception\IcingaException;
use Icinga\Exception\InvalidPropertyException;
@ -194,7 +195,7 @@ abstract class ObjectController extends ActionController
try {
$this->addFieldsFormAndTable($object, $type);
} catch (NestingError $e) {
$this->content()->add(Html::tag('p', ['class' => 'error'], $e->getMessage()));
$this->content()->add(Hint::error($e->getMessage()));
}
}

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Controller;
use gipfl\Web\Widget\Hint;
use Icinga\Module\Director\DirectorObject\Automation\ExportInterface;
use Icinga\Module\Director\Exception\NestingError;
use Icinga\Module\Director\Objects\IcingaCommand;
@ -190,7 +191,7 @@ abstract class TemplateController extends CompatController
TemplateUsageTable::forTemplate($template)
);
} catch (NestingError $e) {
$this->content()->add(Html::tag('p', ['class' => 'error'], $e->getMessage()));
$this->content()->add(Hint::error($e->getMessage()));
}
}

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web;
use gipfl\Web\Widget\Hint;
use ipl\Html\Text;
use Icinga\Module\Director\Exception\NestingError;
use Icinga\Module\Director\Objects\IcingaObject;
@ -70,9 +71,7 @@ class ObjectPreview
$content = $cc->content();
if ($object->isDisabled()) {
$content->add(Html::tag(
'p',
['class' => 'error'],
$content->add(Hint::error(
$this->translate('This object will not be deployed as it has been disabled')
));
}

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Web;
use Exception;
use gipfl\Web\Widget\Hint;
use Icinga\Exception\ProgrammingError;
use Icinga\Module\Director\Core\CoreApi;
use Icinga\Module\Director\Forms\IcingaForgetApiKeyForm;
@ -64,7 +65,7 @@ class SelfService
. ' secret key, you might want to dismiss the current key. This'
. ' would allow you to register the same host again.'
)),
Html::tag('p', ['class' => 'warning'], $this->translate(
Hint::warning($this->translate(
'It is not a good idea to do so as long as your Agent still has'
. ' a valid Self Service API key!'
)),
@ -119,7 +120,7 @@ class SelfService
$wizard->renderTokenBasedWindowsInstaller($key)
),
Html::tag('h2', null, $this->translate('Generate a new key')),
Html::tag('p', ['class' => 'warning'], $this->translate(
Hint::warning($this->translate(
'This will invalidate the former key'
)),
]);
@ -206,7 +207,7 @@ class SelfService
$wizard = new AgentWizard($host);
$wizard->setTicketSalt($this->api->getTicketSalt());
} catch (Exception $e) {
$c->add(Html::tag('p', ['class' => 'error'], sprintf(
$c->add(Hint::error(sprintf(
$this->translate(
'A ticket for this agent could not have been requested from'
. ' your deployment endpoint: %s'

View File

@ -5,6 +5,7 @@ namespace Icinga\Module\Director\Web\Widget;
use gipfl\IcingaWeb2\Icon;
use gipfl\IcingaWeb2\Widget\NameValueTable;
use gipfl\Translation\TranslationHelper;
use gipfl\Web\Widget\Hint;
use Icinga\Date\DateFormatter;
use Icinga\Module\Director\Daemon\RunningDaemonInfo;
use Icinga\Util\Format;
@ -34,9 +35,7 @@ class BackgroundDaemonDetails extends BaseHtmlElement
{
$info = $this->info;
if ($info->hasBeenStopped()) {
$this->add(Html::tag('p', [
'class' => 'state-hint error'
], Html::sprintf(
$this->add(Hint::error(Html::sprintf(
$this->translate(
'Daemon has been stopped %s, was running with PID %s as %s@%s'
),
@ -47,9 +46,7 @@ class BackgroundDaemonDetails extends BaseHtmlElement
Html::tag('strong', $info->getFqdn())
)));
} elseif ($info->isOutdated()) {
$this->add(Html::tag('p', [
'class' => 'state-hint error'
], Html::sprintf(
$this->add(Hint::error(Html::sprintf(
$this->translate(
'Daemon keep-alive is outdated, was last seen running with PID %s as %s@%s %s'
),
@ -83,9 +80,7 @@ class BackgroundDaemonDetails extends BaseHtmlElement
),
]);
$this->add($details);
$this->add(Html::tag('p', [
'class' => 'state-hint ok'
], Html::sprintf(
$this->add(Hint::ok(Html::sprintf(
$this->translate(
'Daemon is running with PID %s as %s@%s, last refresh happened %s'
),

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Widget;
use gipfl\Web\Widget\Hint;
use ipl\Html\HtmlDocument;
use Icinga\Module\Director\Forms\ImportCheckForm;
use Icinga\Module\Director\Forms\ImportRunForm;
@ -30,17 +31,13 @@ class ImportSourceDetails extends HtmlDocument
switch ($source->get('import_state')) {
case 'unknown':
$this->add(Html::tag(
'p',
['class' => 'state-hint warning'],
$this->translate(
"It's currently unknown whether we are in sync with this Import Source."
. ' You should either check for changes or trigger a new Import Run.'
)
));
$this->add(Hint::warning($this->translate(
"It's currently unknown whether we are in sync with this Import Source."
. ' You should either check for changes or trigger a new Import Run.'
)));
break;
case 'in-sync':
$this->add(Html::tag('p', ['class' => 'state-hint ok'], sprintf(
$this->add(Hint::ok(sprintf(
$this->translate(
'This Import Source was last found to be in sync at %s.'
),
@ -51,13 +48,13 @@ class ImportSourceDetails extends HtmlDocument
// - there have been activities since then
break;
case 'pending-changes':
$this->add(Html::tag('p', ['class' => 'state-hint warning'], $this->translate(
$this->add(Hint::warning($this->translate(
'There are pending changes for this Import Source. You should trigger a new'
. ' Import Run.'
)));
break;
case 'failing':
$this->add(Html::tag('p', ['class' => 'state-hint error'], sprintf(
$this->add(Hint::error(sprintf(
$this->translate(
'This Import Source failed when last checked at %s: %s'
),
@ -66,7 +63,7 @@ class ImportSourceDetails extends HtmlDocument
)));
break;
default:
$this->add(Html::tag('p', ['class' => 'state-hint error'], sprintf(
$this->add(Hint::error(sprintf(
$this->translate('This Import Source has an invalid state: %s'),
$source->get('import_state')
)));

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Widget;
use gipfl\Web\Widget\Hint;
use Icinga\Date\DateFormatter;
use ipl\Html\HtmlDocument;
use Icinga\Module\Director\Objects\DirectorJob;
@ -21,7 +22,7 @@ class JobDetails extends HtmlDocument
{
$runInterval = $job->get('run_interval');
if ($job->hasBeenDisabled()) {
$this->add(Html::tag('p', ['class' => 'state-hint error'], sprintf(
$this->add(Hint::error(sprintf(
$this->translate(
'This job would run every %ds. It has been disabled and will'
. ' therefore not be executed as scheduled'
@ -50,21 +51,19 @@ class JobDetails extends HtmlDocument
], DateFormatter::timeAgo($ts));
if ($tsLastAttempt) {
if ($job->get('last_attempt_succeeded') === 'y') {
$this->add(Html::tag('p', ['class' => 'state-hint ok'], Html::sprintf(
$this->add(Hint::ok(Html::sprintf(
$this->translate('The last attempt succeeded %s'),
$timeAgo
)));
} else {
$this->add(Html::tag('p', ['class' => 'state-hint error'], Html::sprintf(
$this->add(Hint::error(Html::sprintf(
$this->translate('The last attempt failed %s: %s'),
$timeAgo,
$job->get('last_error_message')
)));
}
} else {
$this->add(Html::tag('p', [
'class' => 'state-hint warning'
], $this->translate('This job has not been executed yet')));
$this->add(Hint::warning($this->translate('This job has not been executed yet')));
}
}
}

View File

@ -1105,79 +1105,11 @@ span.error {
}
}
p.error:not(.state-hint) {
color: white;
padding: 1em 2em;
background-color: @colorCritical;
font-weight: bold;
p.legacy-error {
color: white;
padding: 1em 2em;
background-color: @colorCritical;
a {
color: inherit;
text-decoration: underline;
}
}
p.warning:not(.state-hint) {
color: white;
padding: 1em 2em;
background-color: @colorWarning;
font-weight: bold;
a {
color: inherit;
text-decoration: underline;
}
}
p.information:not(.state-hint) {
color: white;
padding: 1em 2em;
background-color: @colorOk;
font-weight: bold;
a {
color: inherit;
text-decoration: underline;
}
}
p.state-hint {
border: 1px solid @text-color;
padding: 0.5em;
line-height: 2em;
max-width: 60em;
border-left-width: 3em;
&:before {
position: relative;
margin-left: -1.5em;
margin-right: 0.5em;
height: 100%;
vertical-align: middle;
font-family: 'ifont';
color: white;
font-size: 2em;
}
&.ok {
border-color: @color-ok;
}
&.warning {
border-color: @color-warning;
}
&.error {
border-color: @color-critical;
}
&.critical:before, &.error:before {
content: '\e885';
}
&.warning:before {
content: '\e885';
}
&.ok:before {
content: '\e803';
}
a {
text-decoration: underline;
}
}
table th.actions, table td.actions {