Fix: Error notification when user does not have access to read from certain environments

This commit is contained in:
Daniel Hougaard
2024-08-20 21:41:02 +04:00
parent bd5cd03aeb
commit e970cc0f47
2 changed files with 9 additions and 5 deletions
@@ -0,0 +1 @@
export const ERROR_NOT_ALLOWED_READ_SECRETS = "You are not allowed to read on secrets";
+8 -5
View File
@@ -7,6 +7,7 @@ import { createNotification } from "@app/components/notifications";
import { apiRequest } from "@app/config/request"; import { apiRequest } from "@app/config/request";
import { useToggle } from "@app/hooks/useToggle"; import { useToggle } from "@app/hooks/useToggle";
import { ERROR_NOT_ALLOWED_READ_SECRETS } from "./constants";
import { import {
GetSecretVersionsDTO, GetSecretVersionsDTO,
SecretType, SecretType,
@@ -135,11 +136,13 @@ export const useGetProjectSecretsAllEnv = ({
onError: (error: unknown) => { onError: (error: unknown) => {
if (axios.isAxiosError(error) && !isErrorHandled) { if (axios.isAxiosError(error) && !isErrorHandled) {
const serverResponse = error.response?.data as { message: string }; const serverResponse = error.response?.data as { message: string };
createNotification({ if (serverResponse.message !== ERROR_NOT_ALLOWED_READ_SECRETS) {
title: "Error fetching secrets", createNotification({
type: "error", title: "Error fetching secrets",
text: serverResponse.message type: "error",
}); text: serverResponse.message
});
}
setIsErrorHandled.on(); setIsErrorHandled.on();
} }