[icinga-checkins] icinga.org: icingaweb2/feature/actiontable-row-handling-13115: Don' t show the link for resource removal if the resource is utilized for configuration

git at icinga.org git at icinga.org
Wed Nov 16 10:39:04 CET 2016


Module: icingaweb2
Branch: feature/actiontable-row-handling-13115
Commit: 7331904851ec6bbb5d32a40ead3bfed632f10d1e
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=7331904851ec6bbb5d32a40ead3bfed632f10d1e

Author: Alexander A. Klimov <alexander.klimov at icinga.com>
Date:   Thu Nov  3 18:28:44 2016 +0100

Don't show the link for resource removal if the resource is utilized for configuration

refs #9804

---

 application/controllers/ConfigController.php    |    2 ++
 application/views/scripts/config/resource.phtml |   24 +++++++++++++----------
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php
index c652983..03750fe 100644
--- a/application/controllers/ConfigController.php
+++ b/application/controllers/ConfigController.php
@@ -315,6 +315,8 @@ class ConfigController extends Controller
     {
         $this->assertPermission('config/application/resources');
         $this->view->resources = Config::app('resources', true);
+        $configResource = Config::app()->get('global', 'config_resource');
+        $this->view->unremovableResources = $configResource === null ? array() : array($configResource);
         $this->createApplicationTabs()->activate('resource');
     }
 
diff --git a/application/views/scripts/config/resource.phtml b/application/views/scripts/config/resource.phtml
index ec9c0c7..82f7af0 100644
--- a/application/views/scripts/config/resource.phtml
+++ b/application/views/scripts/config/resource.phtml
@@ -58,16 +58,20 @@
             ) ?>
         </td>
         <td class="icon-col text-right">
-            <?= $this->qlink(
-                '',
-                'config/removeresource',
-                array('resource' => $name),
-                array(
-                    'class'   => 'action-link',
-                    'icon'    => 'cancel',
-                    'title'   => sprintf($this->translate('Remove resource %s'), $name)
-                )
-            ) ?>
+            <?php
+            if (! in_array($name, $unremovableResources)) {
+                echo $this->qlink(
+                    '',
+                    'config/removeresource',
+                    array('resource' => $name),
+                    array(
+                        'class'   => 'action-link',
+                        'icon'    => 'cancel',
+                        'title'   => sprintf($this->translate('Remove resource %s'), $name)
+                    )
+                );
+            }
+            ?>
         </td>
     </tr>
 <?php endforeach ?>



More information about the icinga-checkins mailing list