index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <base-side-page
  3. @cancel="cancelSidePage"
  4. :title="$t('helm.text_77')"
  5. icon="res-k8s-release"
  6. :res-name="detailData.name"
  7. :actions="params.actions"
  8. :current-tab="params.windowData.currentTab"
  9. :tabs="detailTabs"
  10. :loaded="loaded"
  11. @tab-change="handleTabChange">
  12. <template v-slot:actions>
  13. <actions :options="singleActions" :row="detailData" button-type="link" button-size="small" />
  14. </template>
  15. <component
  16. :is="params.windowData.currentTab"
  17. :res-id="data.id"
  18. :data="detailData"
  19. :onManager="onManager"
  20. resource="releases"
  21. :getParams="getParams"
  22. :responseData="responseData"
  23. :showSearchbox="false"
  24. :showGroupActions="false"
  25. :getResponseData="fetchData" />
  26. </base-side-page>
  27. </template>
  28. <script>
  29. import * as R from 'ramda'
  30. import ColumnsMixin from '../mixins/columns'
  31. import SingleActionsMixin from '../mixins/singleActions'
  32. import Detail from './Detail'
  33. import Statefulset from '@K8S/views/statefulset/components/List'
  34. import Deployment from '@K8S/views/deployment/components/List'
  35. import Secret from '@K8S/views/secret/components/List'
  36. import Configmap from '@K8S/views/configmap/components/List'
  37. import Daemonset from '@K8S/views/daemonset/components/List'
  38. import Clusterrole from '@K8S/views/rbacrole/components/List'
  39. import Clusterrolebinding from '@K8S/views/rbacrolebinding/components/List'
  40. import Serviceaccount from '@K8S/views/service-account/components/List'
  41. import SidePageMixin from '@/mixins/sidePage'
  42. import WindowsMixin from '@/mixins/windows'
  43. import Actions from '@/components/PageList/Actions'
  44. export default {
  45. name: 'K8SReleaseSidePage',
  46. components: {
  47. Actions,
  48. Detail,
  49. Statefulset,
  50. Deployment,
  51. Secret,
  52. Configmap,
  53. Daemonset,
  54. Clusterrole,
  55. Clusterrolebinding,
  56. Serviceaccount,
  57. },
  58. mixins: [SidePageMixin, WindowsMixin, ColumnsMixin, SingleActionsMixin],
  59. computed: {
  60. detailTabs () {
  61. const detailTabs = [{ label: this.$t('helm.text_78'), key: 'detail' }]
  62. if (!this.detailData.resources) return detailTabs
  63. const allResourceArr = [
  64. { label: this.$t('helm.text_79'), key: 'deployment' },
  65. { label: this.$t('helm.text_80'), key: 'statefulset' },
  66. { label: this.$t('helm.text_81'), key: 'configmap' },
  67. { label: this.$t('helm.text_82'), key: 'secret' },
  68. { label: this.$t('helm.text_83'), key: 'daemonset' },
  69. { label: this.$t('helm.text_84'), key: 'clusterrole' },
  70. { label: this.$t('helm.text_85'), key: 'clusterrolebinding' },
  71. { label: this.$t('helm.text_86'), key: 'serviceaccount' },
  72. ]
  73. allResourceArr.forEach(item => {
  74. const resource = item.key
  75. if (R.is(Array, this.detailData.resources[resource])) {
  76. detailTabs.push(item)
  77. }
  78. })
  79. detailTabs.push({ label: this.$t('dictionary.actions'), key: 'event-drawer' })
  80. return detailTabs
  81. },
  82. responseData () {
  83. const data = {
  84. data: [],
  85. }
  86. if (this.detailData.resources && this.params.windowData.currentTab) {
  87. data.data = this.detailData.resources[this.params.windowData.currentTab]
  88. }
  89. return data
  90. },
  91. getParams () {
  92. return {
  93. namespace: this.detailData.namespace,
  94. cluster: this.detailData.clusterID,
  95. }
  96. },
  97. },
  98. watch: {
  99. detailTabs (val) {
  100. if (!val.find(v => v.key === this.params.windowData.currentTab)) {
  101. this.params.windowData.currentTab = this.detailTabs.length ? this.detailTabs[0].key : ''
  102. }
  103. },
  104. },
  105. }
  106. </script>