List.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns"
  5. :noDataText="noDataText"
  6. :group-actions="groupActions"
  7. :single-actions="singleActions">
  8. <template v-slot:group-actions-append>
  9. <cluster-namespace :getParams.sync="list.getParams" @refresh="fetchData" class="ml-3" />
  10. </template>
  11. </page-list>
  12. </template>
  13. <script>
  14. import * as R from 'ramda'
  15. import ColumnsMixin from '../mixins/columns'
  16. import SingleActionsMixin from '../mixins/singleActions'
  17. import ClusterNamespace from '@K8S/sections/ClusterNamespace'
  18. import clusterNamespaceMixin from '@K8S/mixins/clusterNamespace'
  19. import expectStatus from '@/constants/expectStatus'
  20. import WindowsMixin from '@/mixins/windows'
  21. import ListMixin from '@/mixins/list'
  22. import { getCreatedAtFilter } from '@/utils/common/tableFilter'
  23. export default {
  24. name: 'K8SReleaseList',
  25. components: {
  26. ClusterNamespace,
  27. },
  28. mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin, clusterNamespaceMixin],
  29. props: {
  30. id: String,
  31. getParams: {
  32. type: Object,
  33. default: () => ({ type: 'external' }),
  34. },
  35. },
  36. data () {
  37. return {
  38. list: this.$list.createList(this, {
  39. id: this.id,
  40. resource: 'releases',
  41. apiVersion: 'v1',
  42. getParams: this.getParams,
  43. filterOptions: {
  44. name: {
  45. label: this.$t('helm.text_16'),
  46. },
  47. created_at: getCreatedAtFilter(),
  48. },
  49. steadyStatus: {
  50. status: Object.values(expectStatus.release).flat(),
  51. },
  52. itemGetParams: {
  53. cluster: '',
  54. namespace: '',
  55. },
  56. }),
  57. groupActions: [
  58. {
  59. label: this.$t('helm.text_68'),
  60. permission: 'k8s_releases_create',
  61. action: () => {
  62. this.$router.push({
  63. path: '/k8s-chart',
  64. query: {
  65. type: 'external',
  66. },
  67. })
  68. },
  69. meta: () => ({
  70. buttonType: 'primary',
  71. }),
  72. },
  73. {
  74. label: this.$t('helm.text_69'),
  75. permission: 'k8s_releases_delete',
  76. action: () => {
  77. const data = this.list.selectedItems
  78. const requestData = {
  79. cluster: data[0].clusterID,
  80. }
  81. const namespace = data[0].namespace
  82. if (namespace) requestData.namespace = namespace
  83. this.createDialog('DeleteResDialog', {
  84. vm: this,
  85. data,
  86. columns: this.columns,
  87. title: this.$t('helm.text_69'),
  88. name: this.$t('helm.text_4'),
  89. onManager: this.onManager,
  90. requestData,
  91. })
  92. },
  93. meta: () => {
  94. let validate = true
  95. let tooltip = ''
  96. if (this.list.selectedItems.length > 0) {
  97. const namespaces = this.list.selectedItems.map(v => v.namespace)
  98. const unique = Array.from(new Set(namespaces))
  99. if (unique.length > 1) {
  100. validate = false
  101. tooltip = this.$t('helm.text_70')
  102. }
  103. } else {
  104. validate = false
  105. tooltip = this.$t('helm.text_71')
  106. }
  107. return {
  108. validate,
  109. tooltip,
  110. }
  111. },
  112. },
  113. ],
  114. }
  115. },
  116. methods: {
  117. handleOpenSidepage (row) {
  118. this.sidePageTriggerHandle(this, 'K8SReleaseSidePage', {
  119. id: row.id,
  120. resource: 'releases',
  121. getParams: () => {
  122. const params = R.clone(this.list.getParams)
  123. if (row.namespace) {
  124. params.namespace = row.namespace
  125. if (params.all_namespace) delete params.all_namespace
  126. }
  127. return params
  128. },
  129. apiVersion: 'v1',
  130. steadyStatus: {
  131. status: Object.values(expectStatus.k8s_resource).flat(),
  132. },
  133. }, {
  134. list: this.list,
  135. })
  136. },
  137. },
  138. }
  139. </script>