incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olgasm...@apache.org
Subject git commit: CS-15349: Fix incorrect result when Make owner in New project/Add account.
Date Fri, 27 Jul 2012 14:46:08 GMT
Updated Branches:
  refs/heads/master c1989a5e5 -> 7fc3adbac


CS-15349: Fix incorrect result when Make owner in New project/Add account.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/7fc3adba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7fc3adba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7fc3adba

Branch: refs/heads/master
Commit: 7fc3adbacc74850634b6b926d1552cfa00ea0bea
Parents: c1989a5
Author: olgasmola <olya.smola@gmail.com>
Authored: Fri Jul 27 17:32:54 2012 +0300
Committer: olgasmola <olya.smola@gmail.com>
Committed: Fri Jul 27 17:32:54 2012 +0300

----------------------------------------------------------------------
 ui/scripts/projects.js             |   28 ++++++++++++++++++++++++++--
 ui/scripts/ui/widgets/multiEdit.js |    6 ++++++
 2 files changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7fc3adba/ui/scripts/projects.js
----------------------------------------------------------------------
diff --git a/ui/scripts/projects.js b/ui/scripts/projects.js
index 2ece194..cbbb4ce 100644
--- a/ui/scripts/projects.js
+++ b/ui/scripts/projects.js
@@ -15,6 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 (function(cloudStack) {
+  var getProjectAdmin;
   cloudStack.projects = {
     requireInvitation: function(args) {
       return g_capabilities.projectinviterequired;
@@ -447,12 +448,28 @@
             return ['destroy'];
         }
 
-        if (args.context.multiRule[0].role != 'Admin') {
+        if (args.context.multiRule[0].role != 'Admin' &&
+            (cloudStack.context.users[0].account == getProjectAdmin || isAdmin() || isDomainAdmin()))
{ // This is for the new project wizard: check if current logged in User is the Project Owner
           return args.context.actions;
         }
 
         return [];
       },
+      readOnlyCheck: function(args) { // check if current logged in User is the Project Owner
+        if (isAdmin() || isDomainAdmin())
+            return true;
+
+        var projectOwner, currentUser = cloudStack.context.users[0].account;
+        $(args.data).each(function() {
+            var data = this;
+            if (data.role == 'Admin')
+                projectOwner = data.username;
+        });
+        if (projectOwner == currentUser)
+            return true;
+
+        return false;
+      },
       actions: {
         destroy: {
           label: 'label.remove.project.account',
@@ -497,7 +514,12 @@
               success: function(data) {
                 args.response.success({
                   _custom: {
-                    jobId: data.updateprojectresponse.jobid
+                    jobId: data.updateprojectresponse.jobid,
+                    onComplete: function(){
+                      setTimeout(function() {
+                        $(window).trigger('cloudStack.fullRefresh');
+                      }, 500);
+                    }
                   },
                   notification: {
                     label: 'label.make.project.owner',
@@ -522,6 +544,8 @@
           success: function(data) {
             args.response.success({
               data: $.map(data.listprojectaccountsresponse.projectaccount, function(elem)
{
+                if (elem.role == 'Owner' || elem.role == 'Admin')
+                  getProjectAdmin = elem.account;
                 return {
                   id: elem.accountid,
                   role: elem.role,

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7fc3adba/ui/scripts/ui/widgets/multiEdit.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/multiEdit.js b/ui/scripts/ui/widgets/multiEdit.js
index 140b889..9334214 100644
--- a/ui/scripts/ui/widgets/multiEdit.js
+++ b/ui/scripts/ui/widgets/multiEdit.js
@@ -675,6 +675,7 @@
     var context = args.context;
     var ignoreEmptyFields = args.ignoreEmptyFields;
     var actionPreFilter = args.actionPreFilter;
+    var readOnlyCheck = args.readOnlyCheck;
 
     var $thead = $('<tr>').appendTo(
       $('<thead>').appendTo($inputTable)
@@ -935,6 +936,11 @@
               ).appendTo($dataBody);
             });
 
+            if (readOnlyCheck && !readOnlyCheck(args)) {
+                $multi.find('th.add-user, td.add-user').detach();
+                $multiForm.find('tbody').detach();
+            }
+
             _medit.refreshItemWidths($multi);
           },
           error: cloudStack.dialog.error


Mime
View raw message