singleActions.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { mapGetters } from 'vuex'
  2. import i18n from '@/locales'
  3. export default {
  4. created () {
  5. this.singleActions = [
  6. {
  7. label: this.$t('network.text_349'),
  8. permission: 'proxy_endpoints_update',
  9. action: (obj) => {
  10. this.createDialog('UpdateSSHPortDialog', {
  11. vm: this,
  12. data: [obj],
  13. columns: this.columns,
  14. title: this.$t('network.text_349'),
  15. name: this.$t('network.ssh-proxy.endpoints'),
  16. onManager: this.onManager,
  17. })
  18. },
  19. },
  20. {
  21. label: i18n.t('network.text_131'),
  22. permission: 'sshproxy_endpoint_delete',
  23. action: obj => {
  24. this.createDialog('DeleteResDialog', {
  25. vm: this,
  26. data: [obj],
  27. columns: this.columns,
  28. title: i18n.t('network.text_131'),
  29. name: this.$t('network.ssh-proxy.endpoints'),
  30. onManager: this.onManager,
  31. })
  32. },
  33. meta: obj => {
  34. if (!this.isPower(obj)) {
  35. return {
  36. validate: false,
  37. tooltip: i18n.t('network.text_627'),
  38. }
  39. }
  40. if (!this.$getDeleteResult(obj).validate) {
  41. return {
  42. validate: false,
  43. tooltip: this.$getDeleteResult(obj).tooltip,
  44. }
  45. }
  46. return {
  47. validate: true,
  48. tooltip: '',
  49. }
  50. },
  51. },
  52. ]
  53. },
  54. computed: {
  55. ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo']),
  56. },
  57. methods: {
  58. isPower (obj) {
  59. if (this.isAdminMode) return true
  60. if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
  61. return obj.tenant_id === this.userInfo.projectId
  62. },
  63. },
  64. }