Skip to content

Commit

Permalink
frontend: Resource: Add support for cluster via URL var
Browse files Browse the repository at this point in the history
This is so that in multi cluster mode the URL can keep the group
of clusters in the URL, but the details still know which cluster
to use for fetching details.

Signed-off-by: René Dudfield <[email protected]>
  • Loading branch information
illume committed Dec 30, 2024
1 parent 5925769 commit d6eb8fe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/src/components/common/Resource/Resource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import React, { PropsWithChildren, ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { generatePath, NavLinkProps, useLocation } from 'react-router-dom';
import YAML from 'yaml';
import { labelSelectorToQuery, ResourceClasses } from '../../../lib/k8s';
import { labelSelectorToQuery, ResourceClasses, useClusterFromURLVar } from '../../../lib/k8s';
import { ApiError } from '../../../lib/k8s/apiProxy';
import { KubeCondition, KubeContainer, KubeContainerStatus } from '../../../lib/k8s/cluster';
import { KubeEvent } from '../../../lib/k8s/event';
Expand Down Expand Up @@ -113,7 +113,6 @@ export function DetailsGrid<T extends KubeObjectClass>(props: DetailsGridProps<T
resourceType,
name,
namespace,
cluster,
children,
withEvents,
extraSections,
Expand All @@ -128,6 +127,8 @@ export function DetailsGrid<T extends KubeObjectClass>(props: DetailsGridProps<T
state => state.detailsViewSection.detailsViewSectionsProcessors
);
const dispatchHeadlampEvent = useEventCallback();
const clusterFromURLVar = useClusterFromURLVar();
const cluster = props.cluster || clusterFromURLVar;

// This component used to have a MainInfoSection with all these props passed to it, so we're
// using them to accomplish the same behavior.
Expand Down

0 comments on commit d6eb8fe

Please sign in to comment.