singleActions.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. import { mapGetters } from 'vuex'
  2. import { getSetPublicAction } from '@/utils/common/tableActions'
  3. import i18n from '@/locales'
  4. // import { exportDataOptions } from '../utils'
  5. export default {
  6. computed: {
  7. ...mapGetters(['isAdminMode', 'isDomainMode', 'isProjectMode', 'userInfo']),
  8. },
  9. created () {
  10. this.singleActions = [
  11. // {
  12. // label: `关联${this.$t('dictionary.server')}`,
  13. // permission: 'server_perform_assign_secgroup',
  14. // action: (obj) => {
  15. // this.createDialog('SetServerDialog', {
  16. // data: [obj],
  17. // columns: this.columns,
  18. // title: `关联${this.$t('dictionary.server')}`,
  19. // onManager: this.onManager,
  20. // refresh: this.refresh,
  21. // })
  22. // },
  23. // },
  24. {
  25. label: i18n.t('compute.text_1027'),
  26. permission: 'secgrouprules_list',
  27. action: (obj) => {
  28. this.sidePageTriggerHandle(this, 'SecGroupSidePage', {
  29. id: obj.id,
  30. resource: 'secgroups',
  31. }, { tab: 'in-direction' })
  32. },
  33. },
  34. {
  35. label: i18n.t('compute.text_352'),
  36. actions: obj => {
  37. return [
  38. // {
  39. // label: '设置为私有',
  40. // permission: 'secgroups_create',
  41. // action: () => {
  42. // this.onManager('performAction', {
  43. // id: obj.id,
  44. // managerArgs: {
  45. // action: 'private',
  46. // },
  47. // })
  48. // },
  49. // meta: () => {
  50. // if (this.$store.getters.isAdminMode || this.$store.getters.isDomainMode) {
  51. // if (this.isPower(obj)) {
  52. // return {
  53. // validate: obj.is_public,
  54. // }
  55. // }
  56. // }
  57. // return {
  58. // validate: false,
  59. // }
  60. // },
  61. // },
  62. // {
  63. // label: '设置为共享',
  64. // permission: 'secgroups_create',
  65. // action: () => {
  66. // this.createDialog('SetPublicDialog', {
  67. // data: [obj],
  68. // title: '设置为共享',
  69. // columns: this.columns,
  70. // onManager: this.onManager,
  71. // refresh: this.refresh,
  72. // })
  73. // },
  74. // meta: () => {
  75. // if (this.$store.getters.isAdminMode || this.$store.getters.isDomainMode) {
  76. // if (this.isPower(obj)) {
  77. // return {
  78. // validate: !obj.is_public,
  79. // }
  80. // }
  81. // }
  82. // return {
  83. // validate: false,
  84. // }
  85. // },
  86. // },
  87. {
  88. label: i18n.t('compute.perform_sync_status'),
  89. permission: 'secgroups_perform_sync_status',
  90. action: () => {
  91. this.onManager('performAction', {
  92. steadyStatus: ['ready', 'delete_failed'],
  93. id: obj.id,
  94. managerArgs: {
  95. action: 'syncstatus',
  96. },
  97. })
  98. },
  99. },
  100. {
  101. label: i18n.t('compute.text_1028_1'),
  102. permission: 'servers_list',
  103. action: (obj) => {
  104. this.sidePageTriggerHandle(this, 'SecGroupSidePage', {
  105. id: obj.id,
  106. resource: 'secgroups',
  107. }, { tab: 'associated-instances' })
  108. },
  109. hidden: () => this.hiddenActions.includes('openSecgroupSidepageTab'),
  110. },
  111. // {
  112. // label: i18n.t('compute.text_983'),
  113. // permission: 'secgroups_perform_clone',
  114. // action: () => {
  115. // this.createDialog('CloneSecgroupDialog', {
  116. // data: [obj],
  117. // columns: this.columns,
  118. // title: i18n.t('compute.text_983'),
  119. // onManager: this.onManager,
  120. // refresh: this.refresh,
  121. // })
  122. // },
  123. // meta: () => {
  124. // const isPrivate = !obj.is_public
  125. // return {
  126. // validate: this.isPower(obj),
  127. // tooltip: !isPrivate ? i18n.t('compute.secgroup.shared') : '',
  128. // }
  129. // },
  130. // },
  131. // {
  132. // label: i18n.t('compute.import_secgroup_rule', []),
  133. // permission: 'secgroups_perform_import_rules',
  134. // action: () => {
  135. // this.createDialog('ImportSecgroupRuleDialog', {
  136. // data: [obj],
  137. // exportDataOptions,
  138. // onManager: this.onManager,
  139. // refresh: this.refresh,
  140. // a: 1,
  141. // })
  142. // },
  143. // meta: () => {
  144. // const isPrivate = !obj.is_public
  145. // return {
  146. // validate: this.isPower(obj),
  147. // tooltip: !isPrivate ? i18n.t('compute.secgroup.shared') : '',
  148. // }
  149. // },
  150. // },
  151. // {
  152. // label: i18n.t('compute.text_1012'),
  153. // permission: 'secgroups_perform_merge',
  154. // action: () => {
  155. // this.createDialog('ConcatSecgroupDialog', {
  156. // data: [obj],
  157. // columns: this.columns,
  158. // title: i18n.t('compute.text_1012'),
  159. // onManager: this.onManager,
  160. // refresh: this.refresh,
  161. // })
  162. // },
  163. // meta: () => {
  164. // const isPrivate = !obj.is_public
  165. // return {
  166. // validate: this.isPower(obj),
  167. // tooltip: !isPrivate ? i18n.t('compute.secgroup.shared') : '',
  168. // }
  169. // },
  170. // },
  171. {
  172. label: this.$t('compute.perform_change_owner', [this.$t('dictionary.project')]),
  173. permission: 'secgroups_create',
  174. action: () => {
  175. this.createDialog('ChangeOwenrDialog', {
  176. data: [obj],
  177. columns: this.columns,
  178. onManager: this.onManager,
  179. refresh: this.refresh,
  180. name: this.$t('dictionary.secgroup'),
  181. resource: 'secgroups',
  182. })
  183. },
  184. meta: () => {
  185. if (!this.isProjectMode) {
  186. const isPower = this.isPower(obj)
  187. const isPrivate = !obj.is_public
  188. return {
  189. validate: isPower && isPrivate,
  190. tooltip: isPower && !isPrivate ? i18n.t('compute.secgroup.shared') : '',
  191. }
  192. }
  193. return {
  194. tooltip: i18n.t('compute.text_1336'),
  195. validate: false,
  196. }
  197. },
  198. },
  199. getSetPublicAction(this, {
  200. name: this.$t('dictionary.secgroup'),
  201. scope: 'project',
  202. resource: 'secgroups',
  203. }, {
  204. permission: 'secgroups_perform_public',
  205. }),
  206. {
  207. label: i18n.t('compute.perform_delete'),
  208. permission: 'secgroups_delete',
  209. action: () => {
  210. this.createDialog('DeleteResDialog', {
  211. vm: this,
  212. data: [obj],
  213. alert: this.$t('compute.text_1395'),
  214. columns: this.columns,
  215. title: i18n.t('compute.perform_delete'),
  216. name: this.$t('dictionary.secgroup'),
  217. onManager: this.onManager,
  218. })
  219. },
  220. meta: () => this.$getDeleteResult(obj),
  221. },
  222. ]
  223. },
  224. },
  225. ]
  226. },
  227. methods: {
  228. isPower (obj) {
  229. if (!obj.domain_id && obj.data.domain_id) {
  230. obj = obj.data
  231. }
  232. if (this.isAdminMode) return true
  233. if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
  234. return obj.tenant_id === this.userInfo.projectId
  235. },
  236. },
  237. }