diff --git a/assets/src/components/cd/cluster/Cluster.tsx b/assets/src/components/cd/cluster/Cluster.tsx index 2085486cc7..378e533754 100644 --- a/assets/src/components/cd/cluster/Cluster.tsx +++ b/assets/src/components/cd/cluster/Cluster.tsx @@ -60,18 +60,23 @@ import ClusterSelector from '../utils/ClusterSelector' import { ClusterPermissionsModal } from './ClusterPermissions' import { ClusterSettingsModal } from './ClusterSettings.tsx' +import { InsightsTabLabel } from 'components/utils/AiInsights.tsx' -const directory = [ - { path: CLUSTER_SERVICES_PATH, label: 'Services' }, - { path: CLUSTER_NODES_PATH, label: 'Nodes' }, - { path: CLUSTER_PODS_PATH, label: 'Pods' }, - { path: CLUSTER_INSIGHTS_PATH, label: 'Insights' }, - { path: CLUSTER_METADATA_PATH, label: 'Metadata' }, - { path: CLUSTER_VCLUSTERS_REL_PATH, label: 'VClusters', vclusters: true }, - { path: CLUSTER_LOGS_PATH, label: 'Logs', logs: true }, - { path: CLUSTER_ADDONS_REL_PATH, label: 'Add-ons' }, - { path: CLUSTER_PRS_REL_PATH, label: 'PRs' }, -] as const +const getDirectory = ({ cluster }: { cluster: Nullable }) => + [ + { path: CLUSTER_SERVICES_PATH, label: 'Services' }, + { path: CLUSTER_NODES_PATH, label: 'Nodes' }, + { path: CLUSTER_PODS_PATH, label: 'Pods' }, + { + path: CLUSTER_INSIGHTS_PATH, + label: , + }, + { path: CLUSTER_METADATA_PATH, label: 'Metadata' }, + { path: CLUSTER_VCLUSTERS_REL_PATH, label: 'VClusters', vclusters: true }, + { path: CLUSTER_LOGS_PATH, label: 'Logs', logs: true }, + { path: CLUSTER_ADDONS_REL_PATH, label: 'Add-ons' }, + { path: CLUSTER_PRS_REL_PATH, label: 'PRs' }, + ] as const const getSharedMenuItems = (cluster: ClusterFragment): Array => [ { @@ -141,8 +146,6 @@ export default function Cluster() { const [refetchServices, setRefetchServices] = useState(() => () => {}) const logsEnabled = useLogsEnabled() - const currentTab = directory.find(({ path }) => path === tab) - const { data, refetch: refetchCluster, @@ -154,6 +157,8 @@ export default function Cluster() { }) const cluster = data?.cluster + const directory = getDirectory({ cluster }) + const currentTab = directory.find(({ path }) => path === tab) const [headerContent, setHeaderContent] = useState() const [menuKey, setMenuKey] = useState('') @@ -234,18 +239,12 @@ export default function Cluster() { css={{ minWidth: 'fit-content' }} subTab key={path} - textValue={label} to={`${CLUSTER_ABS_PATH}/${path}`.replace( `:${CLUSTER_PARAM_ID}`, clusterId ?? '' )} > - - {label} - + {label} ))} diff --git a/assets/src/components/utils/ButtonGroup.tsx b/assets/src/components/utils/ButtonGroup.tsx index 910bb4a876..1f7d2c9658 100644 --- a/assets/src/components/utils/ButtonGroup.tsx +++ b/assets/src/components/utils/ButtonGroup.tsx @@ -1,5 +1,5 @@ -import { SubTab, TabList } from '@pluralsh/design-system' -import { ReactNode, useCallback, useRef } from 'react' +import { Flex, SubTab } from '@pluralsh/design-system' +import { ReactNode } from 'react' import { useTheme } from 'styled-components' import { LinkTabWrap } from './Tabs.tsx' @@ -20,78 +20,47 @@ export default function ButtonGroup({ directory, toPath, tab, -}: ButtonGroupProps): ReactNode { +}: ButtonGroupProps) { const theme = useTheme() - const tabStateRef = useRef(null) - const currentTab = directory.find(({ path }) => path === tab) - const radius = theme.borderRadiuses.medium - - const first = useCallback((idx: number) => idx === 0, []) - const last = useCallback( - (idx: number) => !first(idx) && idx === directory.length - 1, - [directory.length, first] - ) - const middle = useCallback( - (idx: number) => !first(idx) && !last(idx), - [first, last] - ) return ( - {directory.map(({ path, icon, label }, idx) => ( {icon} {label} ))} - + ) } diff --git a/assets/src/generated/graphql-kubernetes.ts b/assets/src/generated/graphql-kubernetes.ts index d1042cfb91..d29b0e2876 100644 --- a/assets/src/generated/graphql-kubernetes.ts +++ b/assets/src/generated/graphql-kubernetes.ts @@ -1,4 +1,4 @@ -/* eslint-disable */ + /* prettier-ignore */ import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/assets/src/generated/graphql-plural.ts b/assets/src/generated/graphql-plural.ts index 694f1a631a..2a8b931afc 100644 --- a/assets/src/generated/graphql-plural.ts +++ b/assets/src/generated/graphql-plural.ts @@ -1,4 +1,4 @@ -/* eslint-disable */ + /* prettier-ignore */ import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/assets/src/generated/graphql.ts b/assets/src/generated/graphql.ts index f8639fa61e..e001e385e4 100644 --- a/assets/src/generated/graphql.ts +++ b/assets/src/generated/graphql.ts @@ -1,4 +1,4 @@ -/* eslint-disable */ + /* prettier-ignore */ import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client';