From f2dde9d63a29186f187b6a63f7f97e6617c3c3a7 Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Thu, 17 Nov 2022 09:40:47 +0100 Subject: [PATCH] stop making enterprise calls in oss (#2449) --- .../getters/useChangeRequestConfig/useChangeRequestConfig.ts | 4 +++- .../api/getters/useChangeRequestOpen/useChangeRequestOpen.ts | 4 +++- .../useProjectChangeRequests/useProjectChangeRequests.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/hooks/api/getters/useChangeRequestConfig/useChangeRequestConfig.ts b/frontend/src/hooks/api/getters/useChangeRequestConfig/useChangeRequestConfig.ts index 1d8f2580e1..bcf1dcf35e 100644 --- a/frontend/src/hooks/api/getters/useChangeRequestConfig/useChangeRequestConfig.ts +++ b/frontend/src/hooks/api/getters/useChangeRequestConfig/useChangeRequestConfig.ts @@ -2,11 +2,13 @@ import useSWR from 'swr'; import { formatApiPath } from 'utils/formatPath'; import handleErrorResponses from '../httpErrorResponseHandler'; import { IChangeRequestEnvironmentConfig } from 'component/changeRequest/changeRequest.types'; +import useUiConfig from '../useUiConfig/useUiConfig'; export const useChangeRequestConfig = (projectId: string) => { + const { isOss } = useUiConfig(); const { data, error, mutate } = useSWR( formatApiPath(`api/admin/projects/${projectId}/change-requests/config`), - fetcher + isOss() ? () => Promise.resolve([]) : fetcher ); return { diff --git a/frontend/src/hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen.ts b/frontend/src/hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen.ts index 4969aa6a04..aee350585a 100644 --- a/frontend/src/hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen.ts +++ b/frontend/src/hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen.ts @@ -3,6 +3,7 @@ import { useMemo } from 'react'; import { formatApiPath } from 'utils/formatPath'; import handleErrorResponses from '../httpErrorResponseHandler'; import { IChangeRequest } from 'component/changeRequest/changeRequest.types'; +import useUiConfig from '../useUiConfig/useUiConfig'; const fetcher = (path: string) => { return fetch(path) @@ -11,9 +12,10 @@ const fetcher = (path: string) => { }; export const useChangeRequestOpen = (project: string) => { + const { isOss } = useUiConfig(); const { data, error, mutate } = useSWR( formatApiPath(`api/admin/projects/${project}/change-requests/open`), - fetcher + isOss() ? () => Promise.resolve([]) : fetcher ); return useMemo( diff --git a/frontend/src/hooks/api/getters/useProjectChangeRequests/useProjectChangeRequests.ts b/frontend/src/hooks/api/getters/useProjectChangeRequests/useProjectChangeRequests.ts index b9fa709527..cd9acc9bc3 100644 --- a/frontend/src/hooks/api/getters/useProjectChangeRequests/useProjectChangeRequests.ts +++ b/frontend/src/hooks/api/getters/useProjectChangeRequests/useProjectChangeRequests.ts @@ -2,6 +2,7 @@ import useSWR from 'swr'; import { useMemo } from 'react'; import { formatApiPath } from 'utils/formatPath'; import handleErrorResponses from '../httpErrorResponseHandler'; +import useUiConfig from '../useUiConfig/useUiConfig'; const fetcher = (path: string) => { return fetch(path) @@ -10,9 +11,10 @@ const fetcher = (path: string) => { }; export const useProjectChangeRequests = (project: string) => { + const { isOss } = useUiConfig(); const { data, error, mutate } = useSWR( formatApiPath(`api/admin/projects/${project}/change-requests`), - fetcher + isOss() ? () => Promise.resolve([]) : fetcher ); return useMemo(