CrossDomainRules.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div>
  3. <a-alert banner v-if="!isSupport">
  4. <template #message>
  5. <p>{{$t('storage.text_148')}}</p>
  6. <p>{{$t('storage.text_234')}}</p>
  7. </template>
  8. </a-alert>
  9. <page-list
  10. v-else
  11. :list="list"
  12. :showSearchbox="false"
  13. :columns="columns"
  14. :group-actions="groupActions"
  15. :single-actions="singleActions" />
  16. </div>
  17. </template>
  18. <script>
  19. import WindowsMixin from '@/mixins/windows'
  20. import ListMixin from '@/mixins/list'
  21. import { HYPERVISORS_MAP } from '@/constants'
  22. export default {
  23. name: 'BucketCrossDomainRuleList',
  24. mixins: [WindowsMixin, ListMixin],
  25. props: {
  26. id: String,
  27. resId: String,
  28. getParams: {
  29. type: [Function, Object],
  30. },
  31. data: {
  32. type: Object,
  33. },
  34. },
  35. data () {
  36. const isSupport = [
  37. HYPERVISORS_MAP.qcloud.provider,
  38. HYPERVISORS_MAP.aliyun.provider,
  39. HYPERVISORS_MAP.aws.provider,
  40. HYPERVISORS_MAP.huawei.provider,
  41. HYPERVISORS_MAP.azure.provider,
  42. HYPERVISORS_MAP.google.provider,
  43. ].includes(this.data.provider)
  44. return {
  45. list: this.$list.createList(this, {
  46. id: 'BucketCrossDomainRuleList',
  47. resource: 'cors',
  48. ctx: [['buckets', this.resId]],
  49. getParams: this.getParam,
  50. }),
  51. groupActions: [
  52. {
  53. label: this.$t('storage.text_31'),
  54. permission: 'cors_create',
  55. action: () => {
  56. this.createDialog('CreateCorsDialog', {
  57. title: this.$t('storage.text_31'),
  58. bucketID: this.resId,
  59. onManager: this.onManager,
  60. refresh: this.refresh,
  61. })
  62. },
  63. meta: () => {
  64. if (this.$store.getters.scope === 'project' && this.data.tenant_id !== this.$store.getters.auth.tenant) {
  65. return {
  66. buttonType: 'primary',
  67. validate: false,
  68. tooltip: this.$t('storage.text_257'),
  69. }
  70. }
  71. return {
  72. buttonType: 'primary',
  73. ...this.$isOwner(this.data),
  74. }
  75. },
  76. },
  77. {
  78. label: this.$t('storage.text_36'),
  79. permission: 'cors_delete',
  80. action: () => {
  81. this.createDialog('DeleteCorsDialog', {
  82. title: this.$t('storage.text_36'),
  83. name: this.$t('storage.text_211'),
  84. data: this.list.selectedItems,
  85. bucketID: this.resId,
  86. columns: this.columns,
  87. refresh: this.refresh,
  88. })
  89. },
  90. meta: () => {
  91. if (this.list.selectedItems.length === 0) return { validate: false }
  92. if (this.$store.getters.scope === 'project' && this.data.tenant_id !== this.$store.getters.auth.tenant) {
  93. return {
  94. validate: false,
  95. tooltip: this.$t('storage.text_257'),
  96. }
  97. }
  98. return this.$isOwner(this.data)
  99. },
  100. },
  101. ],
  102. singleActions: [
  103. {
  104. label: this.$t('storage.text_212'),
  105. permission: 'cors_create',
  106. action: (row) => {
  107. this.createDialog('CreateCorsDialog', {
  108. data: [row],
  109. bucketID: this.resId,
  110. columns: this.columns,
  111. refresh: this.refresh,
  112. })
  113. },
  114. meta: () => {
  115. if (this.$store.getters.scope === 'project' && this.data.tenant_id !== this.$store.getters.auth.tenant) {
  116. return {
  117. validate: false,
  118. tooltip: this.$t('storage.text_257'),
  119. }
  120. }
  121. return this.$isOwner(this.data)
  122. },
  123. },
  124. {
  125. label: this.$t('storage.text_36'),
  126. permission: 'cors_delete',
  127. action: (row) => {
  128. this.createDialog('DeleteCorsDialog', {
  129. title: this.$t('storage.text_36'),
  130. name: this.$t('storage.text_211'),
  131. data: [row],
  132. bucketID: this.resId,
  133. columns: this.columns,
  134. refresh: this.refresh,
  135. })
  136. },
  137. meta: () => {
  138. if (this.$store.getters.scope === 'project' && this.data.tenant_id !== this.$store.getters.auth.tenant) {
  139. return {
  140. validate: false,
  141. tooltip: this.$t('storage.text_257'),
  142. }
  143. }
  144. return this.$isOwner(this.data)
  145. },
  146. },
  147. ],
  148. columns: [
  149. {
  150. field: 'allowed_origins',
  151. title: this.$t('storage.text_194'),
  152. slots: {
  153. default: ({ row }) => {
  154. const allowed_origins = row.allowed_origins || []
  155. return allowed_origins.map(item => {
  156. return (<list-body-cell-wrap hideField copy title={ item } message={ item }>
  157. <span>{ item }</span>
  158. </list-body-cell-wrap>)
  159. })
  160. },
  161. },
  162. },
  163. {
  164. field: 'allowed_methods',
  165. title: this.$t('storage.text_196'),
  166. formatter: ({ row }) => {
  167. return row.allowed_methods.join(',')
  168. },
  169. },
  170. {
  171. field: 'allowed_headers',
  172. title: this.$t('storage.text_197'),
  173. slots: {
  174. default: ({ row }) => {
  175. const allowed_headers = row.allowed_headers || []
  176. return allowed_headers.map(item => {
  177. return (<list-body-cell-wrap hideField copy title={ item } message={ item }>
  178. <span>{ item }</span>
  179. </list-body-cell-wrap>)
  180. })
  181. },
  182. },
  183. },
  184. {
  185. field: 'expose_headers',
  186. title: this.$t('storage.text_198'),
  187. slots: {
  188. default: ({ row }) => {
  189. const expose_headers = row.expose_headers || []
  190. return expose_headers.map(item => {
  191. return (<list-body-cell-wrap hideField copy title={ item } message={ item }>
  192. <span>{ item }</span>
  193. </list-body-cell-wrap>)
  194. })
  195. },
  196. },
  197. },
  198. {
  199. field: 'max_age_seconds',
  200. title: this.$t('storage.text_199'),
  201. },
  202. ],
  203. isSupport,
  204. }
  205. },
  206. created () {
  207. if (this.isSupport) {
  208. this.list.fetchData()
  209. }
  210. },
  211. }
  212. </script>