singleActions.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import { mapGetters } from 'vuex'
  2. import { getSetPublicAction } from '@/utils/common/tableActions'
  3. import { FINANCE_INTERNAL } from '@Storage/constants'
  4. // import { HYPERVISORS_MAP } from '@/constants'
  5. import i18n from '@/locales'
  6. export default {
  7. computed: {
  8. ...mapGetters(['isProjectMode']),
  9. _isOwner () {
  10. if (this.$store.getters.scope === 'project' && this.data.tenant_id !== this.$store.getters.auth.tenant) return false
  11. return this.$isOwner(this.data).validate
  12. },
  13. },
  14. created () {
  15. this.singleActions = [
  16. {
  17. label: i18n.t('storage.text_100'),
  18. permission: 'buckets_perform_syncstatus',
  19. action: (row) => {
  20. this.onManager('performAction', {
  21. steadyStatus: ['running', 'ready'],
  22. id: row.id,
  23. managerArgs: {
  24. action: 'syncstatus',
  25. },
  26. })
  27. },
  28. meta: row => {
  29. return {
  30. validate: row.status !== 'sync_status',
  31. }
  32. },
  33. },
  34. {
  35. label: i18n.t('storage.text_65'),
  36. actions: row => {
  37. return [
  38. {
  39. label: i18n.t('storage.text_99'),
  40. permission: 'buckets_perform_limit',
  41. action: row => {
  42. this.createDialog('BucketUpdateBucketLimitDialog', {
  43. title: i18n.t('storage.text_99'),
  44. data: [row],
  45. columns: this.columns,
  46. onManager: this.onManager,
  47. refresh: this.refresh,
  48. })
  49. },
  50. },
  51. getSetPublicAction(this, {
  52. name: this.$t('dictionary.bucket'),
  53. scope: 'project',
  54. resource: 'buckets',
  55. }, {
  56. permission: 'buckets_perform_public',
  57. }),
  58. {
  59. label: i18n.t('storage.text_138'),
  60. permission: 'buckets_perform_acl',
  61. action: row => {
  62. this.createDialog('ObjectsUpdateAclDialog', {
  63. title: i18n.t('storage.text_138'),
  64. data: [row],
  65. bucket: row,
  66. resName: row.name,
  67. columns: this.columns,
  68. list: this.list,
  69. refresh: this.refresh,
  70. })
  71. },
  72. meta: row => {
  73. const ret = { validate: true, tooltip: '' }
  74. if (this.isInternal(row.location)) {
  75. ret.tooltip = this.$t('storage.internal_bucket')
  76. ret.validate = false
  77. return ret
  78. }
  79. return ret
  80. },
  81. },
  82. {
  83. label: this.$t('storage.text_96', [this.$t('dictionary.project')]),
  84. permission: 'buckets_perform_change_owner',
  85. action: row => {
  86. this.createDialog('ChangeOwenrDialog', {
  87. name: i18n.t('storage.text_18'),
  88. data: [row],
  89. columns: this.columns,
  90. onManager: this.onManager,
  91. refresh: this.refresh,
  92. resource: 'buckets',
  93. })
  94. },
  95. meta: (obj) => {
  96. if (obj.is_public) {
  97. return {
  98. validate: false,
  99. tooltip: i18n.t('common_614'),
  100. }
  101. }
  102. const ret = {
  103. validate: false,
  104. tooltip: '',
  105. }
  106. if (this.isProjectMode) {
  107. ret.tooltip = i18n.t('common_601')
  108. return ret
  109. }
  110. return {
  111. validate: true,
  112. }
  113. },
  114. },
  115. // {
  116. // label: i18n.t('storage.text_205'),
  117. // action: row => {
  118. // this.createDialog('SetAntiLeechDialog', {
  119. // data: [row],
  120. // name: i18n.t('storage.text_18'),
  121. // columns: this.columns,
  122. // onManager: this.onManager,
  123. // refresh: this.refresh,
  124. // })
  125. // },
  126. // meta: (obj) => {
  127. // let validate = false
  128. // let tooltip = HYPERVISORS_MAP[obj.provider.toLowerCase()] ? i18n.t('storage.text_232', [HYPERVISORS_MAP[obj.provider.toLowerCase()].label]) : ''
  129. // if (obj.provider === HYPERVISORS_MAP.qcloud.provider && this._isOwner) {
  130. // validate = true
  131. // tooltip = ''
  132. // }
  133. // if (!this._isOwner) {
  134. // tooltip = i18n.t('storage.text_257')
  135. // }
  136. // return {
  137. // validate,
  138. // tooltip,
  139. // }
  140. // },
  141. // },
  142. // {
  143. // label: i18n.t('storage.text_183'),
  144. // action: row => {
  145. // this.$router.push({
  146. // path: '/bucket/setstaticwebsit',
  147. // query: {
  148. // id: row.id,
  149. // },
  150. // })
  151. // },
  152. // meta: (obj) => {
  153. // let validate = false
  154. // let tooltip = HYPERVISORS_MAP[obj.provider.toLowerCase()] ? i18n.t('storage.text_232', [HYPERVISORS_MAP[obj.provider.toLowerCase()].label]) : ''
  155. // if (obj.provider === HYPERVISORS_MAP.qcloud.provider && this._isOwner) {
  156. // validate = true
  157. // tooltip = ''
  158. // }
  159. // if (!this._isOwner) {
  160. // tooltip = i18n.t('storage.text_257')
  161. // }
  162. // return {
  163. // validate,
  164. // tooltip,
  165. // }
  166. // },
  167. // },
  168. {
  169. label: i18n.t('storage.text_36'),
  170. permission: 'buckets_delete',
  171. action: row => {
  172. this.createDialog('DeleteResDialog', {
  173. vm: this,
  174. data: [row],
  175. columns: this.columns,
  176. title: i18n.t('storage.text_36'),
  177. name: i18n.t('storage.text_18'),
  178. onManager: this.onManager,
  179. refresh: this.refresh,
  180. })
  181. },
  182. meta: (row) => {
  183. const ret = { validate: true, tooltip: '' }
  184. if (this.isInternal(row.location)) {
  185. ret.tooltip = this.$t('storage.internal_bucket')
  186. ret.validate = false
  187. return ret
  188. }
  189. return this.$getDeleteResult(row)
  190. },
  191. },
  192. ]
  193. },
  194. },
  195. ]
  196. },
  197. methods: {
  198. isInternal (location) {
  199. return FINANCE_INTERNAL.includes(location)
  200. },
  201. },
  202. }