Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvements: address feedback

Scott Wilson43c24813693b
diff --git a/frontend/src/components/notifications/Notifications.tsx b/frontend/src/components/notifications/Notifications.tsx
index dc203f6a57..11ef5a71f8 100644
--- a/frontend/src/components/notifications/Notifications.tsx
+++ b/frontend/src/components/notifications/Notifications.tsx
@@ -19,11 +19,10 @@ export type TNotification = {
copyActions?: { icon?: IconDefinition; value: string; name: string; label?: string }[];
};
-// Back-compat shim for the old react-toastify second argument. Across the codebase only
-// `autoClose` and `closeOnClick` were ever passed, so we map those and ignore the rest.
+// Back-compat shim for the old react-toastify second argument. Only `autoClose` is ever passed
+// at call sites; it maps to sonner's `duration`.
type TNotificationOptions = {
autoClose?: number | false;
- closeOnClick?: boolean;
duration?: number;
};
@@ -43,8 +42,12 @@ const ToastCopyButton = ({ value, name }: { value: string; name: string }) => {
className="size-5"
onClick={(e) => {
e.stopPropagation();
- setCopyText("Copied");
- navigator.clipboard.writeText(value);
+ navigator.clipboard
+ .writeText(value)
+ .then(() => setCopyText("Copied"))
+ .catch(() => {
+ // clipboard write failed (e.g. denied permissions); leave the state unchanged
+ });
}}
>
{isCopying ? <CheckIcon className="size-3!" /> : <CopyIcon className="size-3!" />}
diff --git a/frontend/src/components/v3/generic/Toast/Toast.tsx b/frontend/src/components/v3/generic/Toast/Toast.tsx
index a26fce71e3..c2a9570935 100644
--- a/frontend/src/components/v3/generic/Toast/Toast.tsx
+++ b/frontend/src/components/v3/generic/Toast/Toast.tsx
@@ -7,7 +7,6 @@ import {
} from "lucide-react";
import { Toaster as Sonner, type ToasterProps } from "sonner";
-
const Toaster = ({ ...props }: ToasterProps) => {
return (
<Sonner
diff --git a/frontend/src/hooks/api/reactQuery.tsx b/frontend/src/hooks/api/reactQuery.tsx
index a90638f016..284267d6a6 100644
--- a/frontend/src/hooks/api/reactQuery.tsx
+++ b/frontend/src/hooks/api/reactQuery.tsx
@@ -92,123 +92,112 @@ export const onRequestError = (error: unknown) => {
requestBody = undefined;
}
- createNotification(
- {
- title: "Validation Error",
- type: "error",
- text: "Please check the input and try again.",
- callToAction: (
- <ValidationErrorModal serverResponse={serverResponse} requestBody={requestBody} />
- ),
- copyActions: [
- {
- value: serverResponse.reqId,
- name: "Request ID",
- label: `Request ID: ${serverResponse.reqId}`
- }
- ]
- },
- { closeOnClick: false }
- );
+ createNotification({
+ title: "Validation Error",
+ type: "error",
+ text: "Please check the input and try again.",
+ callToAction: (
+ <ValidationErrorModal serverResponse={serverResponse} requestBody={requestBody} />
+ ),
+ copyActions: [
+ {
+ value: serverResponse.reqId,
+ name: "Request ID",
+ label: `Request ID: ${serverResponse.reqId}`
+ }
+ ]
+ });
return;
}
if (serverResponse?.error === ApiErrorTypes.ForbiddenError) {
- createNotification(
- {
- title: "Forbidden Access",
- type: "error",
- text: `${serverResponse.message}.`,
- callToAction: serverResponse?.details?.length ? (
- <Modal>
- <ModalTrigger asChild>
- <Button variant="outline_bg" size="xs">
- Show more
- </Button>
- </ModalTrigger>
- <ModalContent
- title="Validation Rules"
- subTitle="Please review the allowed rules below."
- >
- <div className="flex flex-col gap-2">
- {serverResponse.details?.map((el, index) => {
- const hasConditions = Boolean(Object.keys(el.conditions || {}).length);
- return (
- <div
- key={`Forbidden-error-details-${index + 1}`}
- className="rounded-md border border-gray-600 p-4"
- >
- <div>
- {el.inverted ? "Cannot" : "Can"}{" "}
- <span className="text-yellow-600">
- {el.action.toString().replaceAll(",", ", ")}
- </span>{" "}
- {el.subject.toString()} {hasConditions && "with conditions:"}
- </div>
- {hasConditions && (
- <ul className="flex list-disc flex-col gap-1 pt-2 pl-5 text-sm">
- {Object.keys(el.conditions || {}).flatMap((field, fieldIndex) => {
- const operators = (
- el.conditions as Record<
- string,
- | string
- | { [K in PermissionConditionOperators]: string | string[] }
- >
- )[field];
-
- const formattedFieldName = camelCaseToSpaces(field).toLowerCase();
- if (typeof operators === "string") {
- return (
- <li
- key={`Forbidden-error-details-${index + 1}-${fieldIndex + 1}`}
- >
- <span className="font-bold capitalize">
- {formattedFieldName}
- </span>{" "}
- <span className="text-mineshaft-200">equal to</span>{" "}
- <span className="text-yellow-600">{operators}</span>
- </li>
- );
- }
+ createNotification({
+ title: "Forbidden Access",
+ type: "error",
+ text: `${serverResponse.message}.`,
+ callToAction: serverResponse?.details?.length ? (
+ <Modal>
+ <ModalTrigger asChild>
+ <Button variant="outline_bg" size="xs">
+ Show more
+ </Button>
+ </ModalTrigger>
+ <ModalContent
+ title="Validation Rules"
+ subTitle="Please review the allowed rules below."
+ >
+ <div className="flex flex-col gap-2">
+ {serverResponse.details?.map((el, index) => {
+ const hasConditions = Boolean(Object.keys(el.conditions || {}).length);
+ return (
+ <div
+ key={`Forbidden-error-details-${index + 1}`}
+ className="rounded-md border border-gray-600 p-4"
+ >
+ <div>
+ {el.inverted ? "Cannot" : "Can"}{" "}
+ <span className="text-yellow-600">
+ {el.action.toString().replaceAll(",", ", ")}
+ </span>{" "}
+ {el.subject.toString()} {hasConditions && "with conditions:"}
+ </div>
+ {hasConditions && (
+ <ul className="flex list-disc flex-col gap-1 pt-2 pl-5 text-sm">
+ {Object.keys(el.conditions || {}).flatMap((field, fieldIndex) => {
+ const operators = (
+ el.conditions as Record<
+ string,
+ string | { [K in PermissionConditionOperators]: string | string[] }
+ >
+ )[field];
- return Object.keys(operators).map((operator, operatorIndex) => (
- <li
- key={`Forbidden-error-details-${index + 1}-${
- fieldIndex + 1
- }-${operatorIndex + 1}`}
- >
+ const formattedFieldName = camelCaseToSpaces(field).toLowerCase();
+ if (typeof operators === "string") {
+ return (
+ <li key={`Forbidden-error-details-${index + 1}-${fieldIndex + 1}`}>
<span className="font-bold capitalize">{formattedFieldName}</span>{" "}
- <span className="text-mineshaft-200">
- {
- formatedConditionsOperatorNames[
- operator as PermissionConditionOperators
- ]
- }
- </span>{" "}
- <span className="text-yellow-600">
- {operators[operator as PermissionConditionOperators].toString()}
- </span>
+ <span className="text-mineshaft-200">equal to</span>{" "}
+ <span className="text-yellow-600">{operators}</span>
</li>
- ));
- })}
- </ul>
- )}
- </div>
- );
- })}
- </div>
- </ModalContent>
- </Modal>
- ) : undefined,
- copyActions: [
- {
- value: serverResponse.reqId,
- name: "Request ID",
- label: `Request ID: ${serverResponse.reqId}`
- }
- ]
- },
- { closeOnClick: false }
- );
+ );
+ }
+
+ return Object.keys(operators).map((operator, operatorIndex) => (
+ <li
+ key={`Forbidden-error-details-${index + 1}-${
+ fieldIndex + 1
+ }-${operatorIndex + 1}`}
+ >
+ <span className="font-bold capitalize">{formattedFieldName}</span>{" "}
+ <span className="text-mineshaft-200">
+ {
+ formatedConditionsOperatorNames[
+ operator as PermissionConditionOperators
+ ]
+ }
+ </span>{" "}
+ <span className="text-yellow-600">
+ {operators[operator as PermissionConditionOperators].toString()}
+ </span>
+ </li>
+ ));
+ })}
+ </ul>
+ )}
+ </div>
+ );
+ })}
+ </div>
+ </ModalContent>
+ </Modal>
+ ) : undefined,
+ copyActions: [
+ {
+ value: serverResponse.reqId,
+ name: "Request ID",
+ label: `Request ID: ${serverResponse.reqId}`
+ }
+ ]
+ });
return;
}
const errorMessage =