diff --git a/application/controllers/MonitoringController.php b/application/controllers/MonitoringController.php index 801143d1..3f35a876 100644 --- a/application/controllers/MonitoringController.php +++ b/application/controllers/MonitoringController.php @@ -19,7 +19,6 @@ use Icinga\Module\Vspheredb\Web\Table\Monitoring\MonitoringRuleProblemHistoryTable; use Icinga\Module\Vspheredb\Web\Table\Monitoring\MonitoringRuleProblemTable; use Icinga\Module\Vspheredb\Web\Table\TableWithVCenterFilter; -use Icinga\Module\Vspheredb\Web\Widget\Documentation; use Icinga\Web\Notification; use ipl\Html\Html; use Ramsey\Uuid\Uuid; @@ -39,24 +38,24 @@ public function init() $tabs = $this->tabs(); $tabs->add('index', [ 'label' => $this->translate('Monitoring'), - 'url' => 'vspheredb/monitoring' + 'url' => 'vspheredb/monitoring' ])->add('history', [ 'label' => $this->translate('History'), - 'url' => 'vspheredb/monitoring/history' + 'url' => 'vspheredb/monitoring/history' ]); if ($this->hasPermission('vspheredb/admin')) { $tabs->add('configuration', [ 'label' => $this->translate('Configuration'), - 'url' => 'vspheredb/monitoring/configuration' + 'url' => 'vspheredb/monitoring/configuration' ])->add('hosttree', [ 'label' => $this->translate('Hosts'), - 'url' => 'vspheredb/monitoring/hosttree' + 'url' => 'vspheredb/monitoring/hosttree' ])->add('vmtree', [ 'label' => $this->translate('Virtual Machines'), - 'url' => 'vspheredb/monitoring/vmtree' + 'url' => 'vspheredb/monitoring/vmtree' ])->add('datastoretree', [ 'label' => $this->translate('Datastores'), - 'url' => 'vspheredb/monitoring/datastoretree' + 'url' => 'vspheredb/monitoring/datastoretree' ]); } $tabs->activate($action); @@ -133,11 +132,15 @@ public function configurationAction() Html::tag('h2', $this->translate('Defining Check Commands')), Html::tag('p', Html::sprintf( $this->translate('Check our %s for instructions of how to set them up'), - Documentation::link( + Html::tag( + 'a', + [ + 'href' => 'https://icinga.com/docs/icinga-vsphere-integration/latest/doc/32-Monitoring_Rules/', + 'class' => 'icon-book', + 'title' => $this->translate('Click to read our documentation: Icinga vSphereDB Check Commands'), + 'target' => '_blank' + ], $this->translate('Documentation'), - 'icinga-vsphere-integration', - '32-Monitoring_Rules', - $this->translate('Icinga vSphereDB Check Commands') ) )) ]); diff --git a/library/Vspheredb/Web/Widget/Documentation.php b/library/Vspheredb/Web/Widget/Documentation.php deleted file mode 100644 index 0ea2853e..00000000 --- a/library/Vspheredb/Web/Widget/Documentation.php +++ /dev/null @@ -1,105 +0,0 @@ -app = $app; - $this->auth = $auth; - } - - public static function link($label, $module, $chapter, $title = null) - { - $doc = new static(Icinga::app(), Auth::getInstance()); - return $doc->getModuleLink($label, $module, $chapter, $title); - } - - public function getModuleLink($label, $module, $chapter, $title = null) - { - if ($title !== null) { - $title = sprintf( - $this->translate('Click to read our documentation: %s'), - $title - ); - } - $baseParams = [ - 'class' => 'icon-book', - 'title' => $title, - ]; - if ($this->hasAccessToDocumentationModule()) { - return Link::create( - $label, - $this->getModuleDocumentationUrl($module, $chapter), - null, - ['data-base-target' => '_next'] + $baseParams - ); - } - - $baseParams['target'] = '_blank'; - if ($this->linkToGitHub) { - return Html::tag('a', [ - 'href' => $this->githubDocumentationUrl($module, $chapter), - ] + $baseParams, $label); - } - - return Html::tag('a', [ - 'href' => $this->icingaDocumentationUrl($module, $chapter), - ] + $baseParams, $label); - } - - protected function getModuleDocumentationUrl($moduleName, $chapter): string - { - return sprintf( - 'doc/module/%s/chapter/%s', - rawurlencode($moduleName), - preg_replace('/^\d+-/', '', rawurlencode($chapter)) - ); - } - - protected function githubDocumentationUrl($module, $chapter): string - { - return sprintf( - "https://github.com/Icinga/icingaweb2-module-%s/blob/master/doc/%s.md", - rawurlencode($module), - rawurlencode($chapter) - ); - } - - protected function icingaDocumentationUrl($module, $chapter): string - { - return sprintf( - 'https://icinga.com/docs/%s/latest/doc/%s/', - rawurlencode($module), - rawurlencode($chapter) - ); - } - - protected function hasAccessToDocumentationModule(): bool - { - return $this->app->getModuleManager()->hasLoaded('doc') - && $this->auth->hasPermission('module/doc'); - } -}