Skip to content

Commit a0ab60d

Browse files
fix: prevent loop within effect
1 parent 2bd5c98 commit a0ab60d

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

web/src/components/dashboards/legacy/useLegacyDashboards.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const useLegacyDashboards = (namespace: string, urlBoard: string) => {
4444
setLegacyDashboardsLoaded();
4545
setLegacyDashboardsError(undefined);
4646
let items = response.items;
47-
if (namespace !== ALL_NAMESPACES_KEY) {
47+
if (namespace && namespace !== ALL_NAMESPACES_KEY) {
4848
items = _.filter(
4949
items,
5050
(item) => item.metadata?.labels['console.openshift.io/odc-dashboard'] === 'true',
@@ -97,16 +97,6 @@ export const useLegacyDashboards = (namespace: string, urlBoard: string) => {
9797
}, []) ?? [];
9898
}, [urlBoard, legacyDashboards]);
9999

100-
useEffect(() => {
101-
// Dashboard query argument is only set in dev perspective, so skip for admin
102-
if (perspective !== 'dev') {
103-
return;
104-
}
105-
const allVariables = getAllVariables(legacyDashboards, urlBoard, namespace);
106-
dispatch(dashboardsPatchAllVariables(allVariables));
107-
// eslint-disable-next-line react-hooks/exhaustive-deps
108-
}, [namespace, urlBoard]);
109-
110100
// Homogenize data needed for dashboards dropdown between legacy and perses dashboards
111101
// to enable both to use the same component
112102
const legacyDashboardsMetadata = useMemo<CombinedDashboardMetadata[]>(() => {
@@ -134,8 +124,7 @@ export const useLegacyDashboards = (namespace: string, urlBoard: string) => {
134124
const queryArguments = getAllQueryArguments();
135125
const params = new URLSearchParams(queryArguments);
136126

137-
let url = getLegacyDashboardsUrl(perspective, newBoard);
138-
url = `${url}${perspective === 'dev' ? '&' : '?'}${params.toString()}`;
127+
const url = getLegacyDashboardsUrl(perspective, newBoard) + params.toString();
139128

140129
if (newBoard !== urlBoard || initialLoad) {
141130
if (params.get(QueryParams.Dashboard) !== newBoard) {

0 commit comments

Comments
 (0)