From fef2ba0e82edecc9d0ba4a9f75a0db75eb131b8e Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 27 Mar 2024 16:48:23 +0100 Subject: [PATCH] finish list breadcrumbs --- .../components/kubernetes/access/Access.tsx | 1 - .../kubernetes/access/ClusterRoles.tsx | 1 - .../kubernetes/access/RoleBindings.tsx | 1 - .../components/kubernetes/access/Roles.tsx | 1 - .../components/kubernetes/cluster/Events.tsx | 1 - .../kubernetes/cluster/Namespaces.tsx | 1 - .../components/kubernetes/cluster/Nodes.tsx | 1 - .../kubernetes/configuration/ConfigMaps.tsx | 1 - .../kubernetes/configuration/Secrets.tsx | 1 - .../CustomResourceDefinitions.tsx | 21 ++++++++++-- .../kubernetes/discovery/Ingresses.tsx | 1 - .../kubernetes/discovery/NetworkPolicies.tsx | 1 - .../kubernetes/discovery/Services.tsx | 1 - .../kubernetes/storage/PersistentVolume.tsx | 1 - .../storage/PersistentVolumeClaims.tsx | 1 - .../kubernetes/storage/PersistentVolumes.tsx | 1 - assets/src/components/kubernetes/utils.tsx | 2 -- .../kubernetes/workloads/CronJobs.tsx | 30 ++++++++++++++++- .../kubernetes/workloads/DaemonSets.tsx | 30 ++++++++++++++++- .../kubernetes/workloads/Deployments.tsx | 30 ++++++++++++++++- .../components/kubernetes/workloads/Jobs.tsx | 30 ++++++++++++++++- .../components/kubernetes/workloads/Pods.tsx | 30 +++++++++++++++-- .../kubernetes/workloads/ReplicaSets.tsx | 30 ++++++++++++++++- .../workloads/ReplicationControllers.tsx | 32 ++++++++++++++++++- .../kubernetes/workloads/StatefulSets.tsx | 30 ++++++++++++++++- .../kubernetes/workloads/Workloads.tsx | 28 +--------------- .../configuration/secret.graphql | 2 +- .../storage/persistentvolume.graphql | 3 +- assets/src/routes/kubernetesRoutesConsts.tsx | 7 ++++ 29 files changed, 262 insertions(+), 58 deletions(-) diff --git a/assets/src/components/kubernetes/access/Access.tsx b/assets/src/components/kubernetes/access/Access.tsx index a95cc80597..a941869db8 100644 --- a/assets/src/components/kubernetes/access/Access.tsx +++ b/assets/src/components/kubernetes/access/Access.tsx @@ -8,7 +8,6 @@ import { ROLES_REL_PATH, ROLE_BINDINGS_REL_PATH, getAccessAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { ScrollablePage } from '../../utils/layout/ScrollablePage' diff --git a/assets/src/components/kubernetes/access/ClusterRoles.tsx b/assets/src/components/kubernetes/access/ClusterRoles.tsx index 60a1dcad75..109562a8be 100644 --- a/assets/src/components/kubernetes/access/ClusterRoles.tsx +++ b/assets/src/components/kubernetes/access/ClusterRoles.tsx @@ -17,7 +17,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { CLUSTER_ROLES_REL_PATH, getAccessAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { useKubernetesContext } from '../Kubernetes' diff --git a/assets/src/components/kubernetes/access/RoleBindings.tsx b/assets/src/components/kubernetes/access/RoleBindings.tsx index af2e235866..22f70d97a1 100644 --- a/assets/src/components/kubernetes/access/RoleBindings.tsx +++ b/assets/src/components/kubernetes/access/RoleBindings.tsx @@ -17,7 +17,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { ROLE_BINDINGS_REL_PATH, getAccessAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { useKubernetesContext } from '../Kubernetes' diff --git a/assets/src/components/kubernetes/access/Roles.tsx b/assets/src/components/kubernetes/access/Roles.tsx index 6a75b4bdf1..2893914154 100644 --- a/assets/src/components/kubernetes/access/Roles.tsx +++ b/assets/src/components/kubernetes/access/Roles.tsx @@ -17,7 +17,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { ROLES_REL_PATH, getAccessAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { useKubernetesContext } from '../Kubernetes' diff --git a/assets/src/components/kubernetes/cluster/Events.tsx b/assets/src/components/kubernetes/cluster/Events.tsx index f1f93f7e4c..eb1bfdcceb 100644 --- a/assets/src/components/kubernetes/cluster/Events.tsx +++ b/assets/src/components/kubernetes/cluster/Events.tsx @@ -22,7 +22,6 @@ import { InlineLink } from '../../utils/typography/InlineLink' import { EVENTS_REL_PATH, getClusterAbsPath, - getKubernetesAbsPath, getResourceDetailsAbsPath, } from '../../../routes/kubernetesRoutesConsts' diff --git a/assets/src/components/kubernetes/cluster/Namespaces.tsx b/assets/src/components/kubernetes/cluster/Namespaces.tsx index ac6564656b..828c57fa42 100644 --- a/assets/src/components/kubernetes/cluster/Namespaces.tsx +++ b/assets/src/components/kubernetes/cluster/Namespaces.tsx @@ -18,7 +18,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { NAMESPACES_REL_PATH, getClusterAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { useKubernetesContext } from '../Kubernetes' diff --git a/assets/src/components/kubernetes/cluster/Nodes.tsx b/assets/src/components/kubernetes/cluster/Nodes.tsx index a898609789..75806263c2 100644 --- a/assets/src/components/kubernetes/cluster/Nodes.tsx +++ b/assets/src/components/kubernetes/cluster/Nodes.tsx @@ -20,7 +20,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { NODES_REL_PATH, getClusterAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { useKubernetesContext } from '../Kubernetes' diff --git a/assets/src/components/kubernetes/configuration/ConfigMaps.tsx b/assets/src/components/kubernetes/configuration/ConfigMaps.tsx index 749b79f7d5..bd81d95e39 100644 --- a/assets/src/components/kubernetes/configuration/ConfigMaps.tsx +++ b/assets/src/components/kubernetes/configuration/ConfigMaps.tsx @@ -17,7 +17,6 @@ import { import { CONFIG_MAPS_REL_PATH, getConfigurationAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { ClusterTinyFragment } from '../../../generated/graphql' import { useKubernetesContext } from '../Kubernetes' diff --git a/assets/src/components/kubernetes/configuration/Secrets.tsx b/assets/src/components/kubernetes/configuration/Secrets.tsx index 00c829e5d6..f57a4fd502 100644 --- a/assets/src/components/kubernetes/configuration/Secrets.tsx +++ b/assets/src/components/kubernetes/configuration/Secrets.tsx @@ -17,7 +17,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { SECRETS_REL_PATH, getConfigurationAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { useKubernetesContext } from '../Kubernetes' diff --git a/assets/src/components/kubernetes/customresources/CustomResourceDefinitions.tsx b/assets/src/components/kubernetes/customresources/CustomResourceDefinitions.tsx index 2d5d1fee9d..d36a56ce36 100644 --- a/assets/src/components/kubernetes/customresources/CustomResourceDefinitions.tsx +++ b/assets/src/components/kubernetes/customresources/CustomResourceDefinitions.tsx @@ -1,20 +1,34 @@ import { createColumnHelper } from '@tanstack/react-table' import React, { useMemo } from 'react' import { useTheme } from 'styled-components' -import { ChipList } from '@pluralsh/design-system' +import { ChipList, useSetBreadcrumbs } from '@pluralsh/design-system' import { CustomResourceDefinitionsQuery, CustomResourceDefinitionsQueryVariables, Types_CustomResourceDefinitionList as CustomResourceListT, Types_CustomResourceDefinition as CustomResourceT, + Maybe, useCustomResourceDefinitionsQuery, } from '../../../generated/graphql-kubernetes' -import { useDefaultColumns } from '../utils' +import { getBaseBreadcrumbs, useDefaultColumns } from '../utils' import { ResourceList } from '../ResourceList' +import { ClusterTinyFragment } from '../../../generated/graphql' +import { getCustomResourcesAbsPath } from '../../../routes/kubernetesRoutesConsts' + +import { useKubernetesContext } from '../Kubernetes' + import { CRDEstablishedChip } from './utils' +export const getBreadcrumbs = (cluster?: Maybe) => [ + ...getBaseBreadcrumbs(cluster), + { + label: 'custom resources', + url: getCustomResourcesAbsPath(cluster?.id), + }, +] + const columnHelper = createColumnHelper() const colName = columnHelper.accessor((r) => r?.objectMeta.name, { @@ -78,6 +92,9 @@ const colCategories = columnHelper.accessor((crd) => crd?.names.categories, { export default function CustomResourceDefinitions() { const theme = useTheme() + const { cluster } = useKubernetesContext() + + useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster])) const { colLabels, colCreationTimestamp } = useDefaultColumns(columnHelper) const columns = useMemo( diff --git a/assets/src/components/kubernetes/discovery/Ingresses.tsx b/assets/src/components/kubernetes/discovery/Ingresses.tsx index 335fb3a917..599ee149b8 100644 --- a/assets/src/components/kubernetes/discovery/Ingresses.tsx +++ b/assets/src/components/kubernetes/discovery/Ingresses.tsx @@ -20,7 +20,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { INGRESSES_REL_PATH, getDiscoveryAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { useKubernetesContext } from '../Kubernetes' diff --git a/assets/src/components/kubernetes/discovery/NetworkPolicies.tsx b/assets/src/components/kubernetes/discovery/NetworkPolicies.tsx index 86ec64af98..18b3d68099 100644 --- a/assets/src/components/kubernetes/discovery/NetworkPolicies.tsx +++ b/assets/src/components/kubernetes/discovery/NetworkPolicies.tsx @@ -18,7 +18,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { NETWORK_POLICIES_REL_PATH, getDiscoveryAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { useKubernetesContext } from '../Kubernetes' diff --git a/assets/src/components/kubernetes/discovery/Services.tsx b/assets/src/components/kubernetes/discovery/Services.tsx index 4cd05f4e5f..b4c9cc573b 100644 --- a/assets/src/components/kubernetes/discovery/Services.tsx +++ b/assets/src/components/kubernetes/discovery/Services.tsx @@ -18,7 +18,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { SERVICES_REL_PATH, getDiscoveryAbsPath, - getKubernetesAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { useKubernetesContext } from '../Kubernetes' diff --git a/assets/src/components/kubernetes/storage/PersistentVolume.tsx b/assets/src/components/kubernetes/storage/PersistentVolume.tsx index ac39dce627..400a3474ff 100644 --- a/assets/src/components/kubernetes/storage/PersistentVolume.tsx +++ b/assets/src/components/kubernetes/storage/PersistentVolume.tsx @@ -9,7 +9,6 @@ import { } from '../../../generated/graphql-kubernetes' import { KubernetesClient } from '../../../helpers/kubernetes.client' import LoadingIndicator from '../../utils/LoadingIndicator' -import { SubTitle } from '../../cluster/nodes/SubTitle' import { MetadataSidecar, useKubernetesCluster } from '../utils' import { getResourceDetailsAbsPath } from '../../../routes/kubernetesRoutesConsts' diff --git a/assets/src/components/kubernetes/storage/PersistentVolumeClaims.tsx b/assets/src/components/kubernetes/storage/PersistentVolumeClaims.tsx index b8d3ec03f8..b6711ad39c 100644 --- a/assets/src/components/kubernetes/storage/PersistentVolumeClaims.tsx +++ b/assets/src/components/kubernetes/storage/PersistentVolumeClaims.tsx @@ -17,7 +17,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { InlineLink } from '../../utils/typography/InlineLink' import { PERSISTENT_VOLUME_CLAIMS_REL_PATH, - getKubernetesAbsPath, getResourceDetailsAbsPath, getStorageAbsPath, } from '../../../routes/kubernetesRoutesConsts' diff --git a/assets/src/components/kubernetes/storage/PersistentVolumes.tsx b/assets/src/components/kubernetes/storage/PersistentVolumes.tsx index a159289ad3..34ea8c01c8 100644 --- a/assets/src/components/kubernetes/storage/PersistentVolumes.tsx +++ b/assets/src/components/kubernetes/storage/PersistentVolumes.tsx @@ -18,7 +18,6 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { InlineLink } from '../../utils/typography/InlineLink' import { PERSISTENT_VOLUMES_REL_PATH, - getKubernetesAbsPath, getResourceDetailsAbsPath, getStorageAbsPath, } from '../../../routes/kubernetesRoutesConsts' diff --git a/assets/src/components/kubernetes/utils.tsx b/assets/src/components/kubernetes/utils.tsx index aaab5ed519..2984eed0c9 100644 --- a/assets/src/components/kubernetes/utils.tsx +++ b/assets/src/components/kubernetes/utils.tsx @@ -18,8 +18,6 @@ import { } from '../../generated/graphql' import { InlineLink } from '../utils/typography/InlineLink' import { - INGRESS_CLASSES_REL_PATH, - getDiscoveryAbsPath, getKubernetesAbsPath, getResourceDetailsAbsPath, } from '../../routes/kubernetesRoutesConsts' diff --git a/assets/src/components/kubernetes/workloads/CronJobs.tsx b/assets/src/components/kubernetes/workloads/CronJobs.tsx index 626b735324..49e8fc852d 100644 --- a/assets/src/components/kubernetes/workloads/CronJobs.tsx +++ b/assets/src/components/kubernetes/workloads/CronJobs.tsx @@ -1,19 +1,43 @@ import { createColumnHelper } from '@tanstack/react-table' import { useMemo } from 'react' +import { useSetBreadcrumbs } from '@pluralsh/design-system' + import { Cronjob_CronJobList as CronJobListT, Cronjob_CronJob as CronJobT, CronJobsQuery, CronJobsQueryVariables, + Maybe, useCronJobsQuery, } from '../../../generated/graphql-kubernetes' -import { useDefaultColumns } from '../utils' +import { getBaseBreadcrumbs, useDefaultColumns } from '../utils' import { ResourceList } from '../ResourceList' import { DateTimeCol } from '../../utils/table/DateTimeCol' +import { ClusterTinyFragment } from '../../../generated/graphql' +import { + CRON_JOBS_REL_PATH, + getConfigurationAbsPath, + getWorkloadsAbsPath, +} from '../../../routes/kubernetesRoutesConsts' + +import { useKubernetesContext } from '../Kubernetes' + import { CronJobSuspendChip, WorkloadImages } from './utils' +export const getBreadcrumbs = (cluster?: Maybe) => [ + ...getBaseBreadcrumbs(cluster), + { + label: 'workloads', + url: getWorkloadsAbsPath(cluster?.id), + }, + { + label: 'cron jobs', + url: `${getConfigurationAbsPath(cluster?.id)}/${CRON_JOBS_REL_PATH}`, + }, +] + const columnHelper = createColumnHelper() const colSchedule = columnHelper.accessor((cj) => cj.schedule, { @@ -47,6 +71,10 @@ const colLastSchedule = columnHelper.accessor((cj) => cj.lastSchedule, { }) export default function CronJobs() { + const { cluster } = useKubernetesContext() + + useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster])) + const { colName, colNamespace, colLabels, colCreationTimestamp } = useDefaultColumns(columnHelper) const columns = useMemo( diff --git a/assets/src/components/kubernetes/workloads/DaemonSets.tsx b/assets/src/components/kubernetes/workloads/DaemonSets.tsx index 3fcbbc8129..6c81038d5b 100644 --- a/assets/src/components/kubernetes/workloads/DaemonSets.tsx +++ b/assets/src/components/kubernetes/workloads/DaemonSets.tsx @@ -1,20 +1,44 @@ import { createColumnHelper } from '@tanstack/react-table' import { useMemo } from 'react' +import { useSetBreadcrumbs } from '@pluralsh/design-system' + import { Daemonset_DaemonSetList as DaemonSetListT, Daemonset_DaemonSet as DaemonSetT, DaemonSetsQuery, DaemonSetsQueryVariables, + Maybe, useDaemonSetsQuery, } from '../../../generated/graphql-kubernetes' -import { useDefaultColumns } from '../utils' +import { getBaseBreadcrumbs, useDefaultColumns } from '../utils' import { ResourceList } from '../ResourceList' import { UsageText } from '../../cluster/TableElements' +import { ClusterTinyFragment } from '../../../generated/graphql' +import { + DAEMON_SETS_REL_PATH, + getConfigurationAbsPath, + getWorkloadsAbsPath, +} from '../../../routes/kubernetesRoutesConsts' + +import { useKubernetesContext } from '../Kubernetes' + import { WorkloadImages, WorkloadStatusChip } from './utils' +export const getBreadcrumbs = (cluster?: Maybe) => [ + ...getBaseBreadcrumbs(cluster), + { + label: 'workloads', + url: getWorkloadsAbsPath(cluster?.id), + }, + { + label: 'daemon sets', + url: `${getConfigurationAbsPath(cluster?.id)}/${DAEMON_SETS_REL_PATH}`, + }, +] + const columnHelper = createColumnHelper() const colImages = columnHelper.accessor((ds) => ds, { @@ -52,6 +76,10 @@ const colStatus = columnHelper.accessor((ds) => ds.podInfo, { }) export default function CronJobs() { + const { cluster } = useKubernetesContext() + + useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster])) + const { colName, colNamespace, colLabels, colCreationTimestamp } = useDefaultColumns(columnHelper) const columns = useMemo( diff --git a/assets/src/components/kubernetes/workloads/Deployments.tsx b/assets/src/components/kubernetes/workloads/Deployments.tsx index 17762698ed..9ec5c8b016 100644 --- a/assets/src/components/kubernetes/workloads/Deployments.tsx +++ b/assets/src/components/kubernetes/workloads/Deployments.tsx @@ -1,20 +1,44 @@ import { createColumnHelper } from '@tanstack/react-table' import { useMemo } from 'react' +import { useSetBreadcrumbs } from '@pluralsh/design-system' + import { Deployment_DeploymentList as DeploymentListT, Deployment_Deployment as DeploymentT, DeploymentsQuery, DeploymentsQueryVariables, + Maybe, useDeploymentsQuery, } from '../../../generated/graphql-kubernetes' import { ResourceList } from '../ResourceList' -import { useDefaultColumns } from '../utils' +import { getBaseBreadcrumbs, useDefaultColumns } from '../utils' import { UsageText } from '../../cluster/TableElements' +import { ClusterTinyFragment } from '../../../generated/graphql' +import { + DEPLOYMENTS_REL_PATH, + getConfigurationAbsPath, + getWorkloadsAbsPath, +} from '../../../routes/kubernetesRoutesConsts' + +import { useKubernetesContext } from '../Kubernetes' + import { WorkloadImages, WorkloadStatusChip } from './utils' +export const getBreadcrumbs = (cluster?: Maybe) => [ + ...getBaseBreadcrumbs(cluster), + { + label: 'workloads', + url: getWorkloadsAbsPath(cluster?.id), + }, + { + label: ' deployments', + url: `${getConfigurationAbsPath(cluster?.id)}/${DEPLOYMENTS_REL_PATH}}`, + }, +] + const columnHelper = createColumnHelper() const colImages = columnHelper.accessor((deployment) => deployment, { @@ -52,6 +76,10 @@ const colStatus = columnHelper.accessor((deployment) => deployment.pods, { }) export default function Deployments() { + const { cluster } = useKubernetesContext() + + useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster])) + const { colName, colNamespace, colLabels, colCreationTimestamp } = useDefaultColumns(columnHelper) const columns = useMemo( diff --git a/assets/src/components/kubernetes/workloads/Jobs.tsx b/assets/src/components/kubernetes/workloads/Jobs.tsx index e1ba0d79bc..06c2275b66 100644 --- a/assets/src/components/kubernetes/workloads/Jobs.tsx +++ b/assets/src/components/kubernetes/workloads/Jobs.tsx @@ -1,19 +1,43 @@ import { createColumnHelper } from '@tanstack/react-table' import { useMemo } from 'react' +import { useSetBreadcrumbs } from '@pluralsh/design-system' + import { Job_JobList as JobListT, Job_Job as JobT, JobsQuery, JobsQueryVariables, + Maybe, useJobsQuery, } from '../../../generated/graphql-kubernetes' -import { useDefaultColumns } from '../utils' +import { getBaseBreadcrumbs, useDefaultColumns } from '../utils' import { ResourceList } from '../ResourceList' import { UsageText } from '../../cluster/TableElements' +import { ClusterTinyFragment } from '../../../generated/graphql' +import { + JOBS_REL_PATH, + getConfigurationAbsPath, + getWorkloadsAbsPath, +} from '../../../routes/kubernetesRoutesConsts' + +import { useKubernetesContext } from '../Kubernetes' + import { WorkloadImages, WorkloadStatusChip } from './utils' +export const getBreadcrumbs = (cluster?: Maybe) => [ + ...getBaseBreadcrumbs(cluster), + { + label: 'workloads', + url: getWorkloadsAbsPath(cluster?.id), + }, + { + label: 'jobs', + url: `${getConfigurationAbsPath(cluster?.id)}/${JOBS_REL_PATH}`, + }, +] + const columnHelper = createColumnHelper() const colImages = columnHelper.accessor((job) => job, { @@ -51,6 +75,10 @@ const colStatus = columnHelper.accessor((job) => job.podInfo, { }) export default function CronJobs() { + const { cluster } = useKubernetesContext() + + useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster])) + const { colName, colNamespace, colLabels, colCreationTimestamp } = useDefaultColumns(columnHelper) const columns = useMemo( diff --git a/assets/src/components/kubernetes/workloads/Pods.tsx b/assets/src/components/kubernetes/workloads/Pods.tsx index f126c5825d..35c35f4e47 100644 --- a/assets/src/components/kubernetes/workloads/Pods.tsx +++ b/assets/src/components/kubernetes/workloads/Pods.tsx @@ -3,22 +3,44 @@ import { useMemo } from 'react' import { Link } from 'react-router-dom' +import { useSetBreadcrumbs } from '@pluralsh/design-system' + import { + Maybe, Pod_PodList as PodListT, Pod_Pod as PodT, PodsQuery, PodsQueryVariables, usePodsQuery, } from '../../../generated/graphql-kubernetes' -import { useDefaultColumns } from '../utils' +import { getBaseBreadcrumbs, useDefaultColumns } from '../utils' import { ResourceList } from '../ResourceList' import { InlineLink } from '../../utils/typography/InlineLink' import { ClusterTinyFragment } from '../../../generated/graphql' -import { getResourceDetailsAbsPath } from '../../../routes/kubernetesRoutesConsts' +import { + PODS_REL_PATH, + getConfigurationAbsPath, + getResourceDetailsAbsPath, + getWorkloadsAbsPath, +} from '../../../routes/kubernetesRoutesConsts' + +import { useKubernetesContext } from '../Kubernetes' import { PodStatusChip, WorkloadImages } from './utils' +export const getBreadcrumbs = (cluster?: Maybe) => [ + ...getBaseBreadcrumbs(cluster), + { + label: 'workloads', + url: getWorkloadsAbsPath(cluster?.id), + }, + { + label: 'pods', + url: `${getConfigurationAbsPath(cluster?.id)}/${PODS_REL_PATH}`, + }, +] + const columnHelper = createColumnHelper() const colImages = columnHelper.accessor((pod) => pod?.containerImages, { @@ -68,6 +90,10 @@ const colRestarts = columnHelper.accessor((pod) => pod?.restartCount, { }) export default function Pods() { + const { cluster } = useKubernetesContext() + + useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster])) + const { colName, colNamespace, colCreationTimestamp } = useDefaultColumns(columnHelper) const columns = useMemo( diff --git a/assets/src/components/kubernetes/workloads/ReplicaSets.tsx b/assets/src/components/kubernetes/workloads/ReplicaSets.tsx index b8e7951884..b96ee1b086 100644 --- a/assets/src/components/kubernetes/workloads/ReplicaSets.tsx +++ b/assets/src/components/kubernetes/workloads/ReplicaSets.tsx @@ -1,7 +1,10 @@ import { createColumnHelper } from '@tanstack/react-table' import { useMemo } from 'react' +import { useSetBreadcrumbs } from '@pluralsh/design-system' + import { + Maybe, Replicaset_ReplicaSetList as ReplicaSetListT, Replicaset_ReplicaSet as ReplicaSetT, ReplicaSetsQuery, @@ -9,12 +12,33 @@ import { useReplicaSetsQuery, } from '../../../generated/graphql-kubernetes' import { ResourceList } from '../ResourceList' -import { useDefaultColumns } from '../utils' +import { getBaseBreadcrumbs, useDefaultColumns } from '../utils' import { UsageText } from '../../cluster/TableElements' +import { ClusterTinyFragment } from '../../../generated/graphql' +import { + REPLICA_SETS_REL_PATH, + getConfigurationAbsPath, + getWorkloadsAbsPath, +} from '../../../routes/kubernetesRoutesConsts' + +import { useKubernetesContext } from '../Kubernetes' + import { WorkloadImages, WorkloadStatusChip } from './utils' +export const getBreadcrumbs = (cluster?: Maybe) => [ + ...getBaseBreadcrumbs(cluster), + { + label: 'workloads', + url: getWorkloadsAbsPath(cluster?.id), + }, + { + label: 'replica sets', + url: `${getConfigurationAbsPath(cluster?.id)}/${REPLICA_SETS_REL_PATH}`, + }, +] + const columnHelper = createColumnHelper() const colImages = columnHelper.accessor((rs) => rs, { @@ -52,6 +76,10 @@ const colStatus = columnHelper.accessor((rs) => rs.podInfo, { }) export default function ReplicaSets() { + const { cluster } = useKubernetesContext() + + useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster])) + const { colName, colNamespace, colLabels, colCreationTimestamp } = useDefaultColumns(columnHelper) const columns = useMemo( diff --git a/assets/src/components/kubernetes/workloads/ReplicationControllers.tsx b/assets/src/components/kubernetes/workloads/ReplicationControllers.tsx index 54c7f11042..0368085453 100644 --- a/assets/src/components/kubernetes/workloads/ReplicationControllers.tsx +++ b/assets/src/components/kubernetes/workloads/ReplicationControllers.tsx @@ -1,19 +1,45 @@ import { createColumnHelper } from '@tanstack/react-table' import { useMemo } from 'react' +import { useSetBreadcrumbs } from '@pluralsh/design-system' + import { + Maybe, Replicationcontroller_ReplicationControllerList as ReplicationControllerListT, Replicationcontroller_ReplicationController as ReplicationControllerT, ReplicationControllersQuery, ReplicationControllersQueryVariables, useReplicationControllersQuery, } from '../../../generated/graphql-kubernetes' -import { useDefaultColumns } from '../utils' +import { getBaseBreadcrumbs, useDefaultColumns } from '../utils' import { ResourceList } from '../ResourceList' import { UsageText } from '../../cluster/TableElements' +import { ClusterTinyFragment } from '../../../generated/graphql' +import { + REPLICATION_CONTROLLERS_REL_PATH, + getConfigurationAbsPath, + getWorkloadsAbsPath, +} from '../../../routes/kubernetesRoutesConsts' + +import { useKubernetesContext } from '../Kubernetes' + import { WorkloadImages, WorkloadStatusChip } from './utils' +export const getBreadcrumbs = (cluster?: Maybe) => [ + ...getBaseBreadcrumbs(cluster), + { + label: 'workloads', + url: getWorkloadsAbsPath(cluster?.id), + }, + { + label: 'replication controllers', + url: `${getConfigurationAbsPath( + cluster?.id + )}/${REPLICATION_CONTROLLERS_REL_PATH}`, + }, +] + const columnHelper = createColumnHelper() const colImages = columnHelper.accessor((rc) => rc, { @@ -51,6 +77,10 @@ const colStatus = columnHelper.accessor((rc) => rc.podInfo, { }) export default function ReplicationControllers() { + const { cluster } = useKubernetesContext() + + useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster])) + const { colName, colNamespace, colLabels, colCreationTimestamp } = useDefaultColumns(columnHelper) const columns = useMemo( diff --git a/assets/src/components/kubernetes/workloads/StatefulSets.tsx b/assets/src/components/kubernetes/workloads/StatefulSets.tsx index 295841d8c0..9a860a5d98 100644 --- a/assets/src/components/kubernetes/workloads/StatefulSets.tsx +++ b/assets/src/components/kubernetes/workloads/StatefulSets.tsx @@ -1,7 +1,10 @@ import { createColumnHelper } from '@tanstack/react-table' import { useMemo } from 'react' +import { useSetBreadcrumbs } from '@pluralsh/design-system' + import { + Maybe, Statefulset_StatefulSetList as StatefulSetListT, Statefulset_StatefulSet as StatefulSetT, StatefulSetsQuery, @@ -9,12 +12,33 @@ import { useStatefulSetsQuery, } from '../../../generated/graphql-kubernetes' import { ResourceList } from '../ResourceList' -import { useDefaultColumns } from '../utils' +import { getBaseBreadcrumbs, useDefaultColumns } from '../utils' import { UsageText } from '../../cluster/TableElements' +import { ClusterTinyFragment } from '../../../generated/graphql' +import { + STATEFUL_SETS_REL_PATH, + getConfigurationAbsPath, + getWorkloadsAbsPath, +} from '../../../routes/kubernetesRoutesConsts' + +import { useKubernetesContext } from '../Kubernetes' + import { WorkloadImages, WorkloadStatusChip } from './utils' +export const getBreadcrumbs = (cluster?: Maybe) => [ + ...getBaseBreadcrumbs(cluster), + { + label: 'workloads', + url: getWorkloadsAbsPath(cluster?.id), + }, + { + label: 'stateful sets', + url: `${getConfigurationAbsPath(cluster?.id)}/${STATEFUL_SETS_REL_PATH}`, + }, +] + const columnHelper = createColumnHelper() const colImages = columnHelper.accessor((ss) => ss, { @@ -52,6 +76,10 @@ const colStatus = columnHelper.accessor((ss) => ss.podInfo, { }) export default function StatefulSets() { + const { cluster } = useKubernetesContext() + + useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster])) + const { colName, colNamespace, colLabels, colCreationTimestamp } = useDefaultColumns(columnHelper) const columns = useMemo( diff --git a/assets/src/components/kubernetes/workloads/Workloads.tsx b/assets/src/components/kubernetes/workloads/Workloads.tsx index 1a0b883e4b..798e0980a2 100644 --- a/assets/src/components/kubernetes/workloads/Workloads.tsx +++ b/assets/src/components/kubernetes/workloads/Workloads.tsx @@ -1,9 +1,4 @@ -import { - SubTab, - TabList, - TabPanel, - useSetBreadcrumbs, -} from '@pluralsh/design-system' +import { SubTab, TabList, TabPanel } from '@pluralsh/design-system' import { Suspense, useMemo, useRef, useState } from 'react' import { Outlet, useMatch } from 'react-router-dom' @@ -16,7 +11,6 @@ import { REPLICATION_CONTROLLERS_REL_PATH, REPLICA_SETS_REL_PATH, STATEFUL_SETS_REL_PATH, - getKubernetesAbsPath, getWorkloadsAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { LinkTabWrap } from '../../utils/Tabs' @@ -56,26 +50,6 @@ export default function Workloads() { const tab = pathMatch?.params?.tab || '' const currentTab = directory.find(({ path }) => path === tab) - useSetBreadcrumbs( - useMemo( - () => [ - { - label: 'kubernetes', - url: getKubernetesAbsPath(cluster?.id), - }, - { - label: cluster?.name ?? '', - url: getKubernetesAbsPath(cluster?.id), - }, - { - label: 'workloads', - url: getWorkloadsAbsPath(cluster?.id), - }, - ], - [cluster] - ) - ) - const headerContent = useMemo( () => ( , kind: string,