singleActions.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. export default {
  2. computed: {
  3. commonMeta () {
  4. const rdsItem = this.params.rdsItem || this.data
  5. const isRunning = rdsItem.status === 'running'
  6. const isHuawei = rdsItem.brand === 'Huawei'
  7. const isAliyun = rdsItem.brand === 'Aliyun'
  8. const isGoogle = rdsItem.brand === 'Google'
  9. let tooltip = ''
  10. if (!isRunning) {
  11. tooltip = this.$t('db.text_198')
  12. }
  13. if (!isRunning) {
  14. tooltip = this.$t('db.text_198')
  15. }
  16. return {
  17. isRunning,
  18. isHuawei,
  19. isAliyun,
  20. isGoogle,
  21. tooltip,
  22. validate: isRunning,
  23. }
  24. },
  25. },
  26. created () {
  27. this.singleActions = [
  28. {
  29. label: this.$t('db.text_201'),
  30. permission: 'rds_dbinstanceaccounts_perform_reset_password',
  31. action: (obj) => {
  32. this.createDialog('RedisAccountLisResetPwdDialog', {
  33. data: [obj],
  34. name: this.$t('dictionary.dbinstances'),
  35. list: this.list,
  36. columns: this.columns,
  37. })
  38. },
  39. meta: () => {
  40. if (this.commonMeta.isHuawei) {
  41. return {
  42. validate: false,
  43. tooltip: this.$t('db.text_202'),
  44. }
  45. }
  46. return this.commonMeta
  47. },
  48. },
  49. {
  50. label: this.$t('db.text_203'),
  51. permission: 'rds_dbinstanceaccounts_perform_set_privileges',
  52. action: (obj) => {
  53. this.createDialog('RDSAccountUpdatePrivilegeDialog', {
  54. title: this.$t('db.text_203'),
  55. initialValues: {
  56. account_privilege: obj.account_privilege,
  57. host: obj.host,
  58. },
  59. data: [obj],
  60. list: this.list,
  61. columns: this.columns,
  62. rdsItem: this.data,
  63. })
  64. },
  65. meta: (obj) => {
  66. const { isHuawei, isGoogle } = this.commonMeta
  67. if (isHuawei && obj.name === 'root') {
  68. return {
  69. validate: false,
  70. tooltip: this.$t('db.text_204'),
  71. }
  72. }
  73. if (isGoogle) {
  74. return {
  75. validate: false,
  76. tooltip: this.$t('db.text_205'),
  77. }
  78. }
  79. return {
  80. validate: true,
  81. }
  82. },
  83. },
  84. {
  85. label: this.$t('db.text_42'),
  86. permission: 'rds_dbinstanceaccounts_delete',
  87. action: (obj) => {
  88. this.createDialog('DeleteResDialog', {
  89. title: this.$t('db.text_42'),
  90. name: this.$t('db.text_188'),
  91. data: [obj],
  92. onManager: this.onManager,
  93. columns: this.columns,
  94. refresh: this.refresh,
  95. })
  96. },
  97. meta: (obj) => {
  98. const { tooltip, isAliyun } = this.commonMeta
  99. return {
  100. validate: obj.name !== 'root' || (!tooltip && isAliyun),
  101. tooltip: obj.name === 'root' ? this.$t('db.text_350') : tooltip,
  102. }
  103. },
  104. },
  105. ]
  106. },
  107. }