Skip to content

Commit

Permalink
fix(UI): pod selection fix (#1266)
Browse files Browse the repository at this point in the history
Signed-off-by: Shakira M <shakira_m@intuit.com>
Co-authored-by: Shakira M <shakira_m@intuit.com>
  • Loading branch information
mshakira and Shakira M committed Oct 25, 2023
1 parent 07a7b8e commit b86b225
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ui/src/types/declarations/pods.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export interface SearchablePodsHeatMapProps {
podsDetailsMap: Map<string, PodDetail>;
onPodClick: (e: Element | EventType, pod: Pod) => void;
selectedPod: Pod | undefined;
setSelectedPod: Dispatch<SetStateAction<Pod>>;
}

export interface PodsHeatMapProps {
Expand Down
3 changes: 3 additions & 0 deletions ui/src/utils/fetcherHooks/podsViewFetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe("Custom Pods hook", () => {
"default",
"simple-pipeline",
"cat",
undefined,
jest.fn() as Dispatch<SetStateAction<Pod | undefined>>,
jest.fn() as Dispatch<SetStateAction<string | undefined>>
)
Expand All @@ -86,6 +87,7 @@ describe("Custom Pods hook", () => {
"default",
"simple-pipeline",
"cat",
undefined,
jest.fn() as Dispatch<SetStateAction<Pod | undefined>>,
jest.fn() as Dispatch<SetStateAction<string | undefined>>
)
Expand All @@ -106,6 +108,7 @@ describe("Custom Pods hook", () => {
"default",
"simple-pipeline",
"cat",
undefined,
jest.fn() as Dispatch<SetStateAction<Pod | undefined>>,
jest.fn() as Dispatch<SetStateAction<string | undefined>>
)
Expand Down
7 changes: 5 additions & 2 deletions ui/src/utils/fetcherHooks/podsViewFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const usePodsViewFetch = (
namespaceId: string | undefined,
pipelineId: string | undefined,
vertexId: string | undefined,
selectedPod: Pod | undefined,
setSelectedPod: Dispatch<SetStateAction<Pod | undefined>>,
setSelectedContainer: Dispatch<SetStateAction<string | undefined>>
) => {
Expand Down Expand Up @@ -107,8 +108,10 @@ export const usePodsViewFetch = (

useEffect(() => {
if (pods?.length) {
setSelectedPod(pods[0]);
setSelectedContainer(pods[0]?.containers[0]);
if (!(selectedPod && pods?.find((pod) => pod?.name === selectedPod?.name))) {
setSelectedPod(pods[0]);
setSelectedContainer(pods[0]?.containers[0]);
}
} else {
setSelectedPod(undefined);
setSelectedContainer(undefined);
Expand Down

0 comments on commit b86b225

Please sign in to comment.