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 4dfc8458a51cc3c5e0596005719835ca1459cca6 Author: Marcus Christie <[email protected]> AuthorDate: Wed Jul 24 12:09:41 2019 -0400 AIRAVATA-3177 Allow readonly admins to see gateway resource profile --- django_airavata/apps/admin/apps.py | 3 ++- .../src/components/credentials/SSHCredentialSelector.vue | 8 ++++++-- .../components/gatewayprofile/GatewayResourceProfileEditor.vue | 2 +- .../gatewayprofile/GatewayResourceProfileEditorContainer.vue | 6 ++---- .../src/components/gatewayprofile/StoragePreferenceList.vue | 10 +++++++--- django_airavata/apps/api/serializers.py | 5 +++++ .../django_airavata_api/js/models/GatewayResourceProfile.js | 3 ++- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/django_airavata/apps/admin/apps.py b/django_airavata/apps/admin/apps.py index 91b3752..5501733 100644 --- a/django_airavata/apps/admin/apps.py +++ b/django_airavata/apps/admin/apps.py @@ -54,7 +54,8 @@ class AdminConfig(AiravataAppConfig): 'icon': 'fa fa-tasks', 'url': 'django_airavata_admin:gateway_resource_profile', 'active_prefixes': ['gateway-resource-profile'], - 'enabled': lambda req: req.is_gateway_admin + 'enabled': lambda req: (req.is_gateway_admin or + req.is_read_only_gateway_admin) }, { 'label': 'Manage Notices', diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/credentials/SSHCredentialSelector.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/credentials/SSHCredentialSelector.vue index ead1bb6..c9c6584 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/credentials/SSHCredentialSelector.vue +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/credentials/SSHCredentialSelector.vue @@ -1,7 +1,7 @@ <template> <div> <b-input-group> - <b-form-select v-model="data" :options="credentialStoreTokenOptions"> + <b-form-select v-model="data" :options="credentialStoreTokenOptions" :disabled="readonly"> <option v-if="nullOption" slot="first" :value="null" :disabled="nullOptionDisabled"> <slot name="null-option-label" :defaultCredentialSummary="defaultCredentialSummary"> <span v-if="defaultCredentialSummary"> @@ -16,7 +16,7 @@ <b-input-group-append> <clipboard-copy-button variant="secondary" :text="copySSHPublicKeyText"> </clipboard-copy-button> - <b-button variant="secondary" @click="showNewSSHCredentialModal"> + <b-button v-if="!readonly" variant="secondary" @click="showNewSSHCredentialModal"> <i class="fa fa-plus"></i> </b-button> </b-input-group-append> @@ -47,6 +47,10 @@ export default { nullOptionDisabled: { type: Boolean, default: false + }, + readonly: { + type: Boolean, + default: false } }, mixins: [mixins.VModelMixin], diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditor.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditor.vue index 244bdb6..cb0ac76 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditor.vue +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditor.vue @@ -6,7 +6,7 @@ Gateway Resource Profile - {{ data.gatewayID }} </h1> <b-form-group label="Default SSH Credential" label-for="default-credential-store-token" description="This is the default SSH credential that will be used for storage preferences that don't specify their own SSH credential."> - <ssh-credential-selector id="default-credential-store-token" v-model="data.credentialStoreToken"/> + <ssh-credential-selector id="default-credential-store-token" v-model="data.credentialStoreToken" :readonly="!data.userHasWriteAccess"/> </b-form-group> </div> </div> diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditorContainer.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditorContainer.vue index 3e827c0..949f30a 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditorContainer.vue +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditorContainer.vue @@ -15,12 +15,12 @@ <div class="card-body"> <storage-preference-list v-if="gatewayResourceProfile" :storagePreferences="gatewayResourceProfile.storagePreferences" :default-credential-store-token="gatewayResourceProfile.credentialStoreToken" @updated="updatedStoragePreference" - @added="addedStoragePreference" @delete="deleteStoragePreference" /> + @added="addedStoragePreference" @delete="deleteStoragePreference" :readonly="!gatewayResourceProfile.userHasWriteAccess"/> </div> </div> </div> </div> - <div class="row"> + <div class="row" v-if="gatewayResourceProfile && gatewayResourceProfile.userHasWriteAccess"> <div class="col"> <b-button variant="primary" @click="save"> Save @@ -36,14 +36,12 @@ <script> import { services } from "django-airavata-api"; import GatewayResourceProfileEditor from "./GatewayResourceProfileEditor.vue"; -import StoragePreferenceEditor from "./StoragePreferenceEditor.vue"; import StoragePreferenceList from "./StoragePreferenceList.vue"; export default { name: "gateway-resource-profile-editor-container", components: { GatewayResourceProfileEditor, - StoragePreferenceEditor, StoragePreferenceList }, data() { diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/StoragePreferenceList.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/StoragePreferenceList.vue index 28df694..145d0e0 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/StoragePreferenceList.vue +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/StoragePreferenceList.vue @@ -1,6 +1,6 @@ <template> <list-layout @add-new-item="addNewStoragePreference" :items="decoratedStoragePreferences" title="Storage Preferences" - new-item-button-text="New Storage Preference"> + new-item-button-text="New Storage Preference" :new-button-disabled="readonly"> <template slot="new-item-editor"> <b-card v-if="showNewItemEditor" title="New Storage Preference"> <b-form-group label="Storage Resource" label-for="storage-resource"> @@ -29,11 +29,11 @@ </b-badge> </template> <template slot="action" slot-scope="data"> - <b-link class="action-link" @click="toggleDetails(data)"> + <b-link v-if="!readonly" class="action-link" @click="toggleDetails(data)"> Edit <i class="fa fa-edit" aria-hidden="true"></i> </b-link> - <delete-link @delete="deleteStoragePreference(data.item.storageResourceId)"> + <delete-link v-if="!readonly" @delete="deleteStoragePreference(data.item.storageResourceId)"> Are you sure you want to delete the storage preference for {{ getStorageResourceName(data.item.storageResourceId) }}? </delete-link> </template> @@ -68,6 +68,10 @@ export default { }, defaultCredentialStoreToken: { type: String + }, + readonly: { + type: Boolean, + default: false } }, data() { diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py index 5ba819d..4e5fb21 100644 --- a/django_airavata/apps/api/serializers.py +++ b/django_airavata/apps/api/serializers.py @@ -805,6 +805,11 @@ class GatewayResourceProfileSerializer( lookup_field='gatewayID', lookup_url_kwarg='gateway_id') storagePreferences = StoragePreferenceSerializer(many=True) + userHasWriteAccess = serializers.SerializerMethodField() + + def get_userHasWriteAccess(self, gatewayResourceProfile): + request = self.context['request'] + return request.is_gateway_admin class StorageResourceSerializer( diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/GatewayResourceProfile.js b/django_airavata/apps/api/static/django_airavata_api/js/models/GatewayResourceProfile.js index 5826e68..7ce6a72 100644 --- a/django_airavata/apps/api/static/django_airavata_api/js/models/GatewayResourceProfile.js +++ b/django_airavata/apps/api/static/django_airavata_api/js/models/GatewayResourceProfile.js @@ -11,7 +11,8 @@ const FIELDS = [ list: true }, "identityServerTenant", - "identityServerPwdCredToken" + "identityServerPwdCredToken", + "userHasWriteAccess" ]; export default class GatewayResourceProfile extends BaseModel {
