CubeLinks: fit modified Cube API

This commit is contained in:
Thomas Gelf 2016-11-25 20:50:31 +01:00
parent ac3e541317
commit 42f98e9bbf
1 changed files with 21 additions and 8 deletions

View File

@ -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'
);
}
}