singleActions.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_246'),
  8. permission: 'idps_update',
  9. action: (obj) => {
  10. this.jumpTo(`update/${obj.id}`)
  11. },
  12. meta: (obj) => {
  13. const ret = {
  14. validate: false,
  15. tooltip: null,
  16. }
  17. if (obj.driver === 'sql') {
  18. ret.tooltip = i18n.t('system.text_247', [i18n.t('dictionary.identity_provider')])
  19. return ret
  20. }
  21. if (obj.enabled) {
  22. ret.tooltip = i18n.t('system.text_249')
  23. return ret
  24. }
  25. ret.validate = true
  26. return ret
  27. },
  28. },
  29. {
  30. label: i18n.t('system.text_153'),
  31. actions: obj => {
  32. return [
  33. // {
  34. // label: i18n.t('common_551'),
  35. // action: async (obj) => {
  36. // this.createDialog('IdpBaseConfigDialog', {
  37. // data: [obj],
  38. // title: i18n.t('common_551'),
  39. // columns: this.columns,
  40. // })
  41. // },
  42. // meta: () => {
  43. // if (obj.driver === 'ldap' || obj.driver === 'sql') {
  44. // return {
  45. // validate: false,
  46. // tooltip: i18n.t('common_552'),
  47. // }
  48. // }
  49. // return {
  50. // validate: true,
  51. // }
  52. // },
  53. // },
  54. ...getEnabledSwitchActions(this, undefined, ['idps_perform_enable', 'idps_perform_disable']),
  55. {
  56. label: i18n.t('system.text_250'),
  57. permission: 'idps_perform_sync',
  58. action: () => {
  59. this.onManager('performAction', {
  60. id: obj.id,
  61. steadyStatus: {
  62. sync_status: ['idle'],
  63. },
  64. managerArgs: {
  65. action: 'sync',
  66. },
  67. })
  68. },
  69. meta: () => {
  70. const ret = {
  71. validate: false,
  72. tooltip: null,
  73. }
  74. if (obj.driver === 'sql') {
  75. ret.tooltip = i18n.t('system.text_251', [i18n.t('dictionary.identity_provider')])
  76. return ret
  77. }
  78. if (!obj.enabled) {
  79. ret.tooltip = i18n.t('system.text_252')
  80. return ret
  81. }
  82. ret.validate = true
  83. return ret
  84. },
  85. },
  86. {
  87. label: i18n.t('system.text_129'),
  88. permission: 'idps_delete',
  89. action: () => {
  90. this.createDialog('DeleteResDialog', {
  91. vm: this,
  92. data: [obj],
  93. columns: this.columns,
  94. title: i18n.t('system.text_129'),
  95. onManager: this.onManager,
  96. name: this.$t('dictionary.identity_provider'),
  97. alertProps: {
  98. message: i18n.t('system.text_253'),
  99. type: 'error',
  100. },
  101. })
  102. },
  103. meta: () => this.$getDeleteResult(obj),
  104. },
  105. ]
  106. },
  107. },
  108. ]
  109. },
  110. methods: {
  111. downloadXml (idp, metadataStr) {
  112. console.log(metadataStr)
  113. const eleLink = document.createElement('a')
  114. eleLink.download = `${idp.name}.xml`
  115. const blob = new Blob([metadataStr])
  116. eleLink.href = URL.createObjectURL(blob)
  117. document.body.appendChild(eleLink)
  118. eleLink.click()
  119. },
  120. },
  121. }