singleActions.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import { mapGetters } from 'vuex'
  2. import { getEnabledSwitchActions, getSetPublicAction } from '@/utils/common/tableActions'
  3. export default {
  4. created () {
  5. this.singleActions = [
  6. {
  7. label: this.$t('table.action.modify'),
  8. permission: 'robots_update',
  9. action: (row) => {
  10. this.createDialog('CreateRobotDialog', {
  11. data: row,
  12. onManager: this.onManager,
  13. refresh: this.refresh,
  14. })
  15. },
  16. meta: (row) => {
  17. const ret = {
  18. validate: true,
  19. tooltip: null,
  20. }
  21. if (!this.isPower(row)) {
  22. ret.validate = false
  23. ret.tooltip = this.$t('system.robot.shared')
  24. return ret
  25. }
  26. return ret
  27. },
  28. },
  29. {
  30. label: this.$t('system.text_153'),
  31. actions: (row) => {
  32. return [
  33. getSetPublicAction(this, {
  34. name: this.$t('system.robot'),
  35. scope: 'project',
  36. resource: 'robots',
  37. apiVersion: 'v1',
  38. }, {
  39. permission: 'robots_perform_public',
  40. meta: (row) => {
  41. const ret = {
  42. validate: true,
  43. tooltip: null,
  44. }
  45. if (!this.isPower(row)) {
  46. ret.validate = false
  47. ret.tooltip = this.$t('system.robot.shared')
  48. return ret
  49. }
  50. // if (row.public_scope !== 'none') {
  51. // ret.validate = false
  52. // ret.tooltip = this.$t('system.robot.shared')
  53. // return ret
  54. // }
  55. return ret
  56. },
  57. }),
  58. {
  59. label: this.$t('compute.perform_change_owner', [this.$t('dictionary.project')]),
  60. permission: 'robots_perform_change_owner',
  61. action: () => {
  62. this.createDialog('ChangeOwenrDialog', {
  63. data: [row],
  64. columns: this.columns,
  65. onManager: this.onManager,
  66. name: this.$t('system.robot'),
  67. resource: 'robots',
  68. apiVersion: 'v1',
  69. })
  70. },
  71. meta: () => {
  72. const ret = {
  73. validate: true,
  74. tooltip: null,
  75. }
  76. if (!this.isPower(row)) {
  77. ret.validate = false
  78. ret.tooltip = this.$t('system.robot.shared')
  79. return ret
  80. }
  81. return ret
  82. },
  83. },
  84. ...getEnabledSwitchActions(this, row, ['robots_perform_enable', 'robots_perform_disable'], {
  85. resourceName: this.$t('system.robot'),
  86. metas: [
  87. () => {
  88. const ret = {
  89. validate: true,
  90. tooltip: null,
  91. }
  92. if (!this.isPower(row)) {
  93. ret.validate = false
  94. ret.tooltip = this.$t('system.robot.shared')
  95. return ret
  96. }
  97. return ret
  98. },
  99. () => {
  100. const ret = {
  101. validate: true,
  102. tooltip: null,
  103. }
  104. if (!this.isPower(row)) {
  105. ret.validate = false
  106. ret.tooltip = this.$t('system.robot.shared')
  107. return ret
  108. }
  109. return ret
  110. },
  111. ],
  112. }),
  113. {
  114. label: this.$t('system.text_129'),
  115. permission: 'robots_delete',
  116. action: () => {
  117. this.createDialog('DeleteResDialog', {
  118. vm: this,
  119. data: [row],
  120. columns: this.columns,
  121. title: this.$t('system.text_129'),
  122. name: this.$t('system.robot'),
  123. onManager: this.onManager,
  124. })
  125. },
  126. meta: () => {
  127. const ret = {
  128. validate: true,
  129. tooltip: null,
  130. }
  131. if (!this.isPower(row)) {
  132. ret.validate = false
  133. ret.tooltip = this.$t('system.robot.shared')
  134. return ret
  135. }
  136. return this.$getDeleteResult(row)
  137. },
  138. },
  139. ]
  140. },
  141. },
  142. ]
  143. },
  144. computed: {
  145. ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo']),
  146. },
  147. methods: {
  148. isPower (obj) {
  149. if (this.isAdminMode) return true
  150. if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
  151. return obj.tenant_id === this.userInfo.projectId
  152. },
  153. },
  154. }