Skip to content

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

feat: enhance diff rendering for secrets and folders

Victor Santoscbada8238664
diff --git a/frontend/src/components/secrets/diff/DiffContainer.tsx b/frontend/src/components/secrets/diff/DiffContainer.tsx
index 5cbed0e65f..ae83f3e581 100644
--- a/frontend/src/components/secrets/diff/DiffContainer.tsx
+++ b/frontend/src/components/secrets/diff/DiffContainer.tsx
@@ -4,7 +4,7 @@ import { twMerge } from "tailwind-merge";
import { scrollToFirstChange } from "@app/components/utilities/diff";
export interface DiffContainerProps {
- variant: "added" | "removed";
+ variant?: "added" | "removed";
children: React.ReactNode;
containerRef?: React.RefObject<HTMLDivElement>;
className?: string;
@@ -21,7 +21,12 @@ export const DiffContainer = ({
className,
isSingleLine = false
}: DiffContainerProps) => {
- const backgroundColor = variant === "removed" ? "#120808" : "#081208";
+ const getBackgroundColor = () => {
+ if (!variant) return undefined;
+ return variant === "removed" ? "#120808" : "#081208";
+ };
+
+ const backgroundColor = getBackgroundColor();
useEffect(() => {
if (!isSingleLine && containerRef?.current) {
@@ -36,8 +41,12 @@ export const DiffContainer = ({
if (isSingleLine) {
return (
<div
- className={twMerge("relative rounded-lg border border-mineshaft-600 p-2", className)}
- style={{ backgroundColor }}
+ className={twMerge(
+ "relative rounded-lg border border-mineshaft-600 p-2",
+ !variant && "bg-bunker-800",
+ className
+ )}
+ style={backgroundColor ? { backgroundColor } : undefined}
>
{children}
</div>
@@ -49,9 +58,10 @@ export const DiffContainer = ({
ref={containerRef}
className={twMerge(
"relative max-h-96 thin-scrollbar overflow-x-auto overflow-y-auto rounded-lg border border-mineshaft-600 p-2",
+ !variant && "bg-bunker-800",
className
)}
- style={{ backgroundColor }}
+ style={backgroundColor ? { backgroundColor } : undefined}
>
<div className="w-max min-w-full">{children}</div>
</div>
diff --git a/frontend/src/components/secrets/diff/FieldDiffRenderers.tsx b/frontend/src/components/secrets/diff/FieldDiffRenderers.tsx
index 69689f2627..675894229d 100644
--- a/frontend/src/components/secrets/diff/FieldDiffRenderers.tsx
+++ b/frontend/src/components/secrets/diff/FieldDiffRenderers.tsx
@@ -1,10 +1,14 @@
-import { faKey } from "@fortawesome/free-solid-svg-icons";
+import { faLock } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { twMerge } from "tailwind-merge";
-import { computeWordDiff } from "@app/components/utilities/diff";
+import { computeWordDiff, isSingleLine } from "@app/components/utilities/diff";
import { Tag, Tooltip } from "@app/components/v2";
+import { DiffContainer } from "./DiffContainer";
+import { MultiLineDiff } from "./MultiLineDiff";
+import { SingleLineDiff } from "./SingleLineDiff";
+
// Inline text diff renderer (for Key, Comment, Multi-line Encoding)
export const InlineTextDiff = ({
oldText,
@@ -122,22 +126,26 @@ export const MetadataDiffRenderer = ({
otherMetadata,
isOldVersion
}: {
- metadata?: Array<{ key: string; value: string }>;
- otherMetadata?: Array<{ key: string; value: string }>;
+ metadata?: Array<{ key: string; value: string; isEncrypted?: boolean }>;
+ otherMetadata?: Array<{ key: string; value: string; isEncrypted?: boolean }>;
isOldVersion: boolean;
}) => {
if (!metadata?.length) {
return <p className="text-sm text-mineshaft-300">-</p>;
}
- const otherMetaByKey = new Map(otherMetadata?.map((m) => [m.key, m.value]) ?? []);
+ const otherMetaByKey = new Map(
+ otherMetadata?.map((m) => [m.key, { value: m.value, isEncrypted: m.isEncrypted }]) ?? []
+ );
const otherMetaByValue = new Map(otherMetadata?.map((m) => [m.value, m.key]) ?? []);
return (
<div className="mt-1 flex flex-wrap gap-2 text-sm text-mineshaft-300">
{metadata.map((el) => {
const keyExistsInOther = otherMetaByKey.has(el.key);
- const otherValueForKey = otherMetaByKey.get(el.key);
+ const otherDataForKey = otherMetaByKey.get(el.key);
+ const otherValueForKey = otherDataForKey?.value;
+ const otherIsEncrypted = otherDataForKey?.isEncrypted;
const valueExistsWithDifferentKey =
!keyExistsInOther &&
@@ -149,39 +157,49 @@ export const MetadataDiffRenderer = ({
const isValueChanged = keyExistsInOther && otherValueForKey !== el.value;
const isKeyRenamed = valueExistsWithDifferentKey;
+ const encryptionChanged = keyExistsInOther && el.isEncrypted !== otherIsEncrypted;
+ const encryptionTurnedOff = encryptionChanged && isOldVersion && el.isEncrypted === true;
+ const encryptionTurnedOn = encryptionChanged && !isOldVersion && el.isEncrypted === true;
+
const keyHighlighted = isEntirelyNew || isEntirelyRemoved || isKeyRenamed;
const valueHighlighted = isEntirelyNew || isEntirelyRemoved || isValueChanged;
- const hasAnyChange = keyHighlighted || valueHighlighted;
- const borderColorClass = isOldVersion ? "border-red-500/60" : "border-green-500/60";
+ const hasAnyChange = keyHighlighted || valueHighlighted || encryptionChanged;
+ const borderColorClass = isOldVersion ? "border-red-500" : "border-green-500";
const borderClass = twMerge(
"border",
hasAnyChange && borderColorClass,
!hasAnyChange && "border-mineshaft-500"
);
- // Key: grey background with colored ring if changed
const keyBgClass = twMerge(
"bg-mineshaft-500",
- keyHighlighted &&
- (isOldVersion
- ? "bg-red-500/30 ring-1 ring-red-500/60 ring-inset"
- : "bg-green-500/30 ring-1 ring-green-500/60 ring-inset")
+ keyHighlighted && (isOldVersion ? "bg-red-500/30" : "bg-green-500/30")
);
- // Value: color background if changed
const valueBgClass = twMerge(
valueHighlighted && (isOldVersion ? "bg-red-900/30" : "bg-green-900/30"),
!valueHighlighted && "bg-mineshaft-900"
);
+ const lockIconClass = twMerge(
+ "mr-1",
+ encryptionTurnedOff && "text-red-500",
+ encryptionTurnedOn && "text-green-500",
+ !encryptionTurnedOff && !encryptionTurnedOn && "text-mineshaft-300"
+ );
+
return (
<div key={el.key} className="flex items-center">
<Tag
size="xs"
className={twMerge("mr-0 flex items-center rounded-r-none", borderClass, keyBgClass)}
>
- <FontAwesomeIcon icon={faKey} size="xs" className="mr-1" />
+ {el.isEncrypted && (
+ <Tooltip content="This value is encrypted">
+ <FontAwesomeIcon icon={faLock} size="xs" className={lockIconClass} />
+ </Tooltip>
+ )}
<Tooltip className="max-w-lg break-words whitespace-normal" content={el.key}>
<div className="max-w-[125px] overflow-hidden text-ellipsis whitespace-nowrap">
{el.key}
@@ -208,3 +226,82 @@ export const MetadataDiffRenderer = ({
</div>
);
};
+
+export const SingleLineTextDiffRenderer = ({
+ text,
+ oldText,
+ newText,
+ hasChanges,
+ isOldVersion
+}: {
+ text: string;
+ oldText: string;
+ newText: string;
+ hasChanges: boolean;
+ isOldVersion: boolean;
+}) => {
+ if (!text) {
+ return <span className="text-sm text-mineshaft-300">-</span>;
+ }
+
+ if (!hasChanges) {
+ return (
+ <DiffContainer isSingleLine>
+ <span className="text-sm">{text}</span>
+ </DiffContainer>
+ );
+ }
+
+ const variant = isOldVersion ? "removed" : "added";
+
+ return (
+ <DiffContainer variant={variant} isSingleLine>
+ <SingleLineDiff oldText={oldText} newText={newText} isOldVersion={isOldVersion} />
+ </DiffContainer>
+ );
+};
+
+export const MultiLineTextDiffRenderer = ({
+ text,
+ oldText,
+ newText,
+ hasChanges,
+ isOldVersion,
+ containerRef
+}: {
+ text: string;
+ oldText: string;
+ newText: string;
+ hasChanges: boolean;
+ isOldVersion: boolean;
+ containerRef?: React.RefObject<HTMLDivElement>;
+}) => {
+ if (!text) {
+ return <span className="text-sm text-mineshaft-300">-</span>;
+ }
+
+ if (!hasChanges) {
+ return (
+ <DiffContainer containerRef={containerRef}>
+ <span className="text-sm whitespace-pre-wrap">{text}</span>
+ </DiffContainer>
+ );
+ }
+
+ const variant = isOldVersion ? "removed" : "added";
+ const isBothSingleLine = isSingleLine(oldText) && isSingleLine(newText);
+
+ if (isBothSingleLine) {
+ return (
+ <DiffContainer variant={variant} isSingleLine>
+ <SingleLineDiff oldText={oldText} newText={newText} isOldVersion={isOldVersion} />
+ </DiffContainer>
+ );
+ }
+
+ return (
+ <DiffContainer variant={variant} containerRef={containerRef}>
+ <MultiLineDiff oldText={oldText} newText={newText} isOldVersion={isOldVersion} />
+ </DiffContainer>
+ );
+};
diff --git a/frontend/src/components/secrets/diff/FolderDiffView.tsx b/frontend/src/components/secrets/diff/FolderDiffView.tsx
new file mode 100644
index 0000000000..f7a432ef70
--- /dev/null
+++ b/frontend/src/components/secrets/diff/FolderDiffView.tsx
@@ -0,0 +1,112 @@
+import { useRef } from "react";
+import { faCircleCheck, faCircleXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { MultiLineTextDiffRenderer, SingleLineTextDiffRenderer } from "./FieldDiffRenderers";
+
+export interface FolderVersionData {
+ name?: string;
+ description?: string;
+}
+
+export interface FolderDiffViewProps {
+ operationType: "create" | "update" | "delete";
+ oldVersion?: FolderVersionData;
+ newVersion?: FolderVersionData;
+}
+
+export const FolderDiffView = ({ operationType, oldVersion, newVersion }: FolderDiffViewProps) => {
+ const oldDescriptionDiffContainerRef = useRef<HTMLDivElement>(null);
+ const newDescriptionDiffContainerRef = useRef<HTMLDivElement>(null);
+
+ const oldName = oldVersion?.name ?? "";
+ const newName = newVersion?.name ?? "";
+ const hasNameChanges = oldName !== newName && oldName !== "" && newName !== "";
+
+ const oldDescription = oldVersion?.description ?? "";
+ const newDescription = newVersion?.description ?? "";
+ const hasDescriptionChanges = oldDescription !== newDescription;
+
+ const showOldVersion = operationType === "update" || operationType === "delete";
+ const showNewVersion = operationType === "update" || operationType === "create";
+
+ return (
+ <div className="flex flex-col space-y-4 space-x-0 xl:flex-row xl:space-y-0 xl:space-x-4">
+ {showOldVersion ? (
+ <div className="flex w-full min-w-0 cursor-default flex-col rounded-lg border border-red-600/60 bg-red-600/10 p-4 xl:w-1/2">
+ <div className="mb-4 flex flex-row justify-between">
+ <span className="text-md font-medium">Previous Folder</span>
+ <div className="rounded-full bg-red px-2 pt-[0.2rem] pb-[0.14rem] text-xs font-medium">
+ <FontAwesomeIcon icon={faCircleXmark} className="pr-1 text-white" />
+ Previous
+ </div>
+ </div>
+ <div className="mb-2">
+ <div className="text-sm font-medium text-mineshaft-300">Name</div>
+ <SingleLineTextDiffRenderer
+ text={oldName}
+ oldText={oldName}
+ newText={newName}
+ hasChanges={hasNameChanges}
+ isOldVersion
+ />
+ </div>
+ <div className="mb-2">
+ <div className="text-sm font-medium text-mineshaft-300">Description</div>
+ <MultiLineTextDiffRenderer
+ text={oldDescription}
+ oldText={oldDescription}
+ newText={newDescription}
+ hasChanges={hasDescriptionChanges}
+ isOldVersion
+ containerRef={oldDescriptionDiffContainerRef}
+ />
+ </div>
+ </div>
+ ) : (
+ <div className="flex w-full cursor-default flex-col items-center justify-center rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4 xl:w-1/2">
+ <span className="text-sm text-mineshaft-400">
+ Folder did not exist in the previous version.
+ </span>
+ </div>
+ )}
+
+ {showNewVersion ? (
+ <div className="flex w-full min-w-0 cursor-default flex-col rounded-lg border border-green-600/60 bg-green-600/10 p-4 xl:w-1/2">
+ <div className="mb-4 flex flex-row justify-between">
+ <span className="text-md font-medium">New Folder</span>
+ <div className="rounded-full bg-green-600 px-2 pt-[0.2rem] pb-[0.14rem] text-xs font-medium">
+ <FontAwesomeIcon icon={faCircleCheck} className="pr-1 text-white" />
+ New
+ </div>
+ </div>
+ <div className="mb-2">
+ <div className="text-sm font-medium text-mineshaft-300">Name</div>
+ <SingleLineTextDiffRenderer
+ text={newName}
+ oldText={oldName}
+ newText={newName}
+ hasChanges={hasNameChanges}
+ isOldVersion={false}
+ />
+ </div>
+ <div className="mb-2">
+ <div className="text-sm font-medium text-mineshaft-300">Description</div>
+ <MultiLineTextDiffRenderer
+ text={newDescription}
+ oldText={oldDescription}
+ newText={newDescription}
+ hasChanges={hasDescriptionChanges}
+ isOldVersion={false}
+ containerRef={newDescriptionDiffContainerRef}
+ />
+ </div>
+ </div>
+ ) : (
+ <div className="flex w-full cursor-default flex-col items-center justify-center rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4 xl:w-1/2">
+ <span className="text-sm text-mineshaft-400">Folder will be deleted.</span>
+ </div>
+ )}
+ </div>
+ );
+};
diff --git a/frontend/src/components/secrets/diff/MultiLineDiff.tsx b/frontend/src/components/secrets/diff/MultiLineDiff.tsx
index 1371782043..e3325dbb65 100644
--- a/frontend/src/components/secrets/diff/MultiLineDiff.tsx
+++ b/frontend/src/components/secrets/diff/MultiLineDiff.tsx
@@ -73,8 +73,8 @@ export const MultiLineDiff = ({ oldText, newText, isOldVersion }: MultiLineDiffP
(isOldVersion ? change.removed && !oldExistsInNew : change.added && !newExistsInOld);
const lineClass = isChanged
- ? `flex min-w-full rounded-xs ${
- isOldVersion ? "bg-red-500/30 text-red-300" : "bg-green-500/30 text-green-300"
+ ? `flex min-w-full ${
+ isOldVersion ? "bg-red-500/30 text-red-200" : "bg-green-500/30 text-green-200"
}`
: "flex min-w-full";
diff --git a/frontend/src/components/secrets/diff/SecretDiffView.tsx b/frontend/src/components/secrets/diff/SecretDiffView.tsx
index 6349128da6..5440cd95f4 100644
--- a/frontend/src/components/secrets/diff/SecretDiffView.tsx
+++ b/frontend/src/components/secrets/diff/SecretDiffView.tsx
@@ -3,14 +3,19 @@
import { useRef, useState } from "react";
import { faCircleCheck, faCircleXmark, faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { twMerge } from "tailwind-merge";
import { isSingleLine } from "@app/components/utilities/diff";
-import { SecretInput, Tooltip } from "@app/components/v2";
+import { Tooltip } from "@app/components/v2";
import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem";
import { DiffContainer } from "./DiffContainer";
-import { InlineTextDiff, MetadataDiffRenderer, TagsDiffRenderer } from "./FieldDiffRenderers";
+import {
+ InlineTextDiff,
+ MetadataDiffRenderer,
+ MultiLineTextDiffRenderer,
+ SingleLineTextDiffRenderer,
+ TagsDiffRenderer
+} from "./FieldDiffRenderers";
import { MultiLineDiff } from "./MultiLineDiff";
import { SingleLineDiff } from "./SingleLineDiff";
@@ -20,7 +25,7 @@ export interface SecretVersionData {
secretValueHidden?: boolean;
secretComment?: string;
tags?: Array<{ slug: string; color: string }>;
- secretMetadata?: Array<{ key: string; value: string }>;
+ secretMetadata?: Array<{ key: string; value: string; isEncrypted?: boolean }>;
skipMultilineEncoding?: boolean;
}
@@ -32,82 +37,6 @@ export interface SecretDiffViewProps {
newVersionLabel?: string;
}
-const KeyRenderer = ({
- secretKey,
- oldKey,
- newKey,
- hasChanges,
- isOldVersion
-}: {
- secretKey: string;
- oldKey: string;
- newKey: string;
- hasChanges: boolean;
- isOldVersion: boolean;
-}) => {
- if (!hasChanges) {
- return (
- <div className="rounded border border-mineshaft-600 bg-bunker-800 p-2">
- <span className="text-sm">{secretKey}</span>
- </div>
- );
- }
-
- const variant = isOldVersion ? "removed" : "added";
-
- return (
- <DiffContainer variant={variant} isSingleLine>
- <SingleLineDiff oldText={oldKey} newText={newKey} isOldVersion={isOldVersion} />
- </DiffContainer>
- );
-};
-
-const CommentRenderer = ({
- comment,
- oldComment,
- newComment,
- hasChanges,
- isBothSingleLine,
- isOldVersion,
- containerRef
-}: {
- comment: string;
- oldComment: string;
- newComment: string;
- hasChanges: boolean;
- isBothSingleLine: boolean;
- isOldVersion: boolean;
- containerRef: React.RefObject<HTMLDivElement>;
-}) => {
- if (!comment) {
- return <span className="text-sm text-mineshaft-300">-</span>;
- }
-
- if (!hasChanges) {
- return (
- <div className="max-h-32 thin-scrollbar overflow-y-auto rounded border border-mineshaft-600 bg-bunker-800 p-2">
- <span className="text-sm whitespace-pre-wrap">{comment}</span>
- </div>
- );
- }
-
- const variant = isOldVersion ? "removed" : "added";
-
- if (isBothSingleLine) {
- return (
- <DiffContainer variant={variant} isSingleLine>
- <SingleLineDiff oldText={oldComment} newText={newComment} isOldVersion={isOldVersion} />
- </DiffContainer>
- );
- }
-
- return (
- <DiffContainer variant={variant} containerRef={containerRef}>
- <MultiLineDiff oldText={oldComment} newText={newComment} isOldVersion={isOldVersion} />
- </DiffContainer>
- );
-};
-
const SecretValueRenderer = ({
isOldVersion,
isValueHidden,
@@ -129,69 +58,67 @@ const SecretValueRenderer = ({
}) => {
const [isVisible, setIsVisible] = useState(false);
- if (isValueHidden) {
- return (
- <div className="relative">
- <div className="absolute top-1/2 left-1 z-50 -translate-y-1/2">
+ const variant = isOldVersion ? "removed" : "added";
+
+ // Visibility toggle icon - shown when user can reveal value, or access denied indicator
+ const renderVisibilityIcon = () => {
+ if (isValueHidden) {
+ return (
+ <div className="absolute top-1/2 left-2 z-10 -translate-y-1/2">
<Tooltip
position="right"
content={`You do not have access to view the ${isOldVersion ? "old" : "new"} secret value.`}
>
- <FontAwesomeIcon className="pl-2 text-mineshaft-300" size="sm" icon={faEyeSlash} />
+ <FontAwesomeIcon className="text-mineshaft-300" size="sm" icon={faEyeSlash} />
</Tooltip>
</div>
- <SecretInput
- isReadOnly
- isVisible={isVisible}
- valueAlwaysHidden={isValueHidden}
- value={HIDDEN_SECRET_VALUE}
- containerClassName="border border-mineshaft-600 bg-bunker-700 py-1.5 text-bunker-300 hover:border-primary-400/50 pr-2 pl-8"
- />
- </div>
- );
- }
+ );
+ }
- if (hasValueChanges) {
- const variant = isOldVersion ? "removed" : "added";
- if (isBothSingleLine) {
+ if (value) {
return (
- <DiffContainer variant={variant} isSingleLine>
- <SingleLineDiff oldText={oldValue} newText={newValue} isOldVersion={isOldVersion} />
- </DiffContainer>
+ <div className="absolute top-1.5 right-1.5 z-10">
+ <Tooltip content={isVisible ? "Hide value" : "Reveal value"}>
+ <FontAwesomeIcon
+ icon={isVisible ? faEyeSlash : faEye}
+ className="cursor-pointer rounded-md border border-mineshaft-500 bg-mineshaft-800 p-1.5 text-mineshaft-300 hover:bg-mineshaft-700"
+ onClick={(e) => {
+ e.stopPropagation();
+ setIsVisible(!isVisible);
+ }}
+ />
+ </Tooltip>
+ </div>
);
}
- return (
- <DiffContainer variant={variant} containerRef={containerRef}>
- <MultiLineDiff oldText={oldValue} newText={newValue} isOldVersion={isOldVersion} />
- </DiffContainer>
- );
- }
+ return null;
+ };
+
+ const renderContent = () => {
+ if (!isVisible) {
+ return <span className="text-sm text-bunker-300">{HIDDEN_SECRET_VALUE}</span>;
+ }
+
+ // Show revealed value with diff highlighting if there are changes
+ if (hasValueChanges) {
+ if (isBothSingleLine) {
+ return <SingleLineDiff oldText={oldValue} newText={newValue} isOldVersion={isOldVersion} />;
+ }
+ return <MultiLineDiff oldText={oldValue} newText={newValue} isOldVersion={isOldVersion} />;
+ }
+
+ return <span className="text-sm whitespace-pre-wrap">{value}</span>;
+ };
+
+ const containerVariant = hasValueChanges ? variant : undefined;
return (
<div className="relative">
- <SecretInput
- isReadOnly
- isVisible={isVisible}
- valueAlwaysHidden={isValueHidden || !isVisible}
- value={value ?? HIDDEN_SECRET_VALUE}
- containerClassName={twMerge(
- "border border-mineshaft-600 bg-bunker-700 py-1.5 text-bunker-300 hover:border-primary-400/50",
- isValueHidden ? "pr-2 pl-8" : "px-2"
- )}
- />
- {value && (
- <div className="absolute top-1 right-1">
- <FontAwesomeIcon
- icon={isVisible ? faEyeSlash : faEye}
- className="cursor-pointer rounded-md border border-mineshaft-500 bg-mineshaft-800 p-1.5 text-mineshaft-300 hover:bg-mineshaft-700"
- onClick={(e) => {
- e.stopPropagation();
- setIsVisible(!isVisible);
- }}
- />
- </div>
- )}
+ <DiffContainer variant={containerVariant} containerRef={containerRef} className="pr-8">
+ {renderContent()}
+ </DiffContainer>
+ {renderVisibilityIcon()}
</div>
);
};
@@ -220,7 +147,6 @@ export const SecretDiffView = ({
const oldComment = oldVersion?.secretComment ?? "";
const newComment = newVersion?.secretComment ?? "";
const hasCommentChanges = oldComment !== newComment;
- const isCommentBothSingleLine = isSingleLine(oldComment) && isSingleLine(newComment);
const oldMultiline = String(oldVersion?.skipMultilineEncoding ?? false);
const newMultiline = String(newVersion?.skipMultilineEncoding ?? false);
@@ -245,35 +171,36 @@ export const SecretDiffView = ({
</div>
<div className="mb-2">
<div className="text-sm font-medium text-mineshaft-300">Key</div>
- <KeyRenderer
- secretKey={oldKey}
- oldKey={oldKey}
- newKey={newKey}
+ <SingleLineTextDiffRenderer
+ text={oldKey}
+ oldText={oldKey}
+ newText={newKey}
hasChanges={hasKeyChanges}
isOldVersion
/>
</div>
<div className="mb-2">
<div className="text-sm font-medium text-mineshaft-300">Value</div>
- <SecretValueRenderer
- value={oldVersion?.secretValue}
- isValueHidden={oldVersion?.secretValueHidden}
- isOldVersion
- oldValue={oldSecretValue}
- newValue={newSecretValue}
- hasValueChanges={hasValueChanges}
- isBothSingleLine={isBothSingleLine}
- containerRef={oldDiffContainerRef}
- />
+ {oldVersion?.secretValue && (
+ <SecretValueRenderer
+ value={oldVersion?.secretValue}
+ isValueHidden={oldVersion?.secretValueHidden}
+ isOldVersion
+ oldValue={oldSecretValue}
+ newValue={newSecretValue}
+ hasValueChanges={hasValueChanges}
+ isBothSingleLine={isBothSingleLine}
+ containerRef={oldDiffContainerRef}
+ />
+ )}
</div>
<div className="mb-2">
<div className="text-sm font-medium text-mineshaft-300">Comment</div>
- <CommentRenderer
- comment={oldComment}
- oldComment={oldComment}
- newComment={newComment}
+ <MultiLineTextDiffRenderer
+ text={oldComment}
+ oldText={oldComment}
+ newText={newComment}
hasChanges={hasCommentChanges}
- isBothSingleLine={isCommentBothSingleLine}
isOldVersion
containerRef={oldCommentDiffContainerRef}
/>
@@ -324,35 +251,36 @@ export const SecretDiffView = ({
</div>
<div className="mb-2">
<div className="text-sm font-medium text-mineshaft-300">Key</div>
- <KeyRenderer
- secretKey={newKey}
- oldKey={oldKey}
- newKey={newKey}
+ <SingleLineTextDiffRenderer
+ text={newKey}
+ oldText={oldKey}
+ newText={newKey}
hasChanges={hasKeyChanges}
isOldVersion={false}
/>
</div>
<div className="mb-2">
<div className="text-sm font-medium text-mineshaft-300">Value</div>
- <SecretValueRenderer
- value={newVersion?.secretValue}
- oldValue={oldSecretValue}
- newValue={newSecretValue}
- isValueHidden={newVersion?.secretValueHidden}
- isOldVersion={false}
- hasValueChanges={hasValueChanges}
- isBothSingleLine={isBothSingleLine}
- containerRef={newDiffContainerRef}
- />
+ {newVersion?.secretValue && (
+ <SecretValueRenderer
+ value={newVersion?.secretValue}
+ oldValue={oldSecretValue}
+ newValue={newSecretValue}
+ isValueHidden={newVersion?.secretValueHidden}
+ isOldVersion={false}
+ hasValueChanges={hasValueChanges}
+ isBothSingleLine={isBothSingleLine}
+ containerRef={newDiffContainerRef}
+ />
+ )}
</div>
<div className="mb-2">
<div className="text-sm font-medium text-mineshaft-300">Comment</div>
- <CommentRenderer
- comment={newComment}
- oldComment={oldComment}
- newComment={newComment}
+ <MultiLineTextDiffRenderer
+ text={newComment}
+ oldText={oldComment}
+ newText={newComment}
hasChanges={hasCommentChanges}
- isBothSingleLine={isCommentBothSingleLine}
isOldVersion={false}
containerRef={newCommentDiffContainerRef}
/>
diff --git a/frontend/src/components/secrets/diff/index.ts b/frontend/src/components/secrets/diff/index.ts
index 68c494784c..7de83d1d5f 100644
--- a/frontend/src/components/secrets/diff/index.ts
+++ b/frontend/src/components/secrets/diff/index.ts
@@ -1,6 +1,14 @@
export type { DiffContainerProps } from "./DiffContainer";
export { DiffContainer } from "./DiffContainer";
-export { InlineTextDiff, MetadataDiffRenderer, TagsDiffRenderer } from "./FieldDiffRenderers";
+export {
+ InlineTextDiff,
+ MetadataDiffRenderer,
+ MultiLineTextDiffRenderer,
+ SingleLineTextDiffRenderer,
+ TagsDiffRenderer
+} from "./FieldDiffRenderers";
+export type { FolderDiffViewProps, FolderVersionData } from "./FolderDiffView";
+export { FolderDiffView } from "./FolderDiffView";
export type { MultiLineDiffProps } from "./MultiLineDiff";
export { MultiLineDiff } from "./MultiLineDiff";
export type { SecretDiffViewProps, SecretVersionData } from "./SecretDiffView";
diff --git a/frontend/src/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView/SecretVersionDiffView.tsx b/frontend/src/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView/SecretVersionDiffView.tsx
index eeb44be1c0..3ab4c8807b 100644
--- a/frontend/src/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView/SecretVersionDiffView.tsx
+++ b/frontend/src/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView/SecretVersionDiffView.tsx
@@ -1,10 +1,15 @@
/* eslint-disable no-nested-ternary */
-import { useCallback, useRef, useState } from "react";
+import { useCallback, useState } from "react";
import { faChevronDown, faChevronUp, faTrash } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { twMerge } from "tailwind-merge";
-import { SecretDiffView, SecretVersionData } from "@app/components/secrets/diff";
+import {
+ FolderDiffView,
+ FolderVersionData,
+ SecretDiffView,
+ SecretVersionData
+} from "@app/components/secrets/diff";
import { IconButton, Tooltip } from "@app/components/v2";
export interface Version {
@@ -13,10 +18,6 @@ export interface Version {
[key: string]: any;
}
-type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
-type JsonObject = { [key: string]: JsonValue };
-type JsonArray = JsonValue[];
-
export interface DiffViewItem {
type: "secret" | "folder";
isAdded?: boolean;
@@ -35,457 +36,19 @@ interface SecretVersionDiffViewProps {
onToggleCollapse?: (id: string) => void;
showHeader?: boolean;
customHeader?: JSX.Element;
- excludedFieldsHighlight?: string[];
onDiscard?: VoidFunction;
headerExtra?: JSX.Element;
}
-const isObject = (obj: JsonValue): obj is JsonObject => {
- return obj !== null && typeof obj === "object" && !Array.isArray(obj);
-};
-
-const isArray = (obj: JsonValue): obj is JsonArray => {
- return Array.isArray(obj);
-};
-
-const deepEqual = (a: JsonValue, b: JsonValue): boolean => {
- if (a === b) return true;
- if (a == null || b == null) return false;
- if (typeof a !== typeof b) return false;
-
- if (isArray(a) && isArray(b)) {
- if (a.length !== b.length) return false;
- return a.every((item: JsonValue, index: number) => deepEqual(item, b[index]));
- }
-
- if (isObject(a) && isObject(b)) {
- const keysA = Object.keys(a);
- const keysB = Object.keys(b);
- if (keysA.length !== keysB.length) return false;
- return keysA.every((key) => keysB.includes(key) && deepEqual(a[key], b[key]));
- }
-
- return false;
-};
-
-const getDiffPaths = (oldObj: JsonValue, newObj: JsonValue, path: string = ""): Set<string> => {
- const diffPaths = new Set<string>();
-
- if (oldObj === newObj) return diffPaths;
-
- if (oldObj == null || newObj == null) {
- diffPaths.add(path || "root");
- return diffPaths;
- }
-
- if (typeof oldObj !== typeof newObj) {
- diffPaths.add(path || "root");
- return diffPaths;
- }
-
- if (isArray(oldObj) && isArray(newObj)) {
- return diffPaths;
- }
-
- if (isObject(oldObj) && isObject(newObj)) {
- const allKeys = new Set([...Object.keys(oldObj), ...Object.keys(newObj)]);
-
- allKeys.forEach((key) => {
- const currentPath = path ? `${path}.${key}` : key;
-
- if (path.includes("[")) {
- return;
- }
-
- if (!(key in oldObj) || !(key in newObj) || !deepEqual(oldObj[key], newObj[key])) {
- diffPaths.add(currentPath);
-
- if (
- key in oldObj &&
- key in newObj &&
- (isObject(oldObj[key]) || isArray(oldObj[key])) &&
- (isObject(newObj[key]) || isArray(newObj[key]))
- ) {
- const nestedDiffs = getDiffPaths(oldObj[key], newObj[key], currentPath);
- nestedDiffs.forEach((p) => diffPaths.add(p));
- }
- }
- });
- return diffPaths;
- }
-
- if (oldObj !== newObj) {
- diffPaths.add(path || "root");
- }
-
- return diffPaths;
-};
-
-const getNestedValue = (obj: JsonValue, path: string): JsonValue => {
- if (!path) return obj;
-
- const parts = path.split(/[.[\]]+/).filter(Boolean);
- let current: JsonValue = obj;
-
- parts.forEach((part) => {
- if (current == null) {
- return;
- }
- if (isObject(current)) {
- current = current[part];
- } else if (isArray(current)) {
- const index = parseInt(part, 10);
- if (!Number.isNaN(index)) {
- current = current[index];
- }
- }
- });
-
- return current;
-};
-
-const isPathDifferent = (jsonPath: string, diffPaths: Set<string>): boolean => {
- if (diffPaths.has(jsonPath)) return true;
-
- const diffPathsArray = Array.from(diffPaths);
- return diffPathsArray.some((diffPath) => {
- return (
- jsonPath.startsWith(`${diffPath}.`) ||
- jsonPath.startsWith(`${diffPath}[`) ||
- diffPath.startsWith(`${jsonPath}.`) ||
- diffPath.startsWith(`${jsonPath}[`)
- );
- });
-};
-
-const isContainerActuallyChanged = (
- path: string,
- diffPaths: Set<string>,
- oldObj: JsonValue,
- newObj: JsonValue
-): boolean => {
- if (diffPaths.has(path)) {
- if (oldObj == null || newObj == null) return true;
- if (typeof oldObj !== typeof newObj) return true;
- if (isArray(oldObj) !== isArray(newObj)) return true;
- if (isObject(oldObj) !== isObject(newObj)) return true;
-
- if (!isObject(oldObj) && !isArray(oldObj)) return true;
-
- return false;
- }
-
- if (isArray(oldObj) && isArray(newObj)) {
- return false;
- }
-
- if (isObject(oldObj) && isObject(newObj)) {
- return false;
- }
-
- return oldObj !== newObj;
-};
-
-const renderJsonWithDiffs = (
- obj: JsonValue,
- diffPaths: Set<string>,
- isOldVersion: boolean,
- path: string = "",
- indentLevel: number = 0,
- keyName?: string,
- isLastItem: boolean = false,
- excludedFieldsHighlight: string[] = [],
- oldVersionObj?: JsonValue,
- newVersionObj?: JsonValue
-): JSX.Element => {
- const indent = " ".repeat(indentLevel);
-
- let isDifferent = false;
-
- if (path.includes("[") && oldVersionObj && newVersionObj) {
- const arrayMatch = path.match(/^([^[]+)\[(\d+)\]/);
- if (arrayMatch) {
- const arrayPath = arrayMatch[1];
- const itemIndex = parseInt(arrayMatch[2], 10);
-
- const oldArray = getNestedValue(oldVersionObj, arrayPath);
- const newArray = getNestedValue(newVersionObj, arrayPath);
-
- if (isArray(oldArray) && isArray(newArray)) {
- const currentItem = isOldVersion ? oldArray[itemIndex] : newArray[itemIndex];
-
- if (isOldVersion) {
- isDifferent = !newArray.some((newItem: JsonValue) => deepEqual(currentItem, newItem));
- } else {
- isDifferent = !oldArray.some((oldItem: JsonValue) => deepEqual(currentItem, oldItem));
- }
- } else {
- isDifferent = isPathDifferent(path, diffPaths);
- }
- } else {
- isDifferent = isPathDifferent(path, diffPaths);
- }
- } else {
- isDifferent = isPathDifferent(path, diffPaths);
- }
-
- const getLineClass = (different: boolean) => {
- if (!different) return "flex";
- return isOldVersion
- ? "flex bg-red-500/50 rounded-xs text-red-300"
- : "flex bg-green-500/50 rounded-xs text-green-300";
- };
-
- const prefix = isDifferent ? (isOldVersion ? " -" : " +") : " ";
- const keyDisplay = keyName ? `"${keyName}": ` : "";
- const comma = !isLastItem ? "," : "";
-
- const reactKey = `${path || "root"}-${keyName || "value"}-${indentLevel}-${typeof obj}`;
-
- if (
- obj === null ||
- typeof obj === "string" ||
- typeof obj === "number" ||
- typeof obj === "boolean"
- ) {
- let valueDisplay = "";
- if (obj === null) valueDisplay = "null";
- else if (typeof obj === "string") valueDisplay = `"${obj}"`;
- else valueDisplay = String(obj);
-
- return (
- <div key={reactKey} className={getLineClass(isDifferent)}>
- <div className="w-4 shrink-0">{prefix}</div>
- <div>
- {indent}
- {keyName && <span>{keyDisplay}</span>}
- <span>{valueDisplay}</span>
- {comma}
- </div>
- </div>
- );
- }
-
- if (isArray(obj) && obj.length === 0) {
- return (
- <div key={reactKey} className={getLineClass(isDifferent)}>
- <div className="w-4 shrink-0">{prefix}</div>
- <div>
- {indent}
- {keyName && <span>{keyDisplay}</span>}
- <span>[]</span>
- {comma}
- </div>
- </div>
- );
- }
-
- if (isObject(obj) && Object.keys(obj).length === 0) {
- return (
- <div key={reactKey} className={getLineClass(isDifferent)}>
- <div className="w-4 shrink-0">{prefix}</div>
- <div>
- {indent}
- {keyName && <span>{keyDisplay}</span>}
- <span>{"{}"}</span>
- {comma}
- </div>
- </div>
- );
- }
-
- let isContainerAddedOrRemoved = false;
-
- if (oldVersionObj && newVersionObj) {
- const oldValue = getNestedValue(oldVersionObj, path);
- const newValue = getNestedValue(newVersionObj, path);
-
- if (oldValue == null || newValue == null) {
- isContainerAddedOrRemoved = true;
- } else if (typeof oldValue !== typeof newValue) {
- isContainerAddedOrRemoved = true;
- } else if (isArray(oldValue) !== isArray(newValue)) {
- isContainerAddedOrRemoved = true;
- } else if (isObject(oldValue) !== isObject(newValue)) {
- isContainerAddedOrRemoved = true;
- }
- } else {
- isContainerAddedOrRemoved = isContainerActuallyChanged(
- path,
- diffPaths,
- isOldVersion ? obj : oldVersionObj || null,
- isOldVersion ? newVersionObj || null : obj
- );
- }
-
- if (isArray(obj)) {
- return (
- <div key={reactKey}>
- <div className={getLineClass(isContainerAddedOrRemoved)}>
- <div className="w-4 shrink-0">
- {isContainerAddedOrRemoved ? (isOldVersion ? " -" : " +") : " "}
- </div>
- <div>
- {indent}
- {keyName && <span>{keyDisplay}</span>}
- <span>[</span>
- </div>
- </div>
-
- {obj.map((item: JsonValue, index: number) => {
- const itemPath = path ? `${path}[${index}]` : `[${index}]`;
- const isLast = index === obj.length - 1;
-
- return (
- <div key={`${reactKey}-item-${index + 1}`}>
- {renderJsonWithDiffs(
- item,
- diffPaths,
- isOldVersion,
- itemPath,
- indentLevel + 1,
- undefined,
- isLast,
- excludedFieldsHighlight,
- oldVersionObj,
- newVersionObj
- )}
- </div>
- );
- })}
-
- <div className={getLineClass(isContainerAddedOrRemoved)}>
- <div className="w-4 shrink-0">
- {isContainerAddedOrRemoved ? (isOldVersion ? " -" : " +") : " "}
- </div>
- <div>
- {indent}
- <span>]</span>
- {comma}
- </div>
- </div>
- </div>
- );
- }
-
- if (isObject(obj)) {
- const keys = Object.keys(obj);
-
- return (
- <div key={reactKey}>
- <div className={getLineClass(isContainerAddedOrRemoved)}>
- <div className="w-4 shrink-0">
- {isContainerAddedOrRemoved ? (isOldVersion ? " -" : " +") : " "}
- </div>
- <div>
- {indent}
- {keyName && <span>{keyDisplay}</span>}
- <span>{"{"}</span>
- </div>
- </div>
-
- {keys.map((key, index) => {
- const keyPath = path ? `${path}.${key}` : key;
- const isLast = index === keys.length - 1;
- const propKey = `${reactKey}-prop-${key}`;
-
- return (
- <div key={propKey}>
- {renderJsonWithDiffs(
- obj[key],
- diffPaths,
- isOldVersion,
- keyPath,
- indentLevel + 1,
- key,
- isLast,
- excludedFieldsHighlight,
- oldVersionObj,
- newVersionObj
- )}
- </div>
- );
- })}
-
- <div className={getLineClass(isContainerAddedOrRemoved)}>
- <div className="w-4 shrink-0">
- {isContainerAddedOrRemoved ? (isOldVersion ? " -" : " +") : " "}
- </div>
- <div>
- {indent}
- <span>{"}"}</span>
- </div>
- </div>
- </div>
- );
- }
-
- return (
- <div key={reactKey} className={getLineClass(isDifferent)}>
- <div className="w-4 shrink-0">{prefix}</div>
- <div>
- {indent}
- {keyDisplay}
- {String(obj)}
- {comma}
- </div>
- </div>
- );
-};
-
-const formatAddedJson = (json: JsonValue): JSX.Element => {
- const lines = JSON.stringify(json, null, 2).split("\n");
- return (
- <div className="font-mono text-sm text-green-300">
- {lines.map((line, lineIndex) => {
- const lineKey = `added-${line.slice(0, 30)}-${lineIndex}`;
- return (
- <div key={lineKey} className="flex">
- <div className="w-4 shrink-0">+</div>
- <div>{line}</div>
- </div>
- );
- })}
- </div>
- );
-};
-
-const formatDeletedJson = (json: JsonValue): JSX.Element => {
- const lines = JSON.stringify(json, null, 2).split("\n");
- return (
- <div className="font-mono text-sm text-red-300">
- {lines.map((line, lineIndex) => {
- const lineKey = `deleted-${line.slice(0, 30)}-${lineIndex}`;
- return (
- <div key={lineKey} className="flex">
- <div className="w-4 shrink-0">-</div>
- <div>{line}</div>
- </div>
- );
- })}
- </div>
- );
-};
-
-const cleanVersionForComparison = (version: Version): JsonValue => {
- const { id, version: versionNumber, ...cleanVersion } = version;
- return Object.fromEntries(
- Object.entries(cleanVersion).filter((entry) => typeof entry[1] !== "undefined")
- );
-};
-
export const SecretVersionDiffView = ({
item,
isCollapsed = false,
onToggleCollapse,
showHeader = true,
customHeader,
- excludedFieldsHighlight = ["metadata", "tags"],
onDiscard,
headerExtra
}: SecretVersionDiffViewProps) => {
- const oldContainerRef = useRef<HTMLDivElement>(null);
- const newContainerRef = useRef<HTMLDivElement>(null);
const [internalCollapsed, setInternalCollapsed] = useState(isCollapsed);
const handleToggle = useCallback(() => {
@@ -505,9 +68,6 @@ export const SecretVersionDiffView = ({
const sortedVersions = [...item.versions].sort((a, b) => b.version - a.version);
let oldVersion = null;
let newVersion = null;
- let oldVersionContent = null;
- let newVersionContent = null;
- let diffPaths = new Set<string>();
let operationType: "create" | "update" | "delete" = "update";
if (item.isAdded) operationType = "create";
@@ -519,62 +79,10 @@ export const SecretVersionDiffView = ({
} else {
[newVersion, oldVersion] = sortedVersions;
}
-
- const cleanOldVersion = cleanVersionForComparison(oldVersion);
- const cleanNewVersion = cleanVersionForComparison(newVersion);
- diffPaths = getDiffPaths(cleanOldVersion, cleanNewVersion);
- const hasNoChanges = diffPaths.size === 0;
-
- oldVersionContent = (
- <div className="w-fit min-w-full font-mono text-sm">
- {renderJsonWithDiffs(
- cleanOldVersion,
- diffPaths,
- true,
- "",
- 0,
- undefined,
- false,
- excludedFieldsHighlight,
- cleanOldVersion,
- cleanNewVersion
- )}
- </div>
- );
- newVersionContent = (
- <div
- className={twMerge(
- "relative w-fit min-w-full font-mono text-sm",
- hasNoChanges && "[&>*+*]:opacity-0" // still want to render json to make container equivalent size to old version
- )}
- >
- {hasNoChanges && (
- <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-mineshaft-400">
- <span>No changes</span>
- </div>
- )}
- {renderJsonWithDiffs(
- cleanNewVersion,
- diffPaths,
- false,
- "",
- 0,
- undefined,
- false,
- excludedFieldsHighlight,
- cleanOldVersion,
- cleanNewVersion
- )}
- </div>
- );
} else if (item.isAdded) {
[newVersion] = sortedVersions;
- const cleanNewVersion = cleanVersionForComparison(newVersion);
- newVersionContent = formatAddedJson(cleanNewVersion);
} else if (item.isDeleted) {
[oldVersion] = sortedVersions;
- const cleanOldVersion = cleanVersionForComparison(oldVersion);
- oldVersionContent = formatDeletedJson(cleanOldVersion);
} else {
return null;
}
@@ -609,9 +117,22 @@ export const SecretVersionDiffView = ({
};
};
+ // Convert versions to FolderVersionData format for FolderDiffView
+ const convertToFolderVersionData = (version: Version | null): FolderVersionData | undefined => {
+ if (!version) return undefined;
+
+ return {
+ name: version.name as string | undefined,
+ description: version.description as string | undefined
+ };
+ };
+
const oldSecretData = convertToSecretVersionData(oldVersion);
const newSecretData = convertToSecretVersionData(newVersion);
+ const oldFolderData = convertToFolderVersionData(oldVersion);
+ const newFolderData = convertToFolderVersionData(newVersion);
+
const renderHeader = () => {
if (customHeader) {
return customHeader;
@@ -696,21 +217,11 @@ export const SecretVersionDiffView = ({
newVersion={newSecretData}
/>
) : (
- <div className="flex gap-3">
- <div
- ref={oldContainerRef}
- className="max-h-96 thin-scrollbar flex-1 overflow-auto whitespace-pre"
- >
- {oldVersionContent}
- </div>
- <div className="max-h-96 w-[0.05rem] self-stretch bg-mineshaft-600" />
- <div
- ref={newContainerRef}
- className="max-h-96 thin-scrollbar flex-1 overflow-auto whitespace-pre"
- >
- {newVersionContent}
- </div>
- </div>
+ <FolderDiffView
+ operationType={operationType}
+ oldVersion={oldFolderData}
+ newVersion={newFolderData}
+ />
)}
</div>
)}
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx
index d3172142ba..77409bfab0 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx
@@ -55,6 +55,10 @@ export interface PendingSecretDelete extends BasePendingChange {
secretKey: string;
secretValue: string;
secretValueHidden: boolean;
+ tags: { id: string; slug: string }[];
+ secretMetadata: { key: string; value: string; isEncrypted?: boolean }[];
+ skipMultilineEncoding: boolean | null;
+ comment: string;
}
// 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 10b6dfbda3..c4abdfee48 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx
@@ -153,7 +153,15 @@ const RenderSecretChanges = ({ onDiscard, change, referenceCount }: RenderResour
}
if (change.type === PendingAction.Delete) {
- const { secretKey, secretValue, secretValueHidden } = change;
+ const {
+ secretKey,
+ secretValue,
+ secretValueHidden,
+ tags,
+ secretMetadata,
+ skipMultilineEncoding,
+ comment
+ } = change;
return (
<SecretVersionDiffView
onDiscard={onDiscard}
@@ -171,7 +179,11 @@ const RenderSecretChanges = ({ onDiscard, change, referenceCount }: RenderResour
? secretValueHidden
? HIDDEN_SECRET_VALUE_API_MASK
: secretValue
- : undefined
+ : undefined,
+ tags: tags?.map((tag) => tag.slug),
+ secretMetadata,
+ skipMultilineEncoding,
+ comment
}
]
}}
@@ -375,9 +387,6 @@ export const CommitForm: React.FC<CommitFormProps> = ({
return null;
}
- const hasOnlyFolderChanges =
- pendingChanges.folders.length > 0 && pendingChanges.secrets.length === 0;
-
const handleCommit = async () => {
await onCommit(pendingChanges, commitMessage);
clearAllPendingChanges({
@@ -389,12 +398,8 @@ export const CommitForm: React.FC<CommitFormProps> = ({
setCommitMessage("");
};
- const handleSaveChanges = async () => {
- if (hasOnlyFolderChanges) {
- await handleCommit();
- } else {
- setIsModalOpen(true);
- }
+ const handleSaveChanges = () => {
+ setIsModalOpen(true);
};
return (
@@ -445,7 +450,6 @@ export const CommitForm: React.FC<CommitFormProps> = ({
leftIcon={<FontAwesomeIcon icon={faSave} />}
onClick={handleSaveChanges}
isDisabled={totalChangesCount === 0 || isCommitting}
- isLoading={isCommitting && hasOnlyFolderChanges}
className="px-6"
>
Save Changes
@@ -471,12 +475,12 @@ export const CommitForm: React.FC<CommitFormProps> = ({
</div>
}
subTitle="Write a commit message and review the changes you're about to save."
- className="max-h-[90vh] max-w-[95%] md:max-w-8xl"
+ className="flex h-[calc(100vh-1rem)] max-w-[95%] flex-col md:max-w-8xl"
+ bodyClassName="flex flex-1 flex-col overflow-hidden !max-h-none"
>
- <div className="space-y-6">
- {/* Changes List */}
- <div className="space-y-6">
- <div className="max-h-[50vh] space-y-4 overflow-y-auto">
+ <div className="flex min-h-0 flex-1 flex-col">
+ <div className="min-h-0 flex-1 overflow-y-auto">
+ <div className="space-y-4">
{/* Folder Changes */}
{pendingChanges.folders.length > 0 && (
<div>
@@ -523,40 +527,41 @@ export const CommitForm: React.FC<CommitFormProps> = ({
</div>
</div>
- {/* Commit Message */}
- <div>
- <label className="mb-2 block text-sm font-medium text-mineshaft-200">
- Commit Message
- </label>
- <Input
- value={commitMessage}
- onChange={(e) => setCommitMessage(e.target.value)}
- placeholder="Describe your changes..."
- className="w-full"
- autoFocus
- />
- </div>
+ <div className="shrink-0 space-y-4 border-t border-mineshaft-600 pt-4">
+ {/* Commit Message */}
+ <div>
+ <label className="mb-2 block text-sm font-medium text-mineshaft-200">
+ Commit Message
+ </label>
+ <Input
+ value={commitMessage}
+ onChange={(e) => setCommitMessage(e.target.value)}
+ placeholder="Describe your changes..."
+ className="w-full"
+ autoFocus
+ />
+ </div>
- {/* Action Buttons */}
- <div className="flex justify-end gap-3">
- <Button
- variant="plain"
- colorSchema="secondary"
- onClick={() => setIsModalOpen(false)}
- isDisabled={isCommitting}
- >
- Cancel
- </Button>
- <Button
- onClick={handleCommit}
- isLoading={isCommitting}
- isDisabled={isCommitting}
- leftIcon={<FontAwesomeIcon icon={faCodeCommit} />}
- colorSchema="primary"
- variant="outline_bg"
- >
- {isCommitting ? "Saving..." : "Save Changes"}
- </Button>
+ <div className="flex justify-end gap-3">
+ <Button
+ variant="plain"
+ colorSchema="secondary"
+ onClick={() => setIsModalOpen(false)}
+ isDisabled={isCommitting}
+ >
+ Cancel
+ </Button>
+ <Button
+ onClick={handleCommit}
+ isLoading={isCommitting}
+ isDisabled={isCommitting}
+ leftIcon={<FontAwesomeIcon icon={faCodeCommit} />}
+ colorSchema="primary"
+ variant="outline_bg"
+ >
+ {isCommitting ? "Saving..." : "Save Changes"}
+ </Button>
+ </div>
</div>
</div>
</ModalContent>
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 dfcaecc226..ecdb1127c0 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
@@ -480,7 +480,11 @@ export const SecretListView = ({
key,
id: secretId,
value,
- secretValueHidden
+ secretValueHidden,
+ tags,
+ secretMetadata,
+ skipMultilineEncoding,
+ comment
} = popUp.deleteSecret?.data as SecretV3RawSanitized;
if (isBatchMode) {
const deleteChange: PendingSecretDelete = {
@@ -490,7 +494,11 @@ export const SecretListView = ({
secretValue: value || "",
timestamp: Date.now(),
resourceType: "secret",
- secretValueHidden
+ secretValueHidden,
+ tags: tags || [],
+ secretMetadata: secretMetadata || [],
+ skipMultilineEncoding: skipMultilineEncoding || false,
+ comment: comment || ""
};
addPendingChange(deleteChange, {