Secgroup.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <secgroup-list
  3. ref="secgroupList"
  4. :hiddenActions="['openSecgroupSidepageTab']"
  5. :hiddenColumns="['guest_cnt']"
  6. :hiddenSidepageTabs="['associated-instances']"
  7. :id="id"
  8. :getParams="getParams"
  9. :show-create-action="false"
  10. :customSingleActions="customSingleActions"
  11. frontGroupMethods="coverage"
  12. :frontGroupActions="frontGroupActions" />
  13. </template>
  14. <script>
  15. import SecgroupList from '@Compute/views/secgroup/components/List'
  16. import WindowsMixin from '@/mixins/windows'
  17. import { SECGROUP_LIST_FOR_VMINSTANCE_SIDEPAGE_REFRESH } from '@/constants/event-bus'
  18. export default {
  19. name: 'SecgroupListForVminstanceSidepage',
  20. components: {
  21. SecgroupList,
  22. },
  23. mixins: [WindowsMixin],
  24. props: {
  25. id: String,
  26. data: Object,
  27. getParams: [Function, Object],
  28. serverColumns: {
  29. type: Array,
  30. default () {
  31. return []
  32. },
  33. },
  34. },
  35. data () {
  36. const that = this
  37. return {
  38. frontGroupActions: function () {
  39. return [
  40. {
  41. label: this.$t('compute.text_1116'),
  42. action: () => {
  43. this.createDialog('VmSetSecgroupDialog', {
  44. vm: this,
  45. data: [that.data],
  46. columns: that.serverColumns,
  47. manager: new that.$Manager('servers'),
  48. })
  49. },
  50. },
  51. {
  52. label: this.$t('common.remove'),
  53. action: () => {
  54. this.createDialog('VmSidepageRevokeSecgroupDialog', {
  55. detailData: that.data,
  56. data: this.list.selectedItems,
  57. onManager: this.onManager,
  58. refresh: () => {
  59. this.$bus.$emit(SECGROUP_LIST_FOR_VMINSTANCE_SIDEPAGE_REFRESH)
  60. },
  61. })
  62. },
  63. meta: () => {
  64. const ret = { validate: true }
  65. if (!this.list.selectedItems?.length) {
  66. ret.validate = false
  67. return ret
  68. }
  69. if (this.list.selectedItems.length === this.list.total) {
  70. ret.validate = false
  71. ret.tooltip = this.$t('compute.secgroup.remove_secgroup.group_actions.tooltip')
  72. return ret
  73. }
  74. return ret
  75. },
  76. },
  77. ]
  78. },
  79. customSingleActions: [
  80. {
  81. label: this.$t('common.remove'),
  82. action: (obj) => {
  83. this.createDialog('VmSidepageRevokeSecgroupDialog', {
  84. detailData: this.data,
  85. data: [obj],
  86. onManager: this.onManager,
  87. refresh: () => {
  88. this.$bus.$emit(SECGROUP_LIST_FOR_VMINSTANCE_SIDEPAGE_REFRESH)
  89. },
  90. })
  91. },
  92. meta: () => {
  93. const ret = { validate: true }
  94. if (this.$refs.secgroupList?.list?.total === 1) {
  95. ret.validate = false
  96. ret.tooltip = this.$t('compute.secgroup.remove_secgroup.single_actions.tooltip')
  97. return ret
  98. }
  99. return ret
  100. },
  101. },
  102. ],
  103. }
  104. },
  105. created () {
  106. this.$bus.$on(SECGROUP_LIST_FOR_VMINSTANCE_SIDEPAGE_REFRESH, () => {
  107. const secgroupListVm = this.$refs.secgroupList
  108. secgroupListVm && secgroupListVm.refresh()
  109. })
  110. },
  111. }
  112. </script>