<template>
  <base-side-page
    @cancel="cancelSidePage"
    :title="$t('k8s.text_411')"
    icon="res-k8s-node"
    :res-name="detailData.name"
    :current-tab="params.windowData.currentTab"
    :tabs="detailTabs"
    :loaded="loaded"
    @tab-change="handleTabChange">
    <template v-slot:actions>
      <actions
        :options="singleActions"
        :row="detailData"
        button-type="link"
        button-size="small" />
    </template>
    <component
      :is="params.windowData.currentTab"
      :data="detailData"
      resource="k8s_nodes"
      :serverColumns="columns"
      :id="listId"
      :res-id="data.id"
      :getParams="getParams"
      :on-manager="onManager"
      :showSearchbox="false"
      :showGroupActions="false"
      :inSidepageNeedNamepsace="false"
      @refresh="refresh"
      @single-refresh="singleRefresh"
      @tab-change="handleTabChange" />
  </base-side-page>
</template>

<script>
import SingleActionsMixin from '../mixins/singleActions'
import ColumnsMixin from '../mixins/columns'
import K8sNodeDetail from './Detail'
// import K8sNodeMonitor from './Monitor'
import StatusSidepage from '@K8S/sections/StatusSidepage'
import EventsSidepage from '@K8S/sections/EventsSidepage'
import PodList from '@K8S/views/pod/components/List'
import SourceInformationSidepage from '@K8S/sections/SourceInformationSidepage'
import SidePageMixin from '@/mixins/sidePage'
import WindowsMixin from '@/mixins/windows'
import Actions from '@/components/PageList/Actions'

export default {
  name: 'K8SNodeSidePage',
  components: {
    Actions,
    K8sNodeDetail,
    PodList,
    StatusSidepage,
    EventsSidepage,
    SourceInformationSidepage,
    // K8sNodeMonitor,
  },
  mixins: [SidePageMixin, WindowsMixin, ColumnsMixin, SingleActionsMixin],
  data () {
    return {
      detailTabs: [
        { label: this.$t('k8s.text_217'), key: 'k8s-node-detail' },
        // { label: this.$t('k8s.text_414'), key: 'k8s-node-monitor' },
        { label: this.$t('k8s.text_9'), key: 'pod-list' },
        { label: this.$t('k8s.text_35'), key: 'status-sidepage' },
        { label: this.$t('k8s.text_218'), key: 'events-sidepage' },
        { label: this.$t('k8s.text_219'), key: 'source-information-sidepage' },
        { label: this.$t('compute.text_240'), key: 'event-drawer' },
      ],
    }
  },
  computed: {
    getParams () {
      return {
        owner_kind: this.detailData.kind,
        owner_name: this.detailData.name,
        namespace: this.detailData.namespace,
        cluster: this.detailData.clusterID,
      }
    },
    listId () {
      switch (this.params.windowData.currentTab) {
        case 'event-drawer':
          return 'EventListForK8SNodeSidePage'
        case 'pod-list':
          return 'PodListForK8SNodeSidePage'
        case 'events-sidepage':
          return 'EventsForK8SNodeSidePage'
        default:
          return ''
      }
    },
  },
}
</script>
