singleActions.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import { mapGetters } from 'vuex'
  2. export default {
  3. computed: {
  4. ...mapGetters(['isAdminMode', 'userInfo']),
  5. },
  6. created () {
  7. this.singleActions = [
  8. {
  9. label: this.$t('common.text00043'),
  10. permission: 'clouduser_perform_syncstatus',
  11. action: (obj) => {
  12. this.onManager('performAction', {
  13. id: obj.id,
  14. steadyStatus: ['available'],
  15. managerArgs: {
  16. action: 'syncstatus',
  17. },
  18. })
  19. },
  20. meta: () => {
  21. return {
  22. validate: this.isNormalStatus() && this.isOwner(),
  23. }
  24. },
  25. },
  26. {
  27. label: this.$t('common.more'),
  28. actions: obj => {
  29. return [
  30. {
  31. label: this.$t('cloudenv.text_529'),
  32. permission: 'clouduser_perform_set_password',
  33. action: () => {
  34. this.createDialog('ClouduserSetPasswordDialog', {
  35. data: [obj],
  36. onManager: this.onManager,
  37. columns: this.columns,
  38. cloudaccount: this.cloudaccount,
  39. })
  40. },
  41. },
  42. {
  43. label: this.$t('iam.enable_console_login'),
  44. permission: 'clouduser_perform_enable_console_login',
  45. action: (obj) => {
  46. this.createDialog('ClouduserSetConsoleLoginDialog', {
  47. vm: this,
  48. data: [obj],
  49. columns: this.columns,
  50. title: this.$t('iam.enable_console_login'),
  51. name: this.$t('dictionary.clouduser'),
  52. onManager: this.onManager,
  53. action: 'enable-console-login',
  54. })
  55. },
  56. meta: (obj) => {
  57. return {
  58. validate: !obj.is_console_login,
  59. }
  60. },
  61. hidden: () => !this.$appConfig.isPrivate,
  62. },
  63. {
  64. label: this.$t('iam.disable_console_login'),
  65. permission: 'clouduser_perform_disable_console_login',
  66. action: (obj) => {
  67. this.createDialog('ClouduserSetConsoleLoginDialog', {
  68. vm: this,
  69. data: [obj],
  70. columns: this.columns,
  71. title: this.$t('iam.disable_console_login'),
  72. name: this.$t('dictionary.clouduser'),
  73. onManager: this.onManager,
  74. action: 'disable-console-login',
  75. })
  76. },
  77. meta: (obj) => {
  78. return {
  79. validate: obj.is_console_login,
  80. }
  81. },
  82. hidden: () => !this.$appConfig.isPrivate,
  83. },
  84. {
  85. label: this.$t('cloudenv.clouduser_list_a2'),
  86. permission: 'clouduser_perform_change_owner',
  87. action: () => {
  88. this.createDialog('ClouduserChangeOwnerDialog', {
  89. data: [obj],
  90. onManager: this.onManager,
  91. columns: this.columns,
  92. cloudaccount: this.cloudaccount,
  93. })
  94. },
  95. },
  96. {
  97. label: this.$t('cloudenv.clouduser_list_a1'),
  98. permission: 'clouduser_perform_set_groups',
  99. action: () => {
  100. this.createDialog('ClouduserSetGroupsDialog', {
  101. data: [obj],
  102. onManager: this.onManager,
  103. columns: this.columns,
  104. cloudaccount: this.cloudaccount,
  105. success: () => {
  106. this.$bus.$emit('CloudgroupListForClouduserSidepageRefresh')
  107. },
  108. })
  109. },
  110. },
  111. {
  112. label: this.$t('common.delete'),
  113. permission: 'clouduser_delete',
  114. action: () => {
  115. this.createDialog('DeleteResDialog', {
  116. vm: this,
  117. data: [obj],
  118. columns: this.columns,
  119. title: this.$t('common.delete'),
  120. name: this.$t('dictionary.clouduser'),
  121. onManager: this.onManager,
  122. })
  123. },
  124. meta: () => this.$getDeleteResult(obj),
  125. },
  126. ]
  127. },
  128. meta: () => {
  129. return {
  130. validate: this.isNormalStatus() && this.isOwner(),
  131. }
  132. },
  133. },
  134. ]
  135. },
  136. methods: {
  137. isNormalStatus () {
  138. // let normalStatus = false
  139. // if (
  140. // this.cloudaccount &&
  141. // this.cloudaccount.enabled &&
  142. // this.cloudaccount.status === 'connected'
  143. // ) {
  144. // normalStatus = true
  145. // }
  146. // return normalStatus
  147. return true
  148. },
  149. isOwner () {
  150. return this.isAdminMode || (this.cloudaccount && this.cloudaccount.domain_id === this.userInfo.projectDomainId)
  151. },
  152. },
  153. }