VmSecgroup.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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: 'VmSecgroupListForVminstanceSidepage',
  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('common.remove'),
  42. action: () => {
  43. this.createDialog('VmSidepageRevokeSecgroupDialog', {
  44. detailData: that.data,
  45. data: this.list.selectedItems,
  46. onManager: this.onManager,
  47. refresh: () => {
  48. this.$bus.$emit(SECGROUP_LIST_FOR_VMINSTANCE_SIDEPAGE_REFRESH)
  49. },
  50. })
  51. },
  52. meta: () => {
  53. const ret = { validate: true }
  54. if (!this.list.selectedItems?.length) {
  55. ret.validate = false
  56. return ret
  57. }
  58. if (this.list.selectedItems.length === this.list.total) {
  59. ret.validate = false
  60. ret.tooltip = this.$t('compute.secgroup.remove_secgroup.group_actions.tooltip')
  61. return ret
  62. }
  63. return ret
  64. },
  65. },
  66. ]
  67. },
  68. customSingleActions: [
  69. {
  70. label: this.$t('common.remove'),
  71. action: (obj) => {
  72. this.createDialog('VmSidepageRevokeSecgroupDialog', {
  73. detailData: this.data,
  74. data: [obj],
  75. onManager: this.onManager,
  76. refresh: () => {
  77. this.$bus.$emit(SECGROUP_LIST_FOR_VMINSTANCE_SIDEPAGE_REFRESH)
  78. },
  79. })
  80. },
  81. meta: () => {
  82. const ret = { validate: true }
  83. if (this.$refs.secgroupList?.list?.total === 1) {
  84. ret.validate = false
  85. ret.tooltip = this.$t('compute.secgroup.remove_secgroup.single_actions.tooltip')
  86. return ret
  87. }
  88. return ret
  89. },
  90. },
  91. ],
  92. }
  93. },
  94. created () {
  95. this.$bus.$on(SECGROUP_LIST_FOR_VMINSTANCE_SIDEPAGE_REFRESH, () => {
  96. const secgroupListVm = this.$refs.secgroupList
  97. secgroupListVm && secgroupListVm.refresh()
  98. })
  99. },
  100. }
  101. </script>