singleActions.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import { disableDeleteAction } from '@/utils/common/tableActions'
  2. import { checkSecgroup } from '@DB/views/utils'
  3. import { HYPERVISORS_MAP } from '@/constants'
  4. import i18n from '@/locales'
  5. export default {
  6. created () {
  7. this.singleActions = [
  8. {
  9. label: i18n.t('db.text_69'),
  10. permission: 'rds_dbinstances_perform_syncstatus',
  11. action: (obj) => {
  12. this.onManager('performAction', {
  13. steadyStatus: 'running',
  14. id: obj.id,
  15. managerArgs: {
  16. action: 'sync-status',
  17. },
  18. }).then(ret => {
  19. if (ret.status === 200) {
  20. this.$message.success(i18n.t('db.text_149'))
  21. }
  22. })
  23. },
  24. },
  25. {
  26. label: i18n.t('db.text_155'),
  27. actions: (obj) => {
  28. const isRunning = obj.status.toLowerCase() === 'running'
  29. const notRunninTip = !isRunning ? i18n.t('db.text_156') : null
  30. return [
  31. {
  32. label: i18n.t('db.text_70'),
  33. permission: 'rds_dbinstances_perform_reboot',
  34. action: () => {
  35. this.createDialog('RDSRestartdialog', {
  36. title: i18n.t('db.text_70'),
  37. data: [obj],
  38. columns: this.columns,
  39. onManager: this.onManager,
  40. refresh: this.refresh,
  41. })
  42. },
  43. meta: () => {
  44. const ret = {
  45. validate: isRunning,
  46. tooltip: notRunninTip,
  47. }
  48. // aws 和 azure禁用
  49. if ((obj.brand === HYPERVISORS_MAP.aws.brand || obj.brand === HYPERVISORS_MAP.azure.brand) && ret.validate) {
  50. ret.validate = false
  51. ret.tooltip = this.$t('db.text_384', [obj.brand])
  52. }
  53. return ret
  54. },
  55. },
  56. {
  57. label: i18n.t('db.text_159'),
  58. permission: 'rds_dbinstances_perform_change_config',
  59. action: () => {
  60. this.createDialog('RSDSetConfig', {
  61. title: i18n.t('db.text_159'),
  62. data: [obj],
  63. columns: this.columns,
  64. onManager: this.onManager,
  65. refresh: this.refresh,
  66. })
  67. },
  68. meta: () => {
  69. const ret = {
  70. validate: isRunning,
  71. tooltip: notRunninTip,
  72. }
  73. // aws 和 azure禁用
  74. if ((obj.brand === HYPERVISORS_MAP.aws.brand || obj.brand === HYPERVISORS_MAP.azure.brand) && ret.validate) {
  75. ret.validate = false
  76. ret.tooltip = this.$t('db.text_384', [obj.brand])
  77. }
  78. return ret
  79. },
  80. },
  81. {
  82. label: this.$t('compute.text_1116'),
  83. permission: 'server_perform_add_secgroup',
  84. action: () => {
  85. this.createDialog('SetSecgroupDialog', {
  86. vm: this,
  87. data: [obj],
  88. name: this.$t('dictionary.dbinstances'),
  89. resource: 'dbinstances_id',
  90. columns: this.columns,
  91. onManager: this.onManager,
  92. refresh: this.refresh,
  93. })
  94. },
  95. meta: () => {
  96. const ret = checkSecgroup(obj, 'rds')
  97. // aws 和 azure禁用
  98. if ((obj.brand === HYPERVISORS_MAP.aws.brand || obj.brand === HYPERVISORS_MAP.azure.brand) && ret.validate) {
  99. ret.validate = false
  100. ret.tooltip = this.$t('db.text_384', [obj.brand])
  101. }
  102. return ret
  103. },
  104. },
  105. {
  106. label: i18n.t('db.text_160', [i18n.t('dictionary.project')]),
  107. permission: 'rds_dbinstances_perform_change_owner',
  108. action: () => {
  109. this.createDialog('ChangeOwenrDialog', {
  110. title: i18n.t('db.text_160', [i18n.t('dictionary.project')]),
  111. data: [obj],
  112. columns: this.columns,
  113. onManager: this.onManager,
  114. refresh: this.refresh,
  115. name: this.$t('dictionary.dbinstances'),
  116. resource: 'dbinstances',
  117. })
  118. },
  119. },
  120. {
  121. label: i18n.t('db.text_71'),
  122. permission: 'rds_dbinstances_perform_postpaid_expire',
  123. action: () => {
  124. this.createDialog('SetDurationDialog', {
  125. data: [obj],
  126. columns: this.columns,
  127. alert: this.$t('db.text_391'),
  128. onManager: this.onManager,
  129. refresh: this.refresh,
  130. name: this.$t('dictionary.dbinstances'),
  131. })
  132. },
  133. meta: () => {
  134. const ret = {
  135. validate: false,
  136. tooltip: null,
  137. }
  138. if (obj.billing_type === 'prepaid') {
  139. ret.tooltip = i18n.t('db.text_72')
  140. return ret
  141. }
  142. ret.validate = true
  143. return ret
  144. },
  145. },
  146. {
  147. label: i18n.t('db.text_157'),
  148. permission: 'rds_dbinstances_perform_renew',
  149. action: () => {
  150. this.createDialog('RedisRenewDialog', {
  151. title: i18n.t('db.text_157'),
  152. name: i18n.t('dictionary.dbinstances'),
  153. alert: this.$t('network.text_765'),
  154. data: [obj],
  155. columns: this.columns,
  156. onManager: this.onManager,
  157. refresh: this.refresh,
  158. })
  159. },
  160. meta: () => {
  161. const ret = {
  162. validate: false,
  163. tooltip: null,
  164. }
  165. if (obj.billing_type !== 'prepaid') {
  166. ret.tooltip = i18n.t('db.text_158')
  167. return ret
  168. }
  169. ret.validate = true
  170. return ret
  171. },
  172. },
  173. {
  174. label: i18n.t('db.text_351'),
  175. permission: 'rds_dbinstances_perform_set_auto_renew',
  176. action: () => {
  177. this.createDialog('AutoRenewDialog', {
  178. name: i18n.t('dictionary.dbinstances'),
  179. data: [obj],
  180. alert: this.$t('network.text_766'),
  181. columns: this.columns,
  182. onManager: this.onManager,
  183. refresh: this.refresh,
  184. })
  185. },
  186. meta: () => {
  187. const ret = {
  188. validate: false,
  189. tooltip: null,
  190. }
  191. if (obj.billing_type !== 'prepaid') {
  192. ret.tooltip = i18n.t('db.text_158')
  193. return ret
  194. }
  195. ret.validate = true
  196. return ret
  197. },
  198. },
  199. disableDeleteAction(Object.assign(this, { permission: 'rds_dbinstances_update' }), {
  200. name: this.$t('dictionary.dbinstances'),
  201. }),
  202. {
  203. label: i18n.t('db.text_42'),
  204. permission: 'rds_dbinstances_delete',
  205. action: () => {
  206. this.createDialog('DeleteResDialog', {
  207. vm: this,
  208. title: i18n.t('db.text_42'),
  209. data: [obj],
  210. columns: this.columns,
  211. onManager: this.onManager,
  212. refresh: this.refresh,
  213. name: this.$t('dictionary.dbinstances'),
  214. })
  215. },
  216. meta: () => this.$getDeleteResult(obj),
  217. },
  218. ]
  219. },
  220. },
  221. ]
  222. },
  223. }