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/02/22 20:01:42 UTC
[airavata-django-portal] branch master updated: AIRAVATA-2958
Filtering, sorting sharing user, groups
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
The following commit(s) were added to refs/heads/master by this push:
new cf235d5 AIRAVATA-2958 Filtering, sorting sharing user, groups
cf235d5 is described below
commit cf235d58571d8702421e0f541f46ff4a63d904a6
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Fri Feb 22 14:39:51 2019 -0500
AIRAVATA-2958 Filtering, sorting sharing user, groups
---
.../static/django_airavata_api/js/models/Group.js | 7 ++
.../django_airavata_api/js/models/SharedEntity.js | 10 ++
.../static/common/js/components/ShareButton.vue | 12 +-
.../common/js/components/SharedEntityEditor.vue | 140 +++++++++++++++++----
4 files changed, 142 insertions(+), 27 deletions(-)
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/Group.js b/django_airavata/apps/api/static/django_airavata_api/js/models/Group.js
index 561e8cd..77e12cd 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/models/Group.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/Group.js
@@ -50,4 +50,11 @@ export default class Group extends BaseModel {
}
return null;
}
+
+ /**
+ * Return true if group is either the "Gateway Admins" or the "Readonly Admins" group.
+ */
+ get isAdminGroup() {
+ return this.isReadOnlyGatewayAdminsGroup || this.isGatewayAdminsGroup;
+ }
}
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/SharedEntity.js b/django_airavata/apps/api/static/django_airavata_api/js/models/SharedEntity.js
index 0d92ea7..396e476 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/models/SharedEntity.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/SharedEntity.js
@@ -75,4 +75,14 @@ export default class SharedEntity extends BaseModel {
groupPermission => groupPermission.group.id !== group.id
);
}
+
+ get nonAdminGroupPermissions() {
+ if (this.groupPermissions) {
+ return this.groupPermissions.filter(
+ groupPermission => !groupPermission.group.isAdminGroup
+ );
+ } else {
+ return [];
+ }
+ }
}
diff --git a/django_airavata/static/common/js/components/ShareButton.vue b/django_airavata/static/common/js/components/ShareButton.vue
index 1e890cb..a343b77 100644
--- a/django_airavata/static/common/js/components/ShareButton.vue
+++ b/django_airavata/static/common/js/components/ShareButton.vue
@@ -68,9 +68,11 @@ export default {
: null;
},
filteredGroupPermissions: function() {
- return this.localSharedEntity && this.localSharedEntity.groupPermissions
- ? this.localSharedEntity.groupPermissions
- : [];
+ if (this.localSharedEntity && this.localSharedEntity.groupPermissions) {
+ return this.disallowEditingAdminGroups ? this.localSharedEntity.nonAdminGroupPermissions : this.localSharedEntity.groupPermissions;
+ } else {
+ return [];
+ }
},
groupNames: function() {
return this.filteredGroupPermissions.map(
@@ -231,4 +233,8 @@ button {
min-height: 300px;
overflow: auto;
}
+.share-button >>> .modal-dialog {
+ max-width: 800px;
+ width: 60vw;
+}
</style>
diff --git a/django_airavata/static/common/js/components/SharedEntityEditor.vue b/django_airavata/static/common/js/components/SharedEntityEditor.vue
index 31c137c..dcba2c7 100644
--- a/django_airavata/static/common/js/components/SharedEntityEditor.vue
+++ b/django_airavata/static/common/js/components/SharedEntityEditor.vue
@@ -1,8 +1,18 @@
<template>
<div>
- <b-form-group label="Search for users/groups" labelFor="user-groups-autocomplete">
- <autocomplete-text-input id="user-groups-autocomplete" :suggestions="usersAndGroupsSuggestions" @selected="suggestionSelected">
- <template slot="suggestion" slot-scope="slotProps">
+ <b-form-group
+ label="Search for users/groups"
+ labelFor="user-groups-autocomplete"
+ >
+ <autocomplete-text-input
+ id="user-groups-autocomplete"
+ :suggestions="usersAndGroupsSuggestions"
+ @selected="suggestionSelected"
+ >
+ <template
+ slot="suggestion"
+ slot-scope="slotProps"
+ >
<span v-if="slotProps.suggestion.type == 'group'">
<i class="fa fa-users"></i> {{ slotProps.suggestion.name }}
</span>
@@ -15,32 +25,82 @@
</autocomplete-text-input>
</b-form-group>
<h5 v-if="totalCount > 0">Currently Shared With</h5>
- <b-table v-if="usersCount > 0" id="modal-user-table" hover :items="data.userPermissions" :fields="userFields">
- <template slot="name" slot-scope="data">
+ <b-table
+ v-if="usersCount > 0"
+ id="modal-user-table"
+ hover
+ :items="sortedUserPermissions"
+ :fields="userFields"
+ >
+ <template
+ slot="name"
+ slot-scope="data"
+ >
<span :title="data.item.user.userId">{{data.item.user.firstName}} {{data.item.user.lastName}}</span>
</template>
- <template slot="email" slot-scope="data">
+ <template
+ slot="email"
+ slot-scope="data"
+ >
{{data.item.user.email}}
</template>
- <template slot="permission" slot-scope="data">
- <b-form-select v-model="data.item.permissionType" :options="permissionOptions" />
+ <template
+ slot="permission"
+ slot-scope="data"
+ >
+ <b-form-select
+ v-model="data.item.permissionType"
+ :options="permissionOptions"
+ />
</template>
- <template slot="remove" slot-scope="data">
+ <template
+ slot="remove"
+ slot-scope="data"
+ >
<b-link @click="removeUser(data.item.user)">
<span class="fa fa-trash"></span>
</b-link>
</template>
</b-table>
- <b-table v-if="groupsCount > 0" id="modal-group-table" hover :items="filteredGroupPermissions" :fields="groupFields">
- <template slot="name" slot-scope="data">
- {{data.item.group.name}}
+ <b-table
+ v-if="groupsCount > 0"
+ id="modal-group-table"
+ hover
+ :items="sortedGroupPermissions"
+ :fields="groupFields"
+ >
+ <template
+ slot="name"
+ slot-scope="data"
+ >
+ <span v-if="editingAllowed(data.item.group)">{{data.item.group.name}}</span>
+ <span
+ v-else
+ class="text-muted font-italic"
+ >{{data.item.group.name}}</span>
</template>
- <template slot="permission" slot-scope="data">
- <b-form-select v-if="editingAllowed(data.item.group)" v-model="data.item.permissionType" :options="permissionOptions" />
- <span v-else>{{ data.item.permissionType.name }}</span>
+ <template
+ slot="permission"
+ slot-scope="data"
+ >
+ <b-form-select
+ v-if="editingAllowed(data.item.group)"
+ v-model="data.item.permissionType"
+ :options="permissionOptions"
+ />
+ <span
+ v-else
+ class="text-muted font-italic"
+ >{{ data.item.permissionType.name }}</span>
</template>
- <template slot="remove" slot-scope="data">
- <b-link v-if="editingAllowed(data.item.group)" @click="removeGroup(data.item.group)">
+ <template
+ slot="remove"
+ slot-scope="data"
+ >
+ <b-link
+ v-if="editingAllowed(data.item.group)"
+ @click="removeGroup(data.item.group)"
+ >
<span class="fa fa-trash"></span>
</b-link>
</template>
@@ -49,7 +109,7 @@
</template>
<script>
-import { models } from "django-airavata-api";
+import { models, utils } from "django-airavata-api";
import AutocompleteTextInput from "./AutocompleteTextInput.vue";
import VModelMixin from "../mixins/VModelMixin";
@@ -79,8 +139,8 @@ export default {
computed: {
userFields: function() {
return [
- { key: "name", label: "User Name" },
- { key: "email", label: "Email" },
+ { key: "name", label: "User Name", class: "text-truncate" },
+ { key: "email", label: "Email", class: "text-truncate" },
{ key: "permission", label: "Permission" },
{ key: "remove", label: "Remove" }
];
@@ -97,11 +157,33 @@ export default {
? this.data.userPermissions.length
: 0;
},
+ sortedUserPermissions: function() {
+ const userPermsCopy = this.data.userPermissions
+ ? this.data.userPermissions.slice()
+ : [];
+ return utils.StringUtils.sortIgnoreCase(
+ userPermsCopy,
+ userPerm => userPerm.user.lastName + ", " + userPerm.user.firstName
+ );
+ },
filteredGroupPermissions: function() {
return this.data && this.data.groupPermissions
? this.data.groupPermissions
: [];
},
+ sortedGroupPermissions: function() {
+ const groupPermsCopy = this.filteredGroupPermissions.slice();
+ // Sort by name, then admin groups should come last if editing is disallowed
+ utils.StringUtils.sortIgnoreCase(groupPermsCopy, g => g.group.name);
+ if (this.disallowEditingAdminGroups) {
+ groupPermsCopy.sort((a, b) => {
+ if (a.group.isAdminGroup && !b.group.isAdminGroup) {
+ return 1;
+ }
+ });
+ }
+ return groupPermsCopy;
+ },
groupsCount: function() {
return this.filteredGroupPermissions.length;
},
@@ -126,6 +208,14 @@ export default {
);
return this.groups
.filter(group => currentGroupIds.indexOf(group.id) < 0)
+ .filter(group => {
+ // Filter out admin groups from options
+ if (this.disallowEditingAdminGroups) {
+ return !group.isAdminGroup;
+ } else {
+ return true;
+ }
+ })
.map(group => {
return {
id: group.id,
@@ -189,12 +279,14 @@ export default {
* should not be allowed.
*/
editingAllowed(group) {
- return (
- !this.disallowEditingAdminGroups ||
- !(group.isGatewayAdminsGroup || group.isReadOnlyGatewayAdminsGroup)
- );
+ return !this.disallowEditingAdminGroups || !group.isAdminGroup;
}
}
};
</script>
+<style scoped>
+#modal-user-table {
+ table-layout: fixed;
+}
+</style>