From 4557b5d54e0fdf42d4e704e58c8be57062336cc2 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 22 Sep 2011 16:17:36 -0700 Subject: [PATCH] bug 11525: cloudStack 2.2 UI - Domain Admin can only edit/delete/copy/download his own template just like a user. --- ui/scripts/cloud.core.iso.js | 12 ++++++++---- ui/scripts/cloud.core.template.js | 10 +++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ui/scripts/cloud.core.iso.js b/ui/scripts/cloud.core.iso.js index 564c4b7e69a..b53906add9e 100644 --- a/ui/scripts/cloud.core.iso.js +++ b/ui/scripts/cloud.core.iso.js @@ -446,7 +446,8 @@ function isoJsonToDetailsTab() { var noAvailableActions = true; // "Edit ISO", "Copy ISO" - if ((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) + //if ((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) + if ((isAdmin() == false && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) //if neither root-admin, nor item owner || (jsonObj.isready == false) || (jsonObj.domainid == 1 && jsonObj.account == "system") ) { @@ -463,7 +464,8 @@ function isoJsonToDetailsTab() { // "Create VM" // Commenting this out for Beta2 as it does not support the new network. /* - if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) + //if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) + if (((isAdmin() == false && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) //if neither root-admin, nor item owner || jsonObj.isready == false) || (jsonObj.bootable == false) || (jsonObj.domainid == 1 && jsonObj.account == "system") @@ -477,7 +479,8 @@ function isoJsonToDetailsTab() { */ // "Download ISO" - if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) + //if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) + if (((isAdmin() == false && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) //if neither root-admin, nor item owner || (jsonObj.isready == false) || (jsonObj.domainid == 1 && jsonObj.account == "system") ) { @@ -489,7 +492,8 @@ function isoJsonToDetailsTab() { } // "Delete ISO" - if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) + //if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) + if (((isAdmin() == false && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) //if neither root-admin, nor item owner || (jsonObj.isready == false && jsonObj.status != null && jsonObj.status.indexOf("Downloaded") != -1) || (jsonObj.domainid == 1 && jsonObj.account == "system") ) { diff --git a/ui/scripts/cloud.core.template.js b/ui/scripts/cloud.core.template.js index fab46a03c33..f6fa1069539 100644 --- a/ui/scripts/cloud.core.template.js +++ b/ui/scripts/cloud.core.template.js @@ -478,7 +478,9 @@ function templateJsonToDetailsTab() { var noAvailableActions = true; // "Edit Template", "Copy Template", "Create VM" - if ((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) || jsonObj.templatetype == "SYSTEM" || jsonObj.isready == false) { + //if ((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) + if ((isAdmin() == false && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) //if neither root-admin, nor item owner + || jsonObj.templatetype == "SYSTEM" || jsonObj.isready == false) { //do nothing } else { @@ -493,7 +495,8 @@ function templateJsonToDetailsTab() { } // "Download Template" - if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) + //if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) + if (((isAdmin() == false && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) //if neither root-admin, nor item owner || (jsonObj.isready == false) || jsonObj.templatetype == "SYSTEM") { //do nothing } @@ -503,7 +506,8 @@ function templateJsonToDetailsTab() { } // "Delete Template" - if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) + //if (((isUser() && jsonObj.ispublic == true && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) + if (((isAdmin() == false && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account))) //if neither root-admin, nor item owner || (jsonObj.isready == false && jsonObj.status != null && jsonObj.status.indexOf("Downloaded") != -1) || jsonObj.templatetype == "SYSTEM") { //do nothing