rhtyd commented on a change in pull request #96: Change template permission URL: https://github.com/apache/cloudstack-primate/pull/96#discussion_r364586996
########## File path: src/views/image/UpdateTemplatePermissions.vue ########## @@ -0,0 +1,288 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +<template> + <div class="form"> + <div v-if="loading" class="loading"> + <a-icon type="loading"></a-icon> + </div> + + <div class="form__item"> + <p class="form__label">{{ $t('operation') }}</p> + <a-select v-model="selectedOperation" defaultValue="Add" @change="fetchData"> + <a-select-option :value="$t('add')">{{ $t('add') }}</a-select-option> + <a-select-option :value="$t('remove')">{{ $t('remove') }}</a-select-option> + <a-select-option :value="$t('reset')">{{ $t('reset') }}</a-select-option> + </a-select> + </div> + + <template v-if="selectedOperation !== 'Reset'"> + <div class="form__item"> + <p class="form__label"> + <span class="required">*</span> + {{ $t('shareWith') }} + </p> + <a-select v-model="selectedShareWith" defaultValue="Account" @change="fetchData"> + <a-select-option :value="$t('account')">{{ $t('account') }}</a-select-option> + <a-select-option :value="$t('project')">{{ $t('project') }}</a-select-option> + </a-select> + </div> + + <template v-if="selectedShareWith === 'Account'"> + <div class="form__item"> + <p class="form__label"> + {{ $t('account') }} + </p> + <a-select + mode="multiple" + placeholder="Select Accounts" + :value="selectedAccounts" + @change="handleChange" + style="width: 100%"> + <a-select-option v-for="account in accountsList" :key="account.name"> + {{ account.name }}</a-select-option> + </a-select> + </div> + </template> + + <template v-else> + <div class="form__item"> + <p class="form__label"> + {{ $t('project') }} + </p> + <a-select + mode="multiple" + placeholder="Select Projects" + :value="selectedProjects" + @change="handleChange" + style="width: 100%"> + <a-select-option v-for="project in projectsList" :key="project.name"> + {{ project.name }}</a-select-option> + </a-select> + </div> + </template> + </template> + <div class="actions"> + <a-button @click="closeModal"> + {{ $t('Cancel') }} + </a-button> + <a-button type="primary" @click="submitData"> + {{ $t('OK') }} + </a-button> + </div> + </div> +</template> +<script> +import { api } from '@/api' + +export default { + name: 'UpdateTemplatePermissions', + props: { + resource: { + type: Object, + required: true + } + }, + inject: ['parentFetchData'], + data () { + return { + projects: [], + accounts: [], + permittedAccounts: [], + permittedProjects: [], + selectedAccounts: [], + selectedProjects: [], + selectedOperation: 'Add', + selectedShareWith: this.$t('account'), + accountError: false, + projectError: false, + allowUserViewAllDomainAccounts: null, Review comment: @Pearl1594 - can you check against old UI code how this is used? Rest LGTM. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services