From 5438bab99b8965a44100ad164cb003c1ce117ae2 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 21 Mar 2018 10:23:12 +0100 Subject: [PATCH] Link to the config form in case of a config error --- library/Graphite/Web/Widget/Graphs.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/library/Graphite/Web/Widget/Graphs.php b/library/Graphite/Web/Widget/Graphs.php index 9060a520..b8c278c9 100644 --- a/library/Graphite/Web/Widget/Graphs.php +++ b/library/Graphite/Web/Widget/Graphs.php @@ -4,6 +4,8 @@ use Icinga\Application\Config; use Icinga\Application\Icinga; +use Icinga\Authentication\Auth; +use Icinga\Exception\ConfigurationError; use Icinga\Module\Graphite\Forms\TimeRangePicker\TimeRangePickerTrait; use Icinga\Module\Graphite\Graphing\GraphingTrait; use Icinga\Module\Graphite\Graphing\Template; @@ -317,7 +319,22 @@ protected function getGraphsList() public function render() { - $result = $this->getGraphsList(); + try { + $result = $this->getGraphsList(); + } catch (ConfigurationError $e) { + $view = $this->view(); + + return "

{$view->escape($e->getMessage())}

" + . '

' . vsprintf( + $view->escape($view->translate('Please %scorrect%s the configuration of the Graphite module.')), + Auth::getInstance()->hasPermission('config/modules') + ? explode( + '$LINK_TEXT$', + $view->qlink('$LINK_TEXT$', 'graphite/config/backend', null, ['class' => 'action-link']) + ) + : ['', ''] + ) . '

'; + } if ($result === '' && $this->getShowNoGraphsFound()) { $view = $this->view();