singleActions.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { mapGetters } from 'vuex'
  2. import { getDomainChangeOwnerAction, getSetPublicAction } from '@/utils/common/tableActions'
  3. import { getDisabledProvidersActionMeta } from '@/utils/common/hypervisor'
  4. import i18n from '@/locales'
  5. export default {
  6. created () {
  7. this.singleActions = [
  8. {
  9. label: i18n.t('network.text_201'),
  10. permission: 'vpcs_perform_syncstatus',
  11. action: obj => {
  12. this.onManager('performAction', {
  13. steadyStatus: ['running', 'ready'],
  14. id: obj.id,
  15. managerArgs: {
  16. action: 'syncstatus',
  17. },
  18. })
  19. },
  20. meta: (obj) => {
  21. if (!this.isPower(obj)) {
  22. return {
  23. validate: false,
  24. tooltip: i18n.t('network.text_627'),
  25. }
  26. }
  27. if (obj.brand && obj.brand.toLowerCase() === 'onecloud') {
  28. return {
  29. validate: false,
  30. tooltip: i18n.t('network.text_652'),
  31. }
  32. }
  33. return {
  34. validate: true,
  35. }
  36. },
  37. },
  38. {
  39. label: i18n.t('network.text_129'),
  40. actions: obj => {
  41. return [
  42. getDomainChangeOwnerAction(this, {
  43. name: this.$t('dictionary.vpc'),
  44. resource: 'vpcs',
  45. }, {
  46. permission: 'vpcs_perform_change_owner',
  47. extraMeta: obj => {
  48. return getDisabledProvidersActionMeta({
  49. row: obj,
  50. disabledProviders: ['BingoCloud'],
  51. })
  52. },
  53. }),
  54. getSetPublicAction(this, {
  55. name: this.$t('dictionary.vpc'),
  56. scope: 'domain',
  57. resource: 'vpcs',
  58. }, {
  59. permission: 'vpcs_perform_public',
  60. extraMeta: obj => {
  61. return getDisabledProvidersActionMeta({
  62. row: obj,
  63. disabledProviders: ['BingoCloud'],
  64. })
  65. },
  66. }),
  67. {
  68. label: i18n.t('network.text_131'),
  69. permission: 'vpcs_delete',
  70. action: () => {
  71. this.createDialog('DeleteResDialog', {
  72. vm: this,
  73. title: i18n.t('network.text_131'),
  74. name: this.$t('dictionary.vpc'),
  75. data: [obj],
  76. columns: this.columns,
  77. onManager: this.onManager,
  78. alert: obj.provider === 'Aws' ? this.$t('network.vpc_aws_delete_alert') : null,
  79. })
  80. },
  81. meta: () => this.$getDeleteResult(obj),
  82. extraMeta: obj => {
  83. return getDisabledProvidersActionMeta({
  84. row: obj,
  85. disabledProviders: ['BingoCloud', 'SangFor'],
  86. })
  87. },
  88. },
  89. ]
  90. },
  91. },
  92. ]
  93. },
  94. computed: {
  95. ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo']),
  96. },
  97. methods: {
  98. isPower (obj) {
  99. if (this.isAdminMode) return true
  100. if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
  101. return obj.tenant_id === this.userInfo.projectId
  102. },
  103. },
  104. }