You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/05/09 16:19:57 UTC

[airavata-django-portal] 02/06: AIRAVATA-3030 Add inherited parent permissions to tooltip, count

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git

commit 5ff4acf771b15b49f2e0a81eac08bfe94466b680
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Tue May 7 12:55:13 2019 -0400

    AIRAVATA-3030 Add inherited parent permissions to tooltip, count
---
 .../static/common/js/components/ShareButton.vue    | 65 +++++++++++++++++-----
 .../common/js/components/SharedEntityEditor.vue    |  4 +-
 2 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/django_airavata/static/common/js/components/ShareButton.vue b/django_airavata/static/common/js/components/ShareButton.vue
index f9eb6f9..6380955 100644
--- a/django_airavata/static/common/js/components/ShareButton.vue
+++ b/django_airavata/static/common/js/components/ShareButton.vue
@@ -105,16 +105,35 @@ export default {
       );
     },
     usersCount: function() {
-      return this.localSharedEntity && this.localSharedEntity.userPermissions
-        ? this.localSharedEntity.userPermissions.length
-        : 0;
+      return this.combinedUsers.length;
     },
     userNames: function() {
-      return this.localSharedEntity && this.localSharedEntity.userPermissions
-        ? this.localSharedEntity.userPermissions.map(
-            userPerm => userPerm.user.firstName + " " + userPerm.user.lastName
-          )
-        : null;
+      return this.combinedUsers.map(u => u.firstName + " " + u.lastName);
+    },
+    combinedUsers() {
+      const users = [];
+      if (this.localSharedEntity && this.localSharedEntity.userPermissions) {
+        users.push(
+          ...this.localSharedEntity.userPermissions.map(up => up.user)
+        );
+      }
+      if (this.parentSharedEntity) {
+        // Only add in inherited permissions if we haven't saved yet because
+        // once saved the inherited permissions are already copied in
+        if (
+          this.localSharedEntity &&
+          !this.localSharedEntity.entityId &&
+          this.parentSharedEntity.userPermissions
+        ) {
+          users.push(
+            ...this.parentSharedEntity.userPermissions.map(up => up.user)
+          );
+        }
+        if (this.parentEntityOwner) {
+          users.push(this.parentEntityOwner);
+        }
+      }
+      return users;
     },
     filteredGroupPermissions: function() {
       if (this.localSharedEntity && this.localSharedEntity.groupPermissions) {
@@ -125,13 +144,28 @@ export default {
         return [];
       }
     },
+    combinedGroups() {
+      const groups = [];
+      groups.push(...this.filteredGroupPermissions.map(gp => gp.group));
+      // Only add in inherited permissions if we haven't saved yet because
+      // once saved the inherited permissions are already copied in
+      if (
+        this.localSharedEntity &&
+        !this.localSharedEntity.entityId &&
+        this.parentSharedEntity &&
+        this.parentSharedEntity.groupPermissions
+      ) {
+        groups.push(
+          ...this.parentSharedEntity.groupPermissions.map(gp => gp.group)
+        );
+      }
+      return groups;
+    },
     groupNames: function() {
-      return this.filteredGroupPermissions.map(
-        groupPerm => groupPerm.group.name
-      );
+      return this.combinedGroups.map(g => g.name);
     },
     groupsCount: function() {
-      return this.filteredGroupPermissions.length;
+      return this.combinedGroups.length;
     },
     totalCount: function() {
       return this.usersCount + this.groupsCount;
@@ -151,7 +185,12 @@ export default {
       );
     },
     parentEntityOwner() {
-      return this.parentSharedEntity && this.parentSharedEntity.owner;
+      // Only show the parent entity owner when not the same as current user
+      if (this.parentSharedEntity && !this.parentSharedEntity.isOwner) {
+        return this.parentSharedEntity.owner;
+      } else {
+        return null;
+      }
     }
   },
   methods: {
diff --git a/django_airavata/static/common/js/components/SharedEntityEditor.vue b/django_airavata/static/common/js/components/SharedEntityEditor.vue
index be778ff..fb0ba9c 100644
--- a/django_airavata/static/common/js/components/SharedEntityEditor.vue
+++ b/django_airavata/static/common/js/components/SharedEntityEditor.vue
@@ -173,9 +173,7 @@ export default {
       ];
     },
     usersCount: function() {
-      return this.data && this.data.userPermissions
-        ? this.data.userPermissions.length
-        : 0;
+      return this.sortedUserPermissionsData.length;
     },
     sortedUserPermissionsData: function() {
       const userPermsCopy = this.data.userPermissions