Skip to content

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

improvements: address more feedback

Scott Wilsonc6c3f2c4107a
diff --git a/frontend/src/hooks/api/dashboard/queries.tsx b/frontend/src/hooks/api/dashboard/queries.tsx
index 0d2a0b8be1..3866c63373 100644
--- a/frontend/src/hooks/api/dashboard/queries.tsx
+++ b/frontend/src/hooks/api/dashboard/queries.tsx
@@ -223,7 +223,7 @@ export const useGetProjectSecretsOverview = (
environments
});
- queryClient.resetQueries({
+ queryClient.invalidateQueries({
queryKey: dashboardKeys.getSecretValuesRoot()
});
@@ -335,7 +335,7 @@ export const useGetProjectSecretsDetails = (
tags
});
- queryClient.resetQueries({
+ queryClient.invalidateQueries({
queryKey: dashboardKeys.getSecretValuesRoot()
});
diff --git a/frontend/src/hooks/api/secrets/queries.tsx b/frontend/src/hooks/api/secrets/queries.tsx
index 4eb2ba22fb..95d0b9cdff 100644
--- a/frontend/src/hooks/api/secrets/queries.tsx
+++ b/frontend/src/hooks/api/secrets/queries.tsx
@@ -6,6 +6,7 @@ import axios from "axios";
import { createNotification } from "@app/components/notifications";
import { apiRequest } from "@app/config/request";
import { useToggle } from "@app/hooks/useToggle";
+import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem";
import { ERROR_NOT_ALLOWED_READ_SECRETS } from "./constants";
import {
@@ -81,7 +82,7 @@ export const mergePersonalSecrets = (rawSecrets: SecretV3Raw[]) => {
id: el.id,
env: el.environment,
key: el.secretKey,
- value: el.secretValue,
+ value: el.secretValueHidden ? HIDDEN_SECRET_VALUE : el.secretValue,
secretValueHidden: el.secretValueHidden,
tags: el.tags || [],
comment: el.secretComment || "",
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx
index 9046f2ea7c..a6ed5fc58d 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx
@@ -151,7 +151,7 @@ export const SecretEditRow = ({
formState: { isDirty, isSubmitting }
} = useForm({
defaultValues: {
- value: (secretValueData?.valueOverride ?? secretValueData?.value) || null
+ value: secretValueData?.valueOverride ?? secretValueData?.value ?? (defaultValue || null)
}
});
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx
index 953353e5f2..f6712e1fc5 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx
@@ -47,10 +47,12 @@ import {
useGetWsTags
} from "@app/hooks/api";
import { useGetProjectSecretsDetails } from "@app/hooks/api/dashboard";
+import { dashboardKeys } from "@app/hooks/api/dashboard/queries";
import { DashboardSecretsOrderBy } from "@app/hooks/api/dashboard/types";
import { useGetFolderCommitsCount } from "@app/hooks/api/folderCommits";
import { OrderByDirection } from "@app/hooks/api/generic/types";
import { ProjectVersion } from "@app/hooks/api/projects/types";
+import { queryClient } from "@app/hooks/api/reactQuery";
import { PendingAction } from "@app/hooks/api/secretFolders/types";
import { useCreateCommit } from "@app/hooks/api/secrets/mutations";
import { SecretV3RawSanitized } from "@app/hooks/api/types";
@@ -152,6 +154,10 @@ const Page = () => {
}
}, [isBatchMode, projectId, environment, secretPath, loadPendingChanges]);
+ useEffect(() => {
+ if (isVisible) setIsVisible(false);
+ }, [environment]);
+
const canReadSecret = hasSecretReadValueOrDescribePermission(
permission,
ProjectPermissionSecretActions.DescribeSecret,
@@ -335,6 +341,24 @@ const Page = () => {
pendingChanges: changes,
message
});
+
+ if (!isProtectedBranch) {
+ pendingChanges.secrets.forEach((secret) => {
+ if (secret.type === "update" && secret.secretValue !== undefined) {
+ queryClient.setQueryData(
+ dashboardKeys.getSecretValue({
+ projectId,
+ environment,
+ secretPath,
+ secretKey: secret.newSecretName ?? secret.secretKey,
+ isOverride: false
+ }),
+ { value: secret.secretValue }
+ );
+ }
+ });
+ }
+
createNotification({
text: isProtectedBranch
? "Requested changes have been sent for review"
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx
index 64367a7d10..06fecf169c 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx
@@ -54,6 +54,7 @@ export interface PendingSecretDelete extends BasePendingChange {
type: PendingAction.Delete;
secretKey: string;
secretValue: string;
+ secretValueHidden: boolean;
}
// Folder-related change types
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx
index 59cceb9bbf..dbccd93e03 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx
@@ -13,6 +13,7 @@ import { AnimatePresence, motion } from "framer-motion";
import { Badge, Button, Input, Modal, ModalContent } from "@app/components/v2";
import { PendingAction } from "@app/hooks/api/secretFolders/types";
import { SecretVersionDiffView } from "@app/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView";
+import { HIDDEN_SECRET_VALUE_API_MASK } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem";
import {
PendingChange,
@@ -105,7 +106,12 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => {
version: 1, // placeholder, not used
secretKey: change.newSecretName ? existingSecret.key : undefined,
secretValue:
- change.secretValue !== undefined ? (change.originalValue ?? "") : undefined,
+ // eslint-disable-next-line no-nested-ternary
+ change.secretValue !== undefined
+ ? change.existingSecret.secretValueHidden
+ ? HIDDEN_SECRET_VALUE_API_MASK
+ : (change.originalValue ?? "")
+ : undefined,
tags: change.tags ? (existingSecret.tags?.map((tag) => tag.slug) ?? []) : undefined,
secretMetadata: change.secretMetadata ? existingSecret.secretMetadata : undefined,
skipMultilineEncoding:
@@ -130,7 +136,7 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => {
}
if (change.type === PendingAction.Delete) {
- const { secretKey, secretValue } = change;
+ const { secretKey, secretValue, secretValueHidden } = change;
return (
<SecretVersionDiffView
onDiscard={onDiscard}
@@ -143,7 +149,12 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => {
{
version: 1, // placeholder, not used
secretKey,
- secretValue: secretValue || undefined
+ // eslint-disable-next-line no-nested-ternary
+ secretValue: secretValue
+ ? secretValueHidden
+ ? HIDDEN_SECRET_VALUE_API_MASK
+ : secretValue
+ : undefined
}
]
}}
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx
index e8894cb796..6191e2a186 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx
@@ -212,7 +212,8 @@ export const SecretItem = memo(
reset,
getValues,
trigger,
- formState: { isDirty, isSubmitting, errors }
+ formState: { isDirty, isSubmitting, errors },
+ getFieldState
} = useForm<TFormSchema>({
defaultValues: {
...secret,
@@ -497,7 +498,7 @@ export const SecretItem = memo(
tabIndex={0}
role="button"
>
- {secretValueHidden && !isOverridden && !isPending && (
+ {secretValueHidden && !getFieldState("value").isDirty && (
<Tooltip
content={`You do not have access to view the current value${canEditSecretValue && !isRotatedSecret ? ", but you can set a new one" : "."}`}
>
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
index 010d6a4e24..4fc314bdd4 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
@@ -466,7 +466,12 @@ export const SecretListView = ({
);
const handleSecretDelete = useCallback(async () => {
- const { key, id: secretId, value } = popUp.deleteSecret?.data as SecretV3RawSanitized;
+ const {
+ key,
+ id: secretId,
+ value,
+ secretValueHidden
+ } = popUp.deleteSecret?.data as SecretV3RawSanitized;
try {
if (isBatchMode) {
const deleteChange: PendingSecretDelete = {
@@ -475,7 +480,8 @@ export const SecretListView = ({
secretKey: key,
secretValue: value || "",
timestamp: Date.now(),
- resourceType: "secret"
+ resourceType: "secret",
+ secretValueHidden
};
addPendingChange(deleteChange, {