ObjectController: show info, no form for externals

This commit is contained in:
Thomas Gelf 2016-03-18 14:58:46 +01:00
parent 4417d58349
commit 7ca46b1ab5
3 changed files with 53 additions and 10 deletions

View File

@ -22,11 +22,7 @@ class IcingaCommandTable extends IcingaObjectTable
protected function getActionUrl($row)
{
if ($row->object_type === 'external_object') {
return $this->url('director/command/render', array('name' => $row->command));
} else {
return $this->url('director/command', array('name' => $row->command));
}
return $this->url('director/command', array('name' => $row->command));
}
public function getTitles()

View File

@ -0,0 +1,17 @@
<div class="controls">
<?= $this->tabs ?>
<h1><?= $this->escape($this->title) ?></h1>
<span>
<?= $this->actionLinks ?>
</span>
</div>
<div class="content">
<p><?= $this->translate(
'This is an external object. It has been imported from Icinga 2 throught the'
. ' Core API and cannot be managed with the Icinga Director. It is however'
. ' perfectly valid to create objects using this or referring to this object.'
. ' You might also want to define related Fields to make work based on this'
. ' object more enjoyable'
) ?></p>
</div>

View File

@ -25,11 +25,19 @@ abstract class ObjectController extends ActionController
$this->beforeTabs();
$params = $object->getUrlParams();
$tabs = $this->getTabs()->add('modify', array(
'url' => sprintf('director/%s', $type),
'urlParams' => $params,
'label' => $this->translate(ucfirst($type))
));
if ($object->isExternal()) {
$tabs = $this->getTabs()->add('modify', array(
'url' => sprintf('director/%s', $type),
'urlParams' => $params,
'label' => $this->translate(ucfirst($type))
));
} else {
$tabs = $this->getTabs()->add('modify', array(
'url' => sprintf('director/%s', $type),
'urlParams' => $params,
'label' => $this->translate(ucfirst($type))
));
}
$tabs->add('render', array(
'url' => sprintf('director/%s/render', $type),
@ -75,6 +83,17 @@ abstract class ObjectController extends ActionController
}
}
$allowedExternals = array(
'apiuser',
'endpoint'
);
if ($this->object
&& $this->object->isExternal()
&& ! in_array($this->object->getShortTableName(), $allowedExternals)
) {
return $this->externalObjectInfo();
}
return $this->editAction();
}
@ -257,6 +276,17 @@ abstract class ObjectController extends ActionController
);
}
protected function externalObjectInfo()
{
$this->view->title = sprintf(
$this->translate('External object: %s'),
$this->object->object_name
);
$this->getTabs()->activate('modify');
$this->render('object/externalinfo', null, true);
}
protected function loadObject()
{
if ($this->object === null) {