mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-06-08 16:22:04 -04:00
Streamline usage of a node's name
This commit is contained in:
parent
8465bc0bc3
commit
431a5e0085
9 changed files with 21 additions and 23 deletions
|
|
@ -425,7 +425,7 @@ class AddNodeForm extends QuickForm
|
|||
$name = '@' . $file . ':' . $name;
|
||||
}
|
||||
|
||||
$list[$name] = (string) $node; // display name?
|
||||
$list[$name] = $node->getName(); // display name?
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ class EditNodeForm extends QuickForm
|
|||
|
||||
foreach ($this->bp->getNodes() as $node) {
|
||||
if ($node instanceof BpNode && ! isset($parents[$node->getName()])) {
|
||||
$list[(string) $node] = (string) $node; // display name?
|
||||
$list[$node->getName()] = $node->getName(); // display name?
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class BpNode extends Node
|
|||
$tree = array();
|
||||
|
||||
foreach ($this->getProblematicChildren() as $child) {
|
||||
$name = (string) $child;
|
||||
$name = $child->getName();
|
||||
$tree[$name] = array(
|
||||
'node' => $child,
|
||||
'children' => array()
|
||||
|
|
@ -197,11 +197,11 @@ class BpNode extends Node
|
|||
|
||||
foreach ($this->getChildren() as $child) {
|
||||
if ($child->isMissing()) {
|
||||
$missing[(string) $child] = $child;
|
||||
$missing[$child->getName()] = $child;
|
||||
}
|
||||
|
||||
foreach ($child->getMissingChildren() as $m) {
|
||||
$missing[(string) $m] = $m;
|
||||
$missing[$m->getName()] = $m;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ class BpNode extends Node
|
|||
|
||||
public function getHtmlId()
|
||||
{
|
||||
return 'businessprocess-' . preg_replace('/[\r\n\t\s]/', '_', (string) $this);
|
||||
return 'businessprocess-' . preg_replace('/[\r\n\t\s]/', '_', $this->getName());
|
||||
}
|
||||
|
||||
protected function invertSortingState($state)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class NodeCreateAction extends NodeAction
|
|||
*/
|
||||
public function setParent(Node $name)
|
||||
{
|
||||
$this->parentName = (string) $name;
|
||||
$this->parentName = $name->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class Breadcrumb extends BaseHtmlElement
|
|||
// TODO: something more generic than NodeTile?
|
||||
$renderer = clone($renderer);
|
||||
$renderer->lock()->setIsBreadcrumb();
|
||||
$p = new NodeTile($renderer, (string) $node, $node, $path);
|
||||
$p = new NodeTile($renderer, $node, $path);
|
||||
$p->setTag('li');
|
||||
return $p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,14 +35,13 @@ class TileRenderer extends Renderer
|
|||
|
||||
$path = $this->getCurrentPath();
|
||||
foreach ($nodes as $name => $node) {
|
||||
$this->add(new NodeTile($this, $name, $node, $path));
|
||||
$this->add(new NodeTile($this, $node, $path));
|
||||
}
|
||||
|
||||
if ($this->wantsRootNodes()) {
|
||||
$unbound = $this->createUnboundParent($bp);
|
||||
if ($unbound->hasChildren()) {
|
||||
$name = $unbound->getName();
|
||||
$this->add(new NodeTile($this, $name, $unbound));
|
||||
$this->add(new NodeTile($this, $unbound));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,10 +36,9 @@ class NodeTile extends BaseHtmlElement
|
|||
* @param Node $node
|
||||
* @param null $path
|
||||
*/
|
||||
public function __construct(Renderer $renderer, $name, Node $node, $path = null)
|
||||
public function __construct(Renderer $renderer, Node $node, $path = null)
|
||||
{
|
||||
$this->renderer = $renderer;
|
||||
$this->name = $name;
|
||||
$this->node = $node;
|
||||
$this->path = $path;
|
||||
}
|
||||
|
|
@ -72,9 +71,9 @@ class NodeTile extends BaseHtmlElement
|
|||
|
||||
$attributes = $this->getAttributes();
|
||||
$attributes->add('class', $renderer->getNodeClasses($node));
|
||||
$attributes->add('id', 'bp-' . (string) $node);
|
||||
$attributes->add('id', 'bp-' . $node->getName());
|
||||
if (! $renderer->isLocked()) {
|
||||
$attributes->add('data-node-name', (string) $node);
|
||||
$attributes->add('data-node-name', $node->getName());
|
||||
}
|
||||
|
||||
if (! $renderer->isBreadcrumb()) {
|
||||
|
|
@ -260,7 +259,7 @@ class NodeTile extends BaseHtmlElement
|
|||
[
|
||||
'href' => $renderer->getUrl()
|
||||
->with('action', 'simulation')
|
||||
->with('simulationnode', $this->name),
|
||||
->with('simulationnode', $this->node->getName()),
|
||||
'title' => mt(
|
||||
'businessprocess',
|
||||
'Show the business impact of this node by simulating a specific state'
|
||||
|
|
@ -274,7 +273,7 @@ class NodeTile extends BaseHtmlElement
|
|||
[
|
||||
'href' => $renderer->getUrl()
|
||||
->with('action', 'editmonitored')
|
||||
->with('editmonitorednode', $node->getName()),
|
||||
->with('editmonitorednode', $this->node->getName()),
|
||||
'title' => mt('businessprocess', 'Modify this monitored node')
|
||||
],
|
||||
Html::tag('i', ['class' => 'icon icon-edit'])
|
||||
|
|
@ -282,7 +281,7 @@ class NodeTile extends BaseHtmlElement
|
|||
}
|
||||
|
||||
if (! $this->renderer->getBusinessProcess()->getMetadata()->canModify()
|
||||
|| $node->getName() === '__unbound__'
|
||||
|| $this->node->getName() === '__unbound__'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -293,7 +292,7 @@ class NodeTile extends BaseHtmlElement
|
|||
[
|
||||
'href' => $renderer->getUrl()
|
||||
->with('action', 'edit')
|
||||
->with('editnode', $node->getName()),
|
||||
->with('editnode', $this->node->getName()),
|
||||
'title' => mt('businessprocess', 'Modify this business process node')
|
||||
],
|
||||
Html::tag('i', ['class' => 'icon icon-edit'])
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class TreeRenderer extends Renderer
|
|||
*/
|
||||
protected function getId(Node $node, $path)
|
||||
{
|
||||
return md5(implode(';', $path) . (string) $node);
|
||||
return md5(implode(';', $path) . $node->getName());
|
||||
}
|
||||
|
||||
protected function getStateClassNames(Node $node)
|
||||
|
|
@ -192,7 +192,7 @@ class TreeRenderer extends Renderer
|
|||
'config' => $node->getBpConfig()->getName(),
|
||||
'node' => $node instanceof ImportedNode
|
||||
? $node->getNodeName()
|
||||
: (string) $node
|
||||
: $node->getName()
|
||||
])
|
||||
->getAbsoluteUrl()
|
||||
]);
|
||||
|
|
@ -215,7 +215,7 @@ class TreeRenderer extends Renderer
|
|||
$li = Html::tag('li', [
|
||||
'class' => 'movable',
|
||||
'id' => $this->getId($node, $path ?: []),
|
||||
'data-node-name' => (string) $node
|
||||
'data-node-name' => $node->getName()
|
||||
]);
|
||||
|
||||
$li->add($this->getNodeIcons($node, $path));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class HostNodeTest extends BaseTestCase
|
|||
{
|
||||
$this->assertEquals(
|
||||
'localhost;Hoststatus',
|
||||
(string) $this->localhost()
|
||||
$this->localhost()->getName()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue