singleActions.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import { getEnabledSwitchActions } from '@/utils/common/tableActions'
  2. import i18n from '@/locales'
  3. export default {
  4. created () {
  5. this.singleActions = [
  6. {
  7. label: this.$t('compute.text_1028_1'),
  8. permission: 'instancegroups_perform_bind_guests',
  9. action: (obj) => {
  10. this.sidePageTriggerHandle(this, 'InstanceGroupSidePage', {
  11. id: obj.id,
  12. resource: 'instancegroups',
  13. }, { tab: 'associated-instances' })
  14. },
  15. meta: (obj) => ({
  16. validate: obj.enabled,
  17. tooltip: !obj.enabled ? i18n.t('compute.text_717') : null,
  18. }),
  19. },
  20. {
  21. label: i18n.t('compute.text_352'),
  22. actions: obj => {
  23. return [
  24. ...getEnabledSwitchActions(this, obj, ['instancegroups_perform_enable', 'instancegroups_perform_disable']),
  25. {
  26. label: this.$t('compute.create_vip'),
  27. permission: 'instancegroups_perform_attach_network',
  28. action: () => {
  29. this.createDialog('InstanceGroupAddVipNetworkDialog', {
  30. title: this.$t('compute.create_vip'),
  31. data: [obj],
  32. columns: this.columns,
  33. resId: obj.Id,
  34. refresh: this.refresh,
  35. total: obj.vips && obj.vips.length,
  36. })
  37. },
  38. meta: () => {
  39. const ret = {
  40. validate: true,
  41. }
  42. if (!obj.network_id) {
  43. ret.validate = false
  44. ret.tooltip = this.$t('compute.instance_group_no_network_id')
  45. } else if (obj.vips && obj.vips.length >= 1) {
  46. ret.validate = false
  47. ret.tooltip = this.$t('compute.too_many_instance_group_vip')
  48. }
  49. return ret
  50. },
  51. // hidden: this.$isScopedPolicyMenuHidden('vminstance_hidden_menus.server_add_network_card'),
  52. },
  53. {
  54. label: i18n.t('compute.text_1179'),
  55. permission: 'instancegroup_perform_associate_eip',
  56. action: () => {
  57. this.createDialog('InstanceGroupBindEipDialog', {
  58. data: [obj],
  59. columns: this.columns,
  60. refresh: this.refresh,
  61. onManager: this.onManager,
  62. })
  63. },
  64. meta: () => {
  65. const ret = {
  66. validate: true,
  67. }
  68. if (!obj.vips || obj.vips.length === 0) {
  69. ret.validate = false
  70. ret.tooltip = this.$t('compute.prompt_empty_instance_group_vip')
  71. } else if (obj.vip_eip) {
  72. ret.validate = false
  73. ret.tooltip = this.$t('compute.prompt_already_associate_eip')
  74. }
  75. return ret
  76. },
  77. // hidden: () => !(hasSetupKey(['onestack', 'onecloud', 'public', 'openstack', 'dstack', 'zstack', 'apsara', 'cloudpods', 'hcso'])) || this.$isScopedPolicyMenuHidden('vminstance_hidden_menus.server_perform_bind_elastic_public_ip'),
  78. },
  79. // 解绑弹性公网IP
  80. {
  81. label: i18n.t('compute.text_1264'),
  82. permission: 'instancegroup_perform_dissociate_eip',
  83. action: () => {
  84. this.createDialog('InstanceGroupUnbindEipDialog', {
  85. data: [obj],
  86. columns: this.columns,
  87. onManager: this.onManager,
  88. refresh: this.refresh,
  89. })
  90. },
  91. meta: () => {
  92. const ret = {
  93. validate: true,
  94. }
  95. if (!obj.vip_eip) {
  96. ret.validate = false
  97. ret.tooltip = this.$t('compute.prompt_no_associate_eip')
  98. }
  99. return ret
  100. },
  101. // hidden: () => !(hasSetupKey(['onestack', 'onecloud'])) || this.$isScopedPolicyMenuHidden('vminstance_hidden_menus.instancegroup_perform_unbind_elastic_public_ip'),
  102. },
  103. {
  104. label: i18n.t('compute.perform_delete'),
  105. permission: 'instancegroups_delete',
  106. action: () => {
  107. this.createDialog('DeleteResDialog', {
  108. vm: this,
  109. data: [obj],
  110. columns: this.columns,
  111. title: this.$t('compute.text_700', [this.$t('dictionary.instancegroup')]),
  112. name: this.$t('dictionary.instancegroup'),
  113. onManager: this.onManager,
  114. })
  115. },
  116. meta: () => this.$getDeleteResult(obj),
  117. },
  118. ]
  119. },
  120. },
  121. ]
  122. },
  123. }