mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 00:27:30 +00:00
misc: moved get project secrets error handling to hook
This commit is contained in:
@@ -108,6 +108,16 @@ export const useGetProjectSecrets = ({
|
|||||||
enabled: Boolean(workspaceId && environment) && (options?.enabled ?? true),
|
enabled: Boolean(workspaceId && environment) && (options?.enabled ?? true),
|
||||||
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }),
|
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }),
|
||||||
queryFn: async () => fetchProjectSecrets({ 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)
|
select: ({ secrets }) => mergePersonalSecrets(secrets)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { useRouter } from "next/router";
|
|||||||
import { subject } from "@casl/ability";
|
import { subject } from "@casl/ability";
|
||||||
import { faArrowDown, faArrowUp } from "@fortawesome/free-solid-svg-icons";
|
import { faArrowDown, faArrowUp } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import axios from "axios";
|
|
||||||
|
|
||||||
import NavHeader from "@app/components/navigation/NavHeader";
|
import NavHeader from "@app/components/navigation/NavHeader";
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
@@ -94,12 +93,7 @@ export const SecretMainPage = () => {
|
|||||||
}, [isWorkspaceLoading, currentWorkspace, environment, router.isReady]);
|
}, [isWorkspaceLoading, currentWorkspace, environment, router.isReady]);
|
||||||
|
|
||||||
// fetch secrets
|
// fetch secrets
|
||||||
const {
|
const { data: secrets, isLoading: isSecretsLoading } = useGetProjectSecrets({
|
||||||
data: secrets,
|
|
||||||
isLoading: isSecretsLoading,
|
|
||||||
isError: isErrorFetchingSecrets,
|
|
||||||
error: fetchSecretsError
|
|
||||||
} = useGetProjectSecrets({
|
|
||||||
environment,
|
environment,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
secretPath,
|
secretPath,
|
||||||
@@ -108,17 +102,6 @@ export const SecretMainPage = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isErrorFetchingSecrets) {
|
|
||||||
if (axios.isAxiosError(fetchSecretsError)) {
|
|
||||||
const serverResponse = fetchSecretsError.response?.data as { message: string };
|
|
||||||
createNotification({
|
|
||||||
title: "Error fetching secrets",
|
|
||||||
type: "error",
|
|
||||||
text: serverResponse.message
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fetch folders
|
// fetch folders
|
||||||
const { data: folders, isLoading: isFoldersLoading } = useGetProjectFolders({
|
const { data: folders, isLoading: isFoldersLoading } = useGetProjectFolders({
|
||||||
projectId: workspaceId,
|
projectId: workspaceId,
|
||||||
|
|||||||
Reference in New Issue
Block a user