mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-05-28 04:34:08 -04:00
Provide links to jump to an imported node's source configuration
refs #209
This commit is contained in:
parent
cc80be0f0e
commit
885064b577
3 changed files with 51 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ namespace Icinga\Module\Businessprocess\Renderer;
|
|||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Module\Businessprocess\BpNode;
|
||||
use Icinga\Module\Businessprocess\BpConfig;
|
||||
use Icinga\Module\Businessprocess\ImportedNode;
|
||||
use Icinga\Module\Businessprocess\Node;
|
||||
use Icinga\Module\Businessprocess\Web\Url;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
|
|
@ -196,6 +197,36 @@ abstract class Renderer extends HtmlDocument
|
|||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the url to the given node's source configuration
|
||||
*
|
||||
* @param BpNode $node
|
||||
*
|
||||
* @return Url
|
||||
*/
|
||||
public function getSourceUrl(BpNode $node)
|
||||
{
|
||||
if ($node instanceof ImportedNode) {
|
||||
$name = $node->getNodeName();
|
||||
$paths = $node->getBpConfig()->getBpNode($name)->getPaths();
|
||||
} else {
|
||||
$name = $node->getName();
|
||||
$paths = $node->getPaths();
|
||||
}
|
||||
|
||||
$url = $this->getUrl()->setParams([
|
||||
'config' => $node->getBpConfig()->getName(),
|
||||
'node' => $name
|
||||
]);
|
||||
// This depends on the fact that the node's root path is the last element in $paths
|
||||
$url->getParams()->addValues('path', array_slice(array_pop($paths), 0, -1));
|
||||
if (! $this->isLocked()) {
|
||||
$url->getParams()->add('unlocked', true);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node $node
|
||||
* @param $path
|
||||
|
|
|
|||
|
|
@ -197,6 +197,20 @@ class NodeTile extends BaseHtmlElement
|
|||
],
|
||||
Html::tag('i', ['class' => 'icon icon-sitemap'])
|
||||
));
|
||||
if ($node->getBpConfig()->getName() !== $this->renderer->getBusinessProcess()->getName()) {
|
||||
$this->actions()->add(Html::tag(
|
||||
'a',
|
||||
[
|
||||
'data-base-target' => '_next',
|
||||
'href' => $this->renderer->getSourceUrl($node)->getAbsoluteUrl(),
|
||||
'title' => mt(
|
||||
'businessprocess',
|
||||
'Show this process as part of its original configuration'
|
||||
)
|
||||
],
|
||||
Html::tag('i', ['class' => 'icon icon-forward'])
|
||||
));
|
||||
}
|
||||
|
||||
$url = $node->getInfoUrl();
|
||||
|
||||
|
|
|
|||
|
|
@ -180,6 +180,12 @@ class TreeRenderer extends Renderer
|
|||
$differentConfig = $node->getBpConfig()->getName() !== $this->getBusinessProcess()->getName();
|
||||
if (! $this->isLocked() && !$differentConfig) {
|
||||
$div->add($this->getActionIcons($bp, $node));
|
||||
} elseif ($differentConfig) {
|
||||
$div->add($this->actionIcon(
|
||||
'forward',
|
||||
$this->getSourceUrl($node)->addParams(['mode' => 'tree'])->getAbsoluteUrl(),
|
||||
mt('businessprocess', 'Show this process as part of its original configuration')
|
||||
)->addAttributes(['data-base-target' => '_next']));
|
||||
}
|
||||
|
||||
$ul = Html::tag('ul', [
|
||||
|
|
|
|||
Loading…
Reference in a new issue