<template>
  <base-side-page
    @cancel="cancelSidePage"
    :title="$t('k8s.text_394')"
    icon="res-k8s-rbacclusterrolebinding"
    :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"
      :resId="detailData.id"
      resource="federatedclusterrolebindings"
      :serverColumns="columns"
      :res-id="data.id"
      :id="listId"
      :getParams="getParams"
      :on-manager="onManager"
      :title="$t('k8s.text_394')"
      @refresh="refresh"
      @single-refresh="singleRefresh"
      @tab-change="handleTabChange" />
  </base-side-page>
</template>

<script>
import SingleActionsMixin from '../mixins/singleActions'
import ColumnsMixin from '../mixins/columns'
import K8sFederatedclusterrolebindingDetail from './Detail'
import K8sAttachClusterList from '@K8S/sections/AccachClsuterSidepage'
import SidePageMixin from '@/mixins/sidePage'
import WindowsMixin from '@/mixins/windows'
import Actions from '@/components/PageList/Actions'

export default {
  name: 'K8SFederatedclusterrolebindingSidePage',
  components: {
    Actions,
    K8sFederatedclusterrolebindingDetail,
    K8sAttachClusterList,
  },
  mixins: [SidePageMixin, WindowsMixin, ColumnsMixin, SingleActionsMixin],
  data () {
    return {
      detailTabs: [
        { label: this.$t('k8s.text_217'), key: 'k8s-federatedclusterrolebinding-detail' },
        { label: this.$t('k8s.text_369'), key: 'k8s-attach-cluster-list' },
        { 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 'EventListForK8SFederatedclusterrolebindingSidePage'
        case 'k8s-attach-cluster-list':
          return 'AttachClusterListForK8SFederatedclusterrolebindingSidePage'
        default:
          return ''
      }
    },
  },
}
</script>
