ServiceNode: Change alias to <service> on <host>

This commit is contained in:
Johannes Meyer 2023-08-04 14:01:54 +02:00
parent 9c84764157
commit d9c6debfa9
2 changed files with 10 additions and 3 deletions

View file

@ -3,9 +3,12 @@
namespace Icinga\Module\Businessprocess;
use Icinga\Module\Businessprocess\Web\Url;
use ipl\I18n\Translation;
class ServiceNode extends MonitoredNode
{
use Translation;
protected $hostname;
/** @var string Alias of the host */
@ -69,7 +72,11 @@ class ServiceNode extends MonitoredNode
return null;
}
return $this->getHostAlias() . ': ' . $this->alias;
return sprintf(
$this->translate('%s on %s', '<service> on <host>'),
$this->alias,
$this->getHostAlias()
);
}
public function getUrl()

View file

@ -27,7 +27,7 @@ class ServiceNodeTest extends BaseTestCase
public function testReturnsCorrectAlias()
{
$this->assertEquals(
'localhost: ping <> pong',
'ping <> pong on localhost',
$this->pingOnLocalhost()->getAlias()
);
}
@ -36,7 +36,7 @@ class ServiceNodeTest extends BaseTestCase
{
$this->assertEquals(
'<a href="/icingaweb2/businessprocess/service/show?host=localhost&amp;service=ping%20%3C%3E%20pong">'
. 'localhost: ping &lt;&gt; pong</a>',
. 'ping &lt;&gt; pong on localhost</a>',
$this->pingOnLocalhost()->getLink()->render()
);
}