diff --git a/frontend/src/hooks/api/secrets/queries.tsx b/frontend/src/hooks/api/secrets/queries.tsx index 192a3befb..8d0961ca5 100644 --- a/frontend/src/hooks/api/secrets/queries.tsx +++ b/frontend/src/hooks/api/secrets/queries.tsx @@ -1,8 +1,11 @@ /* eslint-disable no-param-reassign */ import { useCallback, useMemo } from "react"; import { useQueries, useQuery, UseQueryOptions } from "@tanstack/react-query"; +import axios from "axios"; +import { createNotification } from "@app/components/notifications"; import { apiRequest } from "@app/config/request"; +import { useToggle } from "@app/hooks/useToggle"; import { GetSecretVersionsDTO, @@ -105,6 +108,16 @@ export const useGetProjectSecrets = ({ enabled: Boolean(workspaceId && environment) && (options?.enabled ?? true), queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }), queryFn: async () => fetchProjectSecrets({ workspaceId, environment, secretPath }), + onError: (error) => { + if (axios.isAxiosError(error)) { + const serverResponse = error.response?.data as { message: string }; + createNotification({ + title: "Error fetching secrets", + type: "error", + text: serverResponse.message + }); + } + }, select: ({ secrets }) => mergePersonalSecrets(secrets) }); @@ -113,10 +126,24 @@ export const useGetProjectSecretsAllEnv = ({ envs, secretPath }: TGetProjectSecretsAllEnvDTO) => { + const [isErrorHandled, setIsErrorHandled] = useToggle(false); + const secrets = useQueries({ queries: envs.map((environment) => ({ queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }), enabled: Boolean(workspaceId && environment), + onError: (error: unknown) => { + if (axios.isAxiosError(error) && !isErrorHandled) { + const serverResponse = error.response?.data as { message: string }; + createNotification({ + title: "Error fetching secrets", + type: "error", + text: serverResponse.message + }); + + setIsErrorHandled.on(); + } + }, queryFn: async () => fetchProjectSecrets({ workspaceId, environment, secretPath }), select: (el: SecretV3RawResponse) => mergePersonalSecrets(el.secrets).reduce>( diff --git a/frontend/src/views/SecretOverviewPage/components/SecretV2MigrationSection/SecretV2MigrationSection.tsx b/frontend/src/views/SecretOverviewPage/components/SecretV2MigrationSection/SecretV2MigrationSection.tsx index aee61be19..e20d5c111 100644 --- a/frontend/src/views/SecretOverviewPage/components/SecretV2MigrationSection/SecretV2MigrationSection.tsx +++ b/frontend/src/views/SecretOverviewPage/components/SecretV2MigrationSection/SecretV2MigrationSection.tsx @@ -33,7 +33,7 @@ export const SecretV2MigrationSection = () => { currentWorkspace?.version === ProjectVersion.V3 ? "" : currentWorkspace?.id || "", { refetchInterval: - currentWorkspace?.upgradeStatus === ProjectUpgradeStatus.InProgress ? 3000 : false + currentWorkspace?.upgradeStatus === ProjectUpgradeStatus.InProgress ? 2000 : false } ); const { membership } = useProjectPermission();