[icinga-checkins] icinga.org: icingaweb2-module-director/bugfix/service-set-contraints-13309 : CubeLinks: fit modified Cube API
git at icinga.org
git at icinga.org
Mon Nov 28 16:53:51 CET 2016
Module: icingaweb2-module-director
Branch: bugfix/service-set-contraints-13309
Commit: 42f98e9bbf4ea5246e06c1039ae250c66fb550ff
URL: https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=42f98e9bbf4ea5246e06c1039ae250c66fb550ff
Author: Thomas Gelf <thomas at gelf.net>
Date: Fri Nov 25 20:50:31 2016 +0100
CubeLinks: fit modified Cube API
---
library/Director/ProvidedHook/CubeLinks.php | 29 +++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/library/Director/ProvidedHook/CubeLinks.php b/library/Director/ProvidedHook/CubeLinks.php
index 4cbdd9f..015fba8 100644
--- a/library/Director/ProvidedHook/CubeLinks.php
+++ b/library/Director/ProvidedHook/CubeLinks.php
@@ -10,11 +10,12 @@ use Icinga\Web\View;
class CubeLinks extends ActionLinksHook
{
- public function getHtml(View $view, Cube $cube)
+ public function prepareActionLinks(Cube $cube, View $view)
{
if (! $cube instanceof IdoHostStatusCube) {
- return '';
+ return;
}
+
$cube->finalizeInnerQuery();
$query = $cube->innerQuery()
->reset('columns')
@@ -23,9 +24,16 @@ class CubeLinks extends ActionLinksHook
$hosts = $cube->db()->fetchCol($query);
- if (count($hosts) === 1) {
+ $count = count($hosts);
+ if ($count === 1) {
$url = 'director/host/edit';
$params = array('name' => $hosts[0]);
+
+ $title = $view->translate('Modify a host');
+ $description = sprintf(
+ $view->translate('This allows you to modify properties for "%s"'),
+ $hosts[0]
+ );
} else {
$params = null;
@@ -37,13 +45,18 @@ class CubeLinks extends ActionLinksHook
}
$url = 'director/hosts/edit?' . $filter->toQueryString();
+
+ $title = sprintf($view->translate('Modify %d hosts'), $count);
+ $description = $view->translate(
+ 'This allows you to modify properties for all chosen hosts at once'
+ );
}
- return $view->qlink(
- $view->translate('Modify hosts'),
- $url,
- $params,
- array('class' => 'icon-wrench')
+ $this->addActionLink(
+ $this->makeUrl($url, $params),
+ $title,
+ $description,
+ 'wrench'
);
}
}
More information about the icinga-checkins
mailing list