From b04bb5f1f1c0e7f933391935c42e7ed7d6ba6a6e Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Thu, 31 Aug 2017 16:10:07 +0530 Subject: [PATCH] Disabled edit button for admin role. --- .../app/pages/cdmf.page.roles/public/js/role-listing.js | 5 ++++- .../devicemgt/app/pages/cdmf.page.user.view/view.js | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js index c1acb8e9f2..c9cbbb3e8d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js @@ -150,6 +150,9 @@ function loadRoles() { var innerhtml = ''; + //TODO: Remove the hardcoded admin role name. + var isAdmin = data.name === 'admin'; + var editLink = ''; - if (!isCloud) { + if (!isCloud && !isAdmin) { innerhtml = editLink + editPermissionLink + removeLink; } return innerhtml; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js index 997711701c..63304c70b0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js @@ -18,8 +18,6 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var username = request.getParameter("username"); - var user = userModule.getUser(username)["content"]; var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var isExsistingUser = false; var userName = request.getParameter("username"); @@ -48,8 +46,9 @@ function onRequest(context) { canView = true; } + //TODO: Remove hardcoded admin user name. var canEdit = false; - if (userModule.isAuthorized("/permission/admin/device-mgt/users/edit")) { + if (userModule.isAuthorized("/permission/admin/device-mgt/users/edit") && userName !== 'admin') { canEdit = true; }