Skip to content

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

improvements: fix commit changes with value retrieval

Scott Wilsonf1f391f89b2c
diff --git a/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx b/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx
index 8c26dfc819..347be1b4f9 100644
--- a/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx
+++ b/frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx
@@ -55,6 +55,8 @@ type Props = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange" | "val
secretPath?: string;
environment?: string;
containerClassName?: string;
+ isLoadingValue?: boolean;
+ isErrorLoadingValue?: boolean;
};
type ReferenceItem = {
diff --git a/frontend/src/components/v2/SecretInput/SecretInput.tsx b/frontend/src/components/v2/SecretInput/SecretInput.tsx
index c320bb0af8..60ab5848f7 100644
--- a/frontend/src/components/v2/SecretInput/SecretInput.tsx
+++ b/frontend/src/components/v2/SecretInput/SecretInput.tsx
@@ -7,7 +7,16 @@ import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPa
const REGEX = /(\${([a-zA-Z0-9-_.]+)})/g;
-const syntaxHighlight = (content?: string | null, isVisible?: boolean, isImport?: boolean) => {
+const syntaxHighlight = (
+ content?: string | null,
+ isVisible?: boolean,
+ isImport?: boolean,
+ isLoadingValue?: boolean,
+ isErrorLoadingValue?: boolean
+) => {
+ if (isLoadingValue) return HIDDEN_SECRET_VALUE;
+ if (isErrorLoadingValue)
+ return <span className="ph-no-capture text-red/75">Error loading secret value.</span>;
if (isImport && !content) return "IMPORTED";
if (content === "") return "EMPTY";
if (!content) return "EMPTY";
@@ -48,6 +57,8 @@ type Props = TextareaHTMLAttributes<HTMLTextAreaElement> & {
isDisabled?: boolean;
containerClassName?: string;
canEditButNotView?: boolean;
+ isLoadingValue?: boolean;
+ isErrorLoadingValue?: boolean;
};
const commonClassName = "font-mono text-sm caret-white border-none outline-none w-full break-all";
@@ -65,6 +76,8 @@ export const SecretInput = forwardRef<HTMLTextAreaElement, Props>(
isReadOnly,
onFocus,
canEditButNotView,
+ isLoadingValue,
+ isErrorLoadingValue,
...props
},
ref
@@ -83,7 +96,9 @@ export const SecretInput = forwardRef<HTMLTextAreaElement, Props>(
{syntaxHighlight(
value,
isVisible || (isSecretFocused && !valueAlwaysHidden),
- isImport
+ isImport,
+ isLoadingValue,
+ isErrorLoadingValue
)}
</span>
</code>
@@ -114,7 +129,7 @@ export const SecretInput = forwardRef<HTMLTextAreaElement, Props>(
}}
value={value || ""}
{...props}
- readOnly={isReadOnly}
+ readOnly={isReadOnly || isLoadingValue || isErrorLoadingValue}
/>
</div>
</div>
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx
index 4cccc64802..64367a7d10 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx
@@ -408,7 +408,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>
const mergedUpdate: PendingSecretUpdate = {
...existingUpdate,
secretKey: existingUpdate.secretKey,
- originalValue: existingUpdate.originalValue,
+ originalValue: change.originalValue,
originalComment: existingUpdate.originalComment,
originalSkipMultilineEncoding: existingUpdate.originalSkipMultilineEncoding,
originalTags: existingUpdate.originalTags,
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 f81cd7b2d3..ac72adf439 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx
@@ -105,7 +105,7 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => {
version: 1, // placeholder, not used
secretKey: change.newSecretName ? existingSecret.key : undefined,
secretValue:
- change.secretValue !== undefined ? (existingSecret.value ?? "") : undefined,
+ change.secretValue !== undefined ? (change.originalValue ?? "") : undefined,
tags: change.tags ? (existingSecret.tags?.map((tag) => tag.slug) ?? []) : undefined,
secretMetadata: change.secretMetadata ? existingSecret.secretMetadata : undefined,
skipMultilineEncoding:
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 4b75e84e87..7b3ac9738b 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx
@@ -126,9 +126,7 @@ export const SecretItem = memo(
const [isFieldFocused, setIsFieldFocused] = useToggle();
const queryClient = useQueryClient();
- const canFetchSecretValue =
- // TODO NOTE FOR PR PROGRESS: may need to remove !isPending, messes with key edits not fetching proper value
- !originalSecret.secretValueHidden && !originalSecret.isEmpty && !isPending;
+ const canFetchSecretValue = !originalSecret.secretValueHidden && !originalSecret.isEmpty;
const fetchSecretValueParams = {
environment,
@@ -179,25 +177,25 @@ export const SecretItem = memo(
);
const getDefaultValue = () => {
- if (isLoadingSecretValue) return HIDDEN_SECRET_VALUE;
+ if (isLoadingSecretValue) return undefined;
if (secret.secretValueHidden && !isPending) {
return canEditSecretValue ? HIDDEN_SECRET_VALUE : "";
}
- if (isErrorFetchingSecretValue) return "Error loading secret value...";
+ if (isErrorFetchingSecretValue) return undefined;
return secret.value || "";
};
const getOverrideDefaultValue = () => {
- if (isLoadingSecretValue) return HIDDEN_SECRET_VALUE;
+ if (isLoadingSecretValue) return undefined;
if (secret.secretValueHidden && !isPending) {
return canEditSecretValue ? HIDDEN_SECRET_VALUE : "";
}
- if (isErrorFetchingSecretValue) return "Error loading secret value...";
+ if (isErrorFetchingSecretValue) return undefined;
return secret.valueOverride || "";
};
@@ -510,6 +508,8 @@ export const SecretItem = memo(
control={control}
render={({ field }) => (
<SecretInput
+ isLoadingValue={isLoadingSecretValue}
+ isErrorLoadingValue={isErrorFetchingSecretValue}
key="value-overriden"
isVisible={isVisible}
isReadOnly={isReadOnly}
@@ -530,6 +530,8 @@ export const SecretItem = memo(
control={control}
render={({ field }) => (
<InfisicalSecretInput
+ isLoadingValue={isLoadingSecretValue}
+ isErrorLoadingValue={isErrorFetchingSecretValue}
isReadOnly={isReadOnlySecret}
key="secret-value"
isVisible={isVisible && (!secretValueHidden || isPending)}