From 4fe6017c2b09c735cf7e8f385b4dd2d192a258c3 Mon Sep 17 00:00:00 2001 From: Vladyslav Palyvoda Date: Mon, 21 Aug 2023 14:27:37 +0300 Subject: [PATCH] fix: Fix image tags real-time updating (#25) Jira: EPMDEDP-12483 Resolves: #25 Change-Id: I557906e0e66c457e29f82c52a9a354d157f40b92 --- ...richedApplicationsWithImageStreamsQuery.ts | 19 +++++++------------ src/providers/ViewMode/index.tsx | 2 -- .../components/ApplicationRow/index.tsx | 4 +++- src/widgets/DeleteKubeObject/index.tsx | 4 ---- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/k8s/EDPCodebase/hooks/useEnrichedApplicationsWithImageStreamsQuery.ts b/src/k8s/EDPCodebase/hooks/useEnrichedApplicationsWithImageStreamsQuery.ts index 5353ebd5..70bc948d 100644 --- a/src/k8s/EDPCodebase/hooks/useEnrichedApplicationsWithImageStreamsQuery.ts +++ b/src/k8s/EDPCodebase/hooks/useEnrichedApplicationsWithImageStreamsQuery.ts @@ -3,7 +3,7 @@ import { UseQueryOptions } from 'react-query'; import { CODEBASE_TYPES } from '../../../constants/codebaseTypes'; import { KubeObjectListInterface } from '../../../types/k8s'; import { EDPCDPipelineKubeObjectInterface } from '../../EDPCDPipeline/types'; -import { useCodebaseImageStreamListQuery } from '../../EDPCodebaseImageStream/hooks/useCodebaseImageStreamListQuery'; +import { EDPCodebaseImageStreamKubeObject } from '../../EDPCodebaseImageStream'; import { EDPCodebaseImageStreamKubeObjectInterface } from '../../EDPCodebaseImageStream/types'; import { EDPCodebaseKubeObjectInterface } from '../types'; import { useCodebasesByTypeLabelQuery } from './useCodebasesByTypeLabelQuery'; @@ -47,13 +47,8 @@ export const useEnrichedApplicationsWithImageStreamsQuery = ({ [normalizedInputDockerStreamNames] ); - const { data: codebaseImageStreams } = useCodebaseImageStreamListQuery({ - props: { - namespace: CDPipelineData?.metadata.namespace, - }, - options: { - enabled: !!CDPipelineData?.metadata.namespace, - }, + const [codebaseImageStreams] = EDPCodebaseImageStreamKubeObject.useList({ + namespace: CDPipelineData?.metadata.namespace, }); return useCodebasesByTypeLabelQuery({ @@ -63,6 +58,7 @@ export const useEnrichedApplicationsWithImageStreamsQuery = ({ }, options: { enabled: !!codebaseImageStreams, + cacheTime: 0, select: data => { return data?.items .map(el => { @@ -74,10 +70,9 @@ export const useEnrichedApplicationsWithImageStreamsQuery = ({ return; } - const codebaseImageStreamsByCodebaseName = - codebaseImageStreams?.items.filter( - ({ spec: { codebase } }) => codebase === name - ); + const codebaseImageStreamsByCodebaseName = codebaseImageStreams?.filter( + ({ spec: { codebase } }) => codebase === name + ); const applicationImageStream = codebaseImageStreamsByCodebaseName && diff --git a/src/providers/ViewMode/index.tsx b/src/providers/ViewMode/index.tsx index 455c5f37..7b317d02 100644 --- a/src/providers/ViewMode/index.tsx +++ b/src/providers/ViewMode/index.tsx @@ -13,8 +13,6 @@ export const ViewModeContextProvider: React.FC = ( VIEW_MODES.TABLE ); - console.log(viewMode); - const handleChangeViewMode = React.useCallback( (viewMode: ViewMode) => { LOCAL_STORAGE_SERVICE.setItem(`VIEW_MODE::${entityID}`, viewMode); diff --git a/src/widgets/CreateEditCDPipeline/components/fields/Applications/components/ApplicationRow/index.tsx b/src/widgets/CreateEditCDPipeline/components/fields/Applications/components/ApplicationRow/index.tsx index 4e557d6a..0f42866e 100644 --- a/src/widgets/CreateEditCDPipeline/components/fields/Applications/components/ApplicationRow/index.tsx +++ b/src/widgets/CreateEditCDPipeline/components/fields/Applications/components/ApplicationRow/index.tsx @@ -200,7 +200,9 @@ export const ApplicationRow = ({ application }: ApplicationRowProps) => { handleChangeApplicationToPromote({ name, value }), } )} - defaultValue={CDPipelineData?.spec.applicationsToPromote.includes(appName)} + defaultValue={CDPipelineData?.spec?.applicationsToPromote?.includes( + appName + )} label={} control={control} errors={errors} diff --git a/src/widgets/DeleteKubeObject/index.tsx b/src/widgets/DeleteKubeObject/index.tsx index 7a218257..56e0fb69 100644 --- a/src/widgets/DeleteKubeObject/index.tsx +++ b/src/widgets/DeleteKubeObject/index.tsx @@ -46,8 +46,6 @@ export const DeleteKubeObject = () => { DELETE_KUBE_OBJECT_DIALOG_NAME ); - console.log(isDetailsPage); - const [errorTemplate, setErrorTemplate] = React.useState(null); const [loadingActive, setLoadingActive] = React.useState(false); const { register, handleSubmit, watch, reset } = useForm(); @@ -80,8 +78,6 @@ export const DeleteKubeObject = () => { }); reset(); - console.log(isDetailsPage); - if (isDetailsPage) { history.goBack(); }