Skip to content

Commit

Permalink
Pass fallback namespace to datasources
Browse files Browse the repository at this point in the history
  • Loading branch information
akucharska committed Aug 20, 2024
1 parent 358e471 commit 892de24
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/Extensibility/contexts/DataSources.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import pluralize from 'pluralize';
import { createContext, useEffect, useRef, FC } from 'react';
import { useRecoilValue } from 'recoil';

import { useFetch } from 'shared/hooks/BackendAPI/useFetch';
import { useObjectState } from 'shared/useObjectState';
import * as jp from 'jsonpath';
import { jsonataWrapper } from '../helpers/jsonataWrapper';
import { activeNamespaceIdState } from 'state/activeNamespaceIdAtom';

export interface Resource {
metadata: {
Expand Down Expand Up @@ -79,6 +82,7 @@ export const DataSourcesContextProvider: FC<Props> = ({
const dataSourcesDict = useRef<DataSourcesDict>({});
// refetch intervals
const intervals = useRef<ReturnType<typeof setTimeout>[]>([]);
const fallbackNamespace = useRecoilValue(activeNamespaceIdState);

// clear timeouts on component unmount
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand All @@ -93,7 +97,7 @@ export const DataSourcesContextProvider: FC<Props> = ({
ownerLabelSelectorPath,
} = dataSource;
if (typeof namespace === 'undefined') {
namespace = resource?.metadata?.namespace;
namespace = resource?.metadata?.namespace || fallbackNamespace;
}

const namespacePart = namespace ? `/namespaces/${namespace}` : '';
Expand Down

0 comments on commit 892de24

Please sign in to comment.