From 0e00c45e2eeb5ae7174f220b8b987ba532800b11 Mon Sep 17 00:00:00 2001 From: Artem Babak Date: Wed, 13 Jan 2021 06:32:13 +0200 Subject: [PATCH] Hide edge buttons for customer if edges_enabled=false --- .../app/customer/customer-fieldset.tpl.html | 2 +- ui/src/app/customer/customer.controller.js | 44 ++++++++++++------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/ui/src/app/customer/customer-fieldset.tpl.html b/ui/src/app/customer/customer-fieldset.tpl.html index a67a4391df..f24eb3048b 100644 --- a/ui/src/app/customer/customer-fieldset.tpl.html +++ b/ui/src/app/customer/customer-fieldset.tpl.html @@ -19,7 +19,7 @@ {{ 'customer.manage-assets' | translate }} {{ 'customer.manage-devices' | translate }} {{ 'customer.manage-dashboards' | translate }} -{{ 'customer.manage-edges' | translate }} +{{ 'customer.manage-edges' | translate }} {{ 'customer.delete' | translate }}
diff --git a/ui/src/app/customer/customer.controller.js b/ui/src/app/customer/customer.controller.js index 2d1d2202a8..8c20cddb6b 100644 --- a/ui/src/app/customer/customer.controller.js +++ b/ui/src/app/customer/customer.controller.js @@ -21,7 +21,7 @@ import customerCard from './customer-card.tpl.html'; /* eslint-enable import/no-unresolved, import/default */ /*@ngInject*/ -export default function CustomerController(customerService, $state, $stateParams, $translate, types) { +export default function CustomerController(customerService, $state, $stateParams, $translate, types, userService) { var customerActionsList = [ { @@ -76,21 +76,29 @@ export default function CustomerController(customerService, $state, $stateParams } }, icon: "dashboard" - }, - { - onAction: function ($event, item) { - openCustomerEdges($event, item); - }, - name: function() { return $translate.instant('edge.edge-instances') }, - details: function(customer) { - if (customer && customer.additionalInfo && customer.additionalInfo.isPublic) { - return $translate.instant('customer.manage-public-edges') - } else { - return $translate.instant('customer.manage-customer-edges') - } - }, - icon: "router" - }, + }]; + + if (userService.isEdgesSupportEnabled()) { + customerActionsList.push( + { + onAction: function ($event, item) { + openCustomerEdges($event, item); + }, + name: function() { return $translate.instant('edge.edge-instances') }, + details: function(customer) { + if (customer && customer.additionalInfo && customer.additionalInfo.isPublic) { + return $translate.instant('customer.manage-public-edges') + } else { + return $translate.instant('customer.manage-customer-edges') + } + }, + icon: "router", + isEnabled: false + } + ) + } + + customerActionsList.push( { onAction: function ($event, item) { vm.grid.deleteItem($event, item); @@ -102,12 +110,14 @@ export default function CustomerController(customerService, $state, $stateParams return customer && (!customer.additionalInfo || !customer.additionalInfo.isPublic); } } - ]; + ); var vm = this; vm.types = types; + vm.isEdgesSupportEnabled = userService.isEdgesSupportEnabled(); + vm.customerGridConfig = { refreshParamsFunc: null,