| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <div>
- <a-alert banner v-if="!isSupport">
- <template #message>
- <p>{{$t('storage.text_148')}}</p>
- <p>{{$t('storage.text_258')}}</p>
- </template>
- </a-alert>
- <page-list
- v-else
- :list="list"
- :showSearchbox="false"
- :columns="columns"
- :group-actions="groupActions"
- :single-actions="singleActions" />
- </div>
- </template>
- <script>
- import WindowsMixin from '@/mixins/windows'
- import ListMixin from '@/mixins/list'
- import { HYPERVISORS_MAP } from '@/constants'
- export default {
- name: 'BucketPolicyList',
- mixins: [WindowsMixin, ListMixin],
- props: {
- id: String,
- resId: String,
- getParams: {
- type: [Function, Object],
- },
- data: {
- type: Object,
- },
- },
- data () {
- const isSupport = [
- HYPERVISORS_MAP.qcloud.provider,
- HYPERVISORS_MAP.aliyun.provider,
- HYPERVISORS_MAP.aws.provider,
- HYPERVISORS_MAP.huawei.provider,
- ].includes(this.data.provider)
- return {
- list: this.$list.createList(this, {
- id: 'BucketPolicyList',
- resource: 'policy',
- ctx: [['buckets', this.resId]],
- getParams: this.getParam,
- }),
- groupActions: [
- {
- label: this.$t('storage.text_31'),
- permission: 'policy_create',
- action: () => {
- this.createDialog('CreatePolicyDialog', {
- title: this.$t('storage.text_259'),
- bucketID: this.resId,
- onManager: this.onManager,
- refresh: this.refresh,
- bucketData: this.data,
- })
- },
- meta: () => {
- if (this.$store.getters.scope === 'project' && this.data.tenant_id !== this.$store.getters.auth.tenant) {
- return {
- buttonType: 'primary',
- validate: false,
- tooltip: this.$t('storage.text_257'),
- }
- }
- return {
- buttonType: 'primary',
- ...this.$isOwner(this.data),
- }
- },
- },
- {
- label: this.$t('storage.text_36'),
- permission: 'policy_delete',
- action: () => {
- this.createDialog('DeletePolicyDialog', {
- title: this.$t('storage.text_36'),
- name: this.$t('storage.text_259'),
- data: this.list.selectedItems,
- bucketID: this.resId,
- columns: this.columns,
- refresh: this.refresh,
- })
- },
- meta: () => {
- if (this.list.selectedItems.length === 0) return { validate: false }
- if (this.$store.getters.scope === 'project' && this.data.tenant_id !== this.$store.getters.auth.tenant) {
- return {
- validate: false,
- tooltip: this.$t('storage.text_257'),
- }
- }
- return this.$isOwner(this.data)
- },
- },
- ],
- singleActions: [
- {
- label: this.$t('storage.text_36'),
- permission: 'policy_delete',
- action: (row) => {
- this.createDialog('DeletePolicyDialog', {
- title: this.$t('storage.text_36'),
- name: this.$t('storage.text_259'),
- data: [row],
- bucketID: this.resId,
- columns: this.columns,
- refresh: this.refresh,
- })
- },
- meta: () => {
- if (this.$store.getters.scope === 'project' && this.data.tenant_id !== this.$store.getters.auth.tenant) {
- return {
- validate: false,
- tooltip: this.$t('storage.text_257'),
- }
- }
- return this.$isOwner(this.data)
- },
- },
- ],
- columns: [
- {
- field: 'Effect',
- title: this.$t('storage.text_239'),
- formatter: ({ row }) => {
- const obj = {
- Allow: this.$t('storage.text_217'),
- Deny: this.$t('storage.text_218'),
- }
- return obj[row.Effect]
- },
- },
- {
- field: 'principal',
- title: this.$t('storage.text_260'),
- slots: {
- default: ({ row }) => {
- const principal_id = row.principal_id || []
- return principal_id.map(item => {
- const item_arr = item.split(':')
- if (item_arr[0] === item_arr[1]) return (<div>{this.$t('storage.text_241')}</div>)
- return (<div>{this.$t('storage.text_242')}</div>)
- })
- },
- },
- },
- {
- field: 'principal_id',
- title: this.$t('storage.text_261'),
- slots: {
- default: ({ row }) => {
- const { principal_id = [], principal_names = {} } = row
- return principal_id.map(item => {
- const item_arr = item.split(':')
- const item_name = principal_names[item] || ''
- return (<list-body-cell-wrap hideField copy title={ item_arr[1] } message={ item_arr[1] }>
- <span>{ item_arr[1] }{ item_name ? `(${item_name})` : ''}</span>
- </list-body-cell-wrap>)
- })
- },
- },
- },
- {
- field: 'resource_path',
- title: this.$t('storage.text_262'),
- slots: {
- default: ({ row }) => {
- const resource_path = row.resource_path || []
- return resource_path.map(item => {
- return (<list-body-cell-wrap hideField copy title={ item } message={ item }>
- <span>{ item }</span>
- </list-body-cell-wrap>)
- })
- },
- },
- },
- {
- field: 'canned_action',
- title: this.$t('storage.text_263'),
- formatter: ({ row }) => {
- const obj = {
- Read: this.$t('storage.text_252'),
- ReadWrite: this.$t('storage.text_264'),
- FullControl: this.$t('storage.text_254'),
- }
- return obj[row.canned_action] || this.$t('storage.text_265')
- },
- },
- ],
- isSupport,
- }
- },
- created () {
- if (this.isSupport) {
- this.list.fetchData()
- }
- },
- }
- </script>
|