singleActions.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import i18n from '@/locales'
  2. export default {
  3. created () {
  4. this.singleActions = [
  5. {
  6. label: i18n.t('k8s.text_215'),
  7. permission: 'k8s_persistentvolumeclaims_update',
  8. action: async obj => {
  9. const manager = new this.$Manager('persistentvolumeclaims', 'v1')
  10. async function fetchData () {
  11. const { data } = await manager.getSpecific({ id: obj.id, spec: 'rawdata' })
  12. return data
  13. }
  14. const configText = await fetchData()
  15. this.createDialog('K8SEditYamlDialog', {
  16. data: [obj],
  17. manager,
  18. refresh: this.refresh,
  19. configText,
  20. })
  21. },
  22. },
  23. {
  24. label: i18n.t('k8s.text_201'),
  25. permission: 'k8s_persistentvolumeclaims_delete',
  26. action: (obj) => {
  27. const requestParams = {
  28. cluster: obj.clusterID,
  29. }
  30. if (obj.namespace) {
  31. requestParams.namespace = obj.namespace
  32. }
  33. this.createDialog('DeleteResDialog', {
  34. data: [obj],
  35. columns: this.columns,
  36. title: i18n.t('k8s.text_201'),
  37. name: i18n.t('k8s.text_10'),
  38. onManager: this.onManager,
  39. requestParams,
  40. success: () => {
  41. this.destroySidePages()
  42. },
  43. })
  44. },
  45. meta: (obj) => {
  46. let validate = true
  47. let tooltip = ''
  48. if (obj.mountedBy && obj.mountedBy.length > 0) {
  49. validate = false
  50. tooltip = i18n.t('k8s.text_304')
  51. }
  52. return {
  53. validate,
  54. tooltip,
  55. }
  56. },
  57. },
  58. ]
  59. },
  60. }