| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <template>
- <div>
- <a-alert banner v-if="!isSupport">
- <template #message>
- <p>{{$t('storage.text_148')}}</p>
- <p>{{$t('storage.text_234')}}</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: 'BucketCrossDomainRuleList',
- 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,
- HYPERVISORS_MAP.azure.provider,
- HYPERVISORS_MAP.google.provider,
- ].includes(this.data.provider)
- return {
- list: this.$list.createList(this, {
- id: 'BucketCrossDomainRuleList',
- resource: 'cors',
- ctx: [['buckets', this.resId]],
- getParams: this.getParam,
- }),
- groupActions: [
- {
- label: this.$t('storage.text_31'),
- permission: 'cors_create',
- action: () => {
- this.createDialog('CreateCorsDialog', {
- title: this.$t('storage.text_31'),
- bucketID: this.resId,
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- 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: 'cors_delete',
- action: () => {
- this.createDialog('DeleteCorsDialog', {
- title: this.$t('storage.text_36'),
- name: this.$t('storage.text_211'),
- 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_212'),
- permission: 'cors_create',
- action: (row) => {
- this.createDialog('CreateCorsDialog', {
- 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)
- },
- },
- {
- label: this.$t('storage.text_36'),
- permission: 'cors_delete',
- action: (row) => {
- this.createDialog('DeleteCorsDialog', {
- title: this.$t('storage.text_36'),
- name: this.$t('storage.text_211'),
- 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: 'allowed_origins',
- title: this.$t('storage.text_194'),
- slots: {
- default: ({ row }) => {
- const allowed_origins = row.allowed_origins || []
- return allowed_origins.map(item => {
- return (<list-body-cell-wrap hideField copy title={ item } message={ item }>
- <span>{ item }</span>
- </list-body-cell-wrap>)
- })
- },
- },
- },
- {
- field: 'allowed_methods',
- title: this.$t('storage.text_196'),
- formatter: ({ row }) => {
- return row.allowed_methods.join(',')
- },
- },
- {
- field: 'allowed_headers',
- title: this.$t('storage.text_197'),
- slots: {
- default: ({ row }) => {
- const allowed_headers = row.allowed_headers || []
- return allowed_headers.map(item => {
- return (<list-body-cell-wrap hideField copy title={ item } message={ item }>
- <span>{ item }</span>
- </list-body-cell-wrap>)
- })
- },
- },
- },
- {
- field: 'expose_headers',
- title: this.$t('storage.text_198'),
- slots: {
- default: ({ row }) => {
- const expose_headers = row.expose_headers || []
- return expose_headers.map(item => {
- return (<list-body-cell-wrap hideField copy title={ item } message={ item }>
- <span>{ item }</span>
- </list-body-cell-wrap>)
- })
- },
- },
- },
- {
- field: 'max_age_seconds',
- title: this.$t('storage.text_199'),
- },
- ],
- isSupport,
- }
- },
- created () {
- if (this.isSupport) {
- this.list.fetchData()
- }
- },
- }
- </script>
|