Skip to content

Commit aba0c33

Browse files
authored
Reintroduce permission to control the appearance of the Grafana link (#48)
* Reintroduce permission to control the appearance of the Grafana link
1 parent b99be24 commit aba0c33

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

configuration.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
$this->providePermission('grafana/graph', $this->translate('Allow to view graphs in dashboards.'));
1010
$this->providePermission('grafana/debug', $this->translate('Allow to see debug information for graphs.'));
1111
$this->providePermission('grafana/showall', $this->translate('Allow access to see all graphs of a host.'));
12+
$this->providePermission('grafana/showlink', $this->translate('Display a link to the Grafana instance.'));
1213

1314
$this->provideConfigTab('config', [
1415
'title' => 'Configuration',

doc/01-about.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The module provides the following permissions:
1818
* `grafana/graphconfig`, Allow to configure graphs.
1919
* `grafana/graph`, Allow to view graphs in dashboards.
2020
* `grafana/showall`, Allow access to see all graphs of a host.
21+
* `grafana/showlink` Display a link to the Grafana instance.
2122
* `grafana/debug` Allow to see debug information for graphs (can be accessed via the URL parameter `&grafanaDebug`).
2223

2324
## Show all graphs

library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,16 @@ public function getPreviewHtml(Model $object, $report = false)
434434
);
435435

436436
// Add a link to Grafana in the title
437-
$this->title->add(new Link(
438-
new Icon(
439-
'arrow-up-right-from-square',
440-
['title' => 'View in Grafana']
441-
),
442-
str_replace('/d-solo/', '/d/', $url),
443-
['target' => '_blank', 'class' => 'external-link']
444-
));
437+
if ($this->permission->hasPermission('grafana/showlink')) {
438+
$this->title->add(new Link(
439+
new Icon(
440+
'arrow-up-right-from-square',
441+
['title' => 'View in Grafana']
442+
),
443+
str_replace('/d-solo/', '/d/', $url),
444+
['target' => '_blank', 'class' => 'external-link']
445+
));
446+
}
445447

446448
// Hide menu if in reporting or compact mode
447449
$menu = "";

0 commit comments

Comments
 (0)