mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 09:26:47 +00:00
improvements: fix commit changes with value retrieval
This commit is contained in:
@@ -55,6 +55,8 @@ type Props = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange" | "val
|
|||||||
secretPath?: string;
|
secretPath?: string;
|
||||||
environment?: string;
|
environment?: string;
|
||||||
containerClassName?: string;
|
containerClassName?: string;
|
||||||
|
isLoadingValue?: boolean;
|
||||||
|
isErrorLoadingValue?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ReferenceItem = {
|
type ReferenceItem = {
|
||||||
|
|||||||
@@ -7,7 +7,16 @@ import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPa
|
|||||||
|
|
||||||
const REGEX = /(\${([a-zA-Z0-9-_.]+)})/g;
|
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 (isImport && !content) return "IMPORTED";
|
||||||
if (content === "") return "EMPTY";
|
if (content === "") return "EMPTY";
|
||||||
if (!content) return "EMPTY";
|
if (!content) return "EMPTY";
|
||||||
@@ -48,6 +57,8 @@ type Props = TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|||||||
isDisabled?: boolean;
|
isDisabled?: boolean;
|
||||||
containerClassName?: string;
|
containerClassName?: string;
|
||||||
canEditButNotView?: boolean;
|
canEditButNotView?: boolean;
|
||||||
|
isLoadingValue?: boolean;
|
||||||
|
isErrorLoadingValue?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const commonClassName = "font-mono text-sm caret-white border-none outline-none w-full break-all";
|
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,
|
isReadOnly,
|
||||||
onFocus,
|
onFocus,
|
||||||
canEditButNotView,
|
canEditButNotView,
|
||||||
|
isLoadingValue,
|
||||||
|
isErrorLoadingValue,
|
||||||
...props
|
...props
|
||||||
},
|
},
|
||||||
ref
|
ref
|
||||||
@@ -83,7 +96,9 @@ export const SecretInput = forwardRef<HTMLTextAreaElement, Props>(
|
|||||||
{syntaxHighlight(
|
{syntaxHighlight(
|
||||||
value,
|
value,
|
||||||
isVisible || (isSecretFocused && !valueAlwaysHidden),
|
isVisible || (isSecretFocused && !valueAlwaysHidden),
|
||||||
isImport
|
isImport,
|
||||||
|
isLoadingValue,
|
||||||
|
isErrorLoadingValue
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
</code>
|
</code>
|
||||||
@@ -114,7 +129,7 @@ export const SecretInput = forwardRef<HTMLTextAreaElement, Props>(
|
|||||||
}}
|
}}
|
||||||
value={value || ""}
|
value={value || ""}
|
||||||
{...props}
|
{...props}
|
||||||
readOnly={isReadOnly}
|
readOnly={isReadOnly || isLoadingValue || isErrorLoadingValue}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>
|
|||||||
const mergedUpdate: PendingSecretUpdate = {
|
const mergedUpdate: PendingSecretUpdate = {
|
||||||
...existingUpdate,
|
...existingUpdate,
|
||||||
secretKey: existingUpdate.secretKey,
|
secretKey: existingUpdate.secretKey,
|
||||||
originalValue: existingUpdate.originalValue,
|
originalValue: change.originalValue,
|
||||||
originalComment: existingUpdate.originalComment,
|
originalComment: existingUpdate.originalComment,
|
||||||
originalSkipMultilineEncoding: existingUpdate.originalSkipMultilineEncoding,
|
originalSkipMultilineEncoding: existingUpdate.originalSkipMultilineEncoding,
|
||||||
originalTags: existingUpdate.originalTags,
|
originalTags: existingUpdate.originalTags,
|
||||||
|
|||||||
+1
-1
@@ -105,7 +105,7 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => {
|
|||||||
version: 1, // placeholder, not used
|
version: 1, // placeholder, not used
|
||||||
secretKey: change.newSecretName ? existingSecret.key : undefined,
|
secretKey: change.newSecretName ? existingSecret.key : undefined,
|
||||||
secretValue:
|
secretValue:
|
||||||
change.secretValue !== undefined ? (existingSecret.value ?? "") : undefined,
|
change.secretValue !== undefined ? (change.originalValue ?? "") : undefined,
|
||||||
tags: change.tags ? (existingSecret.tags?.map((tag) => tag.slug) ?? []) : undefined,
|
tags: change.tags ? (existingSecret.tags?.map((tag) => tag.slug) ?? []) : undefined,
|
||||||
secretMetadata: change.secretMetadata ? existingSecret.secretMetadata : undefined,
|
secretMetadata: change.secretMetadata ? existingSecret.secretMetadata : undefined,
|
||||||
skipMultilineEncoding:
|
skipMultilineEncoding:
|
||||||
|
|||||||
+9
-7
@@ -126,9 +126,7 @@ export const SecretItem = memo(
|
|||||||
const [isFieldFocused, setIsFieldFocused] = useToggle();
|
const [isFieldFocused, setIsFieldFocused] = useToggle();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const canFetchSecretValue =
|
const canFetchSecretValue = !originalSecret.secretValueHidden && !originalSecret.isEmpty;
|
||||||
// TODO NOTE FOR PR PROGRESS: may need to remove !isPending, messes with key edits not fetching proper value
|
|
||||||
!originalSecret.secretValueHidden && !originalSecret.isEmpty && !isPending;
|
|
||||||
|
|
||||||
const fetchSecretValueParams = {
|
const fetchSecretValueParams = {
|
||||||
environment,
|
environment,
|
||||||
@@ -179,25 +177,25 @@ export const SecretItem = memo(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const getDefaultValue = () => {
|
const getDefaultValue = () => {
|
||||||
if (isLoadingSecretValue) return HIDDEN_SECRET_VALUE;
|
if (isLoadingSecretValue) return undefined;
|
||||||
|
|
||||||
if (secret.secretValueHidden && !isPending) {
|
if (secret.secretValueHidden && !isPending) {
|
||||||
return canEditSecretValue ? HIDDEN_SECRET_VALUE : "";
|
return canEditSecretValue ? HIDDEN_SECRET_VALUE : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isErrorFetchingSecretValue) return "Error loading secret value...";
|
if (isErrorFetchingSecretValue) return undefined;
|
||||||
|
|
||||||
return secret.value || "";
|
return secret.value || "";
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOverrideDefaultValue = () => {
|
const getOverrideDefaultValue = () => {
|
||||||
if (isLoadingSecretValue) return HIDDEN_SECRET_VALUE;
|
if (isLoadingSecretValue) return undefined;
|
||||||
|
|
||||||
if (secret.secretValueHidden && !isPending) {
|
if (secret.secretValueHidden && !isPending) {
|
||||||
return canEditSecretValue ? HIDDEN_SECRET_VALUE : "";
|
return canEditSecretValue ? HIDDEN_SECRET_VALUE : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isErrorFetchingSecretValue) return "Error loading secret value...";
|
if (isErrorFetchingSecretValue) return undefined;
|
||||||
|
|
||||||
return secret.valueOverride || "";
|
return secret.valueOverride || "";
|
||||||
};
|
};
|
||||||
@@ -510,6 +508,8 @@ export const SecretItem = memo(
|
|||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<SecretInput
|
<SecretInput
|
||||||
|
isLoadingValue={isLoadingSecretValue}
|
||||||
|
isErrorLoadingValue={isErrorFetchingSecretValue}
|
||||||
key="value-overriden"
|
key="value-overriden"
|
||||||
isVisible={isVisible}
|
isVisible={isVisible}
|
||||||
isReadOnly={isReadOnly}
|
isReadOnly={isReadOnly}
|
||||||
@@ -530,6 +530,8 @@ export const SecretItem = memo(
|
|||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<InfisicalSecretInput
|
<InfisicalSecretInput
|
||||||
|
isLoadingValue={isLoadingSecretValue}
|
||||||
|
isErrorLoadingValue={isErrorFetchingSecretValue}
|
||||||
isReadOnly={isReadOnlySecret}
|
isReadOnly={isReadOnlySecret}
|
||||||
key="secret-value"
|
key="secret-value"
|
||||||
isVisible={isVisible && (!secretValueHidden || isPending)}
|
isVisible={isVisible && (!secretValueHidden || isPending)}
|
||||||
|
|||||||
Reference in New Issue
Block a user