| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <template>
- <page-list
- :list="list"
- :columns="columns"
- :noDataText="noDataText"
- :group-actions="groupActions"
- :single-actions="singleActions"
- :showSearchbox="showSearchbox"
- :showGroupActions="showGroupActions">
- <template v-slot:group-actions-append>
- <cluster-namespace :getParams.sync="list.getParams" :namespaceMap="namespaceMap" @refresh="fetchData" class="ml-3" />
- </template>
- </page-list>
- </template>
- <script>
- import * as R from 'ramda'
- import ColumnsMixin from '../mixins/columns'
- import SingleActionsMixin from '../mixins/singleActions'
- import ClusterNamespace from '@K8S/sections/ClusterNamespace'
- import releaseMixin from '@K8S/mixins/releaseSidepage'
- import clusterNamespaceMixin from '@K8S/mixins/clusterNamespace'
- import WindowsMixin from '@/mixins/windows'
- import ListMixin from '@/mixins/list'
- import { getNameFilter } from '@/utils/common/tableFilter'
- import expectStatus from '@/constants/expectStatus'
- export default {
- name: 'K8SSecretList',
- components: {
- ClusterNamespace,
- },
- mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin, clusterNamespaceMixin, releaseMixin],
- props: {
- id: String,
- getParams: {
- type: Object,
- default: () => ({}),
- },
- },
- data () {
- return {
- list: this.$list.createList(this, {
- id: this.id,
- resource: 'secrets',
- apiVersion: 'v1',
- getParams: this.getParams,
- filterOptions: {
- name: getNameFilter(),
- type: getNameFilter({ field: 'type', label: this.$t('k8s.text_34') }),
- },
- steadyStatus: {
- status: Object.values(expectStatus.k8s_resource).flat(),
- },
- responseData: this.responseData,
- }),
- groupActions: [
- {
- label: this.$t('k8s.create'),
- permission: 'k8s_secrets_create',
- action: () => {
- this.$router.push({ path: '/k8s-secret/create' })
- },
- meta: () => ({
- buttonType: 'primary',
- }),
- },
- {
- label: this.$t('k8s.text_201'),
- permission: 'k8s_secrets_delete',
- action: () => {
- const data = this.list.selectedItems
- const requestData = {
- cluster: data[0].clusterID,
- }
- const namespace = data[0].namespace
- if (namespace) requestData.namespace = namespace
- this.createDialog('DeleteResDialog', {
- vm: this,
- data,
- columns: this.columns,
- title: this.$t('k8s.text_201'),
- name: this.$t('k8s.text_18'),
- onManager: this.onManager,
- requestData,
- })
- },
- meta: () => {
- let validate = true
- let tooltip = ''
- if (this.list.selectedItems.length > 0) {
- const namespaces = this.list.selectedItems.map(v => v.namespace)
- const unique = Array.from(new Set(namespaces))
- if (unique.length > 1) {
- validate = false
- tooltip = this.$t('k8s.text_203')
- }
- } else {
- validate = false
- tooltip = this.$t('k8s.text_204')
- }
- return {
- validate,
- tooltip,
- }
- },
- },
- ],
- }
- },
- created () {
- this.list.fetchData()
- },
- methods: {
- handleOpenSidepage (row) {
- this.sidePageTriggerHandle(this, 'K8SSecretSidePage', {
- id: row.id,
- resource: 'secrets',
- getParams: () => {
- const params = R.clone(this.list.getParams)
- if (row.namespace) {
- params.namespace = row.namespace
- if (params.all_namespace) delete params.all_namespace
- }
- return params
- },
- apiVersion: 'v1',
- }, {
- list: this.list,
- })
- },
- },
- }
- </script>
|