Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
requested changes
Daniel Hougaard0defe13771ca
diff --git a/frontend/src/components/secrets/SecretReferenceDetails/SecretReferenceDetails.tsx b/frontend/src/components/secrets/SecretReferenceDetails/SecretReferenceDetails.tsxindex 8e777755ea..34996928f8 100644--- a/frontend/src/components/secrets/SecretReferenceDetails/SecretReferenceDetails.tsx+++ b/frontend/src/components/secrets/SecretReferenceDetails/SecretReferenceDetails.tsx@@ -193,8 +193,8 @@ const SecretDependencyTree = ({ secretPath, environment, secretKey }: Props) =>const flowData = useMemo(() => {if (!tree || tree.children.length === 0) return null;- return convertDependencyTreeToFlow(tree, secretKey);- }, [tree, secretKey]);+ return convertDependencyTreeToFlow(tree);+ }, [tree]);useEffect(() => {if (error instanceof AxiosError) {@@ -255,7 +255,7 @@ const SecretDependencyTree = ({ secretPath, environment, secretKey }: Props) =>fitViewfitViewOptions={{ padding: 0.3 }}minZoom={0.1}- proOptions={{ hideAttribution: true }}+ proOptions={{ hideAttribution: false }}><Background color="#5d5f64" bgColor="#111419" variant={BackgroundVariant.Dots} /><Controls position="bottom-left" showInteractive={false} />@@ -264,7 +264,7 @@ const SecretDependencyTree = ({ secretPath, environment, secretKey }: Props) =>)}</div><div className="mt-2 text-xs text-mineshaft-400">- Shows secrets that depend on this secret. Each level references the one below it.+ Shows secrets that depend on this secret. Each level is referenced by the one above it.</div></div>);diff --git a/frontend/src/components/secrets/SecretReferenceDetails/nodes/SecretNode.tsx b/frontend/src/components/secrets/SecretReferenceDetails/nodes/SecretNode.tsxindex a108b3090b..1521af01f6 100644--- a/frontend/src/components/secrets/SecretReferenceDetails/nodes/SecretNode.tsx+++ b/frontend/src/components/secrets/SecretReferenceDetails/nodes/SecretNode.tsx@@ -1,9 +1,9 @@/* eslint-disable no-nested-ternary */import { useCallback, useRef, useState } from "react";-import { faKey, faQuestionCircle } from "@fortawesome/free-solid-svg-icons";+import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { Handle, NodeProps, Position } from "@xyflow/react";-import { FolderIcon, LayersIcon } from "lucide-react";+import { FolderIcon, KeyIcon, LayersIcon } from "lucide-react";import { twMerge } from "tailwind-merge";import { Tooltip } from "@app/components/v2";@@ -17,17 +17,38 @@ export const SecretNode = ({ data }: NodeProps & { data: SecretNodeData }) => {const capitalizedEnv = environment.charAt(0).toUpperCase() + environment.slice(1);const pathTextRef = useRef<HTMLSpanElement>(null);+ const envTextRef = useRef<HTMLSpanElement>(null);const [isPathTruncated, setIsPathTruncated] = useState(false);+ const [isEnvTruncated, setIsEnvTruncated] = useState(false);- const checkTruncation = useCallback(() => {+ const checkPathTruncation = useCallback(() => {const el = pathTextRef.current;if (el) {setIsPathTruncated(el.scrollWidth > el.clientWidth);}}, []);+ const checkEnvTruncation = useCallback(() => {+ const el = envTextRef.current;+ if (el) {+ setIsEnvTruncated(el.scrollWidth > el.clientWidth);+ }+ }, []);++ const envBadge = (+ <Badge+ variant="neutral"+ className="max-w-28 min-w-[3.25rem]"+ isTruncatable+ onMouseEnter={checkEnvTruncation}+ >+ <LayersIcon className="size-3" />+ <span ref={envTextRef}>{capitalizedEnv}</span>+ </Badge>+ );+const pathBadge = (- <Badge variant="neutral" isTruncatable onMouseEnter={checkTruncation}>+ <Badge variant="neutral" isTruncatable onMouseEnter={checkPathTruncation}><FolderIcon /><span ref={pathTextRef}>{secretPath}</span></Badge>@@ -65,7 +86,7 @@ export const SecretNode = ({ data }: NodeProps & { data: SecretNodeData }) => {variant={isCircular ? "danger" : isRoot ? "project" : "neutral"}className="!aspect-square h-auto !w-auto !min-w-0 shrink-0 self-stretch">- <FontAwesomeIcon icon={faKey} />+ <KeyIcon className="size-4" /></Badge><div className="flex min-w-0 flex-col"><span@@ -77,10 +98,13 @@ export const SecretNode = ({ data }: NodeProps & { data: SecretNodeData }) => {{secretKey}</span><div className="mt-0.5 flex items-center gap-1.5">- <Badge variant="neutral">- <LayersIcon className="size-3" />- {capitalizedEnv}- </Badge>+ {isEnvTruncated ? (+ <Tooltip className="max-w-xs text-xs break-all" content={capitalizedEnv}>+ {envBadge}+ </Tooltip>+ ) : (+ envBadge+ )}{isPathTruncated ? (<Tooltip className="max-w-xs text-xs break-all" content={secretPath}>{pathBadge}diff --git a/frontend/src/components/secrets/SecretReferenceDetails/utils/convertToFlowElements.ts b/frontend/src/components/secrets/SecretReferenceDetails/utils/convertToFlowElements.tsindex 463752220e..4ef0a8bc0a 100644--- a/frontend/src/components/secrets/SecretReferenceDetails/utils/convertToFlowElements.ts+++ b/frontend/src/components/secrets/SecretReferenceDetails/utils/convertToFlowElements.ts@@ -4,7 +4,7 @@ import { TSecretDependencyTreeNode } from "@app/hooks/api/secrets/types";import { positionElements } from "./positionElements";-const NODE_WIDTH = 200;+const NODE_WIDTH = 260;const NODE_HEIGHT = 58;export type SecretNodeData = {@@ -17,97 +17,8 @@ export type SecretNodeData = {const makeNodeKey = (env: string, path: string, key: string) => `${env}:${path}:${key}`;-// Invert dependency tree so leaf nodes become roots-const invertDependencyTree = (tree: TSecretDependencyTreeNode): TSecretDependencyTreeNode[] => {- const paths: TSecretDependencyTreeNode[][] = [];-- const collectPaths = (- node: TSecretDependencyTreeNode,- currentPath: TSecretDependencyTreeNode[],- visited: Set<string>- ) => {- const nodeKey = makeNodeKey(node.environment, node.secretPath, node.key);-- if (visited.has(nodeKey)) {- if (currentPath.length > 0) {- paths.push([...currentPath, node]);- }- return;- }-- const newPath = [...currentPath, node];- const newVisited = new Set([...visited, nodeKey]);-- if (node.children.length === 0) {- paths.push(newPath);- } else {- node.children.forEach((child) => collectPaths(child, newPath, newVisited));- }- };-- collectPaths(tree, [], new Set());-- if (paths.length === 0) return [];-- const invertedRoots: Map<string, TSecretDependencyTreeNode> = new Map();-- paths.forEach((path) => {- const reversed = [...path].reverse();- let currentNode: TSecretDependencyTreeNode | null = null;-- reversed.forEach((node, idx) => {- const nodeKey = makeNodeKey(node.environment, node.secretPath, node.key);-- if (idx === 0) {- if (invertedRoots.has(nodeKey)) {- currentNode = invertedRoots.get(nodeKey)!;- } else {- currentNode = {- key: node.key,- environment: node.environment,- secretPath: node.secretPath,- children: []- };- invertedRoots.set(nodeKey, currentNode);- }- } else if (currentNode) {- const existingChild = currentNode.children.find(- (c) =>- c.key === node.key &&- c.environment === node.environment &&- c.secretPath === node.secretPath- );-- if (existingChild) {- currentNode = existingChild;- } else {- const newNode: TSecretDependencyTreeNode = {- key: node.key,- environment: node.environment,- secretPath: node.secretPath,- children: []- };- currentNode.children.push(newNode);- currentNode = newNode;- }- }- });- });-- return Array.from(invertedRoots.values());-};--// Walk the dependency tree (incoming references) and produce React Flow elements-export const convertDependencyTreeToFlow = (- tree: TSecretDependencyTreeNode,- rootSecretKey: string-) => {- const invertedRoots = invertDependencyTree(tree);-- if (invertedRoots.length === 0) {- return { nodes: [], edges: [] };- }-+// Walk the dependency tree and produce React Flow elements with root at the top+export const convertDependencyTreeToFlow = (tree: TSecretDependencyTreeNode) => {const nodes: Node<SecretNodeData>[] = [];const edges: Edge[] = [];@@ -120,7 +31,7 @@ export const convertDependencyTreeToFlow = (const nodeKey = makeNodeKey(node.environment, node.secretPath, node.key);const isCircular = visited.has(nodeKey);const nodeId = parentId ? `${parentId}>${nodeKey}` : nodeKey;- const isOriginalRoot = node.key === rootSecretKey && depth > 0;+ const isRoot = depth === 0;nodes.push({id: nodeId,@@ -132,16 +43,16 @@ export const convertDependencyTreeToFlow = (secretKey: node.key,environment: node.environment,secretPath: node.secretPath,- isRoot: isOriginalRoot,+ isRoot,isCircular}});if (parentId) {edges.push({- id: `e-${parentId}-${nodeId}`,- source: parentId,- target: nodeId,+ id: `e-${nodeId}-${parentId}`,+ source: nodeId,+ target: parentId,type: "secretEdge",markerEnd: { type: MarkerType.Arrow, color: isCircular ? "#ef4444" : "#707174" },data: { isCircular }@@ -154,7 +65,7 @@ export const convertDependencyTreeToFlow = (}};- invertedRoots.forEach((root) => walk(root, undefined, 0, new Set()));+ walk(tree, undefined, 0, new Set());return positionElements(nodes, edges);};