singleActions.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import { getEnabledSwitchActions } from '@/utils/common/tableActions'
  2. import i18n from '@/locales'
  3. export default {
  4. created () {
  5. this.singleActions = [
  6. {
  7. label: i18n.t('system.text_479'),
  8. permission: 'users_update',
  9. action: row => {
  10. this.createDialog('UserUpdateDialog', {
  11. data: [row],
  12. columns: this.columns,
  13. onManager: this.onManager,
  14. })
  15. },
  16. },
  17. {
  18. label: i18n.t('system.text_153'),
  19. actions: row => {
  20. return [
  21. ...getEnabledSwitchActions(this, row, ['users_perform_enable', 'users_perform_disable'], {
  22. actions: [
  23. () => {
  24. this.onManager('performAction', {
  25. id: row.id,
  26. managerArgs: {
  27. action: 'enable',
  28. },
  29. })
  30. },
  31. () => {
  32. this.onManager('performAction', {
  33. id: row.id,
  34. managerArgs: {
  35. action: 'disable',
  36. },
  37. })
  38. },
  39. ],
  40. }),
  41. {
  42. label: i18n.t('compute.text_276'),
  43. permission: 'users_update',
  44. action: () => {
  45. this.createDialog('UserUpdatePasswordDialog', {
  46. data: [row],
  47. columns: this.columns,
  48. onManager: this.onManager,
  49. })
  50. },
  51. meta: () => {
  52. const { idps } = row
  53. if (idps && idps.length > 0) {
  54. const [{ idp_driver }] = idps
  55. if (idp_driver === 'ldap') {
  56. return {
  57. validate: false,
  58. tooltip: this.$t('common_603'),
  59. }
  60. }
  61. }
  62. if (!row.is_local) return { validate: false }
  63. return {
  64. validate: true,
  65. }
  66. },
  67. },
  68. {
  69. label: i18n.t('common_493'),
  70. action: () => {
  71. this.handleOpenSidepage(row, 'projects')
  72. },
  73. },
  74. {
  75. label: `${i18n.t('common.reset')} MFA`,
  76. action: () => {
  77. this.createDialog('ResetMFADialog', {
  78. data: [row],
  79. columns: this.columns,
  80. onManager: this.onManager,
  81. })
  82. },
  83. },
  84. {
  85. label: i18n.t('system.text_129'),
  86. permission: 'users_delete',
  87. action: () => {
  88. this.createDialog('DeleteResDialog', {
  89. vm: this,
  90. data: [row],
  91. columns: this.columns,
  92. title: i18n.t('system.text_480'),
  93. name: this.$t('dictionary.user'),
  94. onManager: this.onManager,
  95. alert: {
  96. message: i18n.t('system.text_513'),
  97. type: 'error',
  98. },
  99. refresh: this.refresh,
  100. })
  101. },
  102. meta: () => this.$getDeleteResult(row),
  103. },
  104. ]
  105. },
  106. },
  107. ]
  108. },
  109. }