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
fix(ui): refine resizable secrets table layout
andrewhuhh04ce11ce0eae
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsxindex 86966afcaa..63c87e7e4a 100644--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx@@ -2535,13 +2535,34 @@ const OverviewPageContent = () => {// }, [debouncedHeaderHeight]);const [tableWidth, setTableWidth] = useState(0);- const [resizedColumns, setResizedColumns] = useState<{ key: string; widths: number[] } | null>(- null- );+ const [storedColumnWidths, setStoredColumnWidths] = useLocalStorageState<+ Record<string, number[]>+ >(`overview-column-widths-${projectId}`, {});const columnResize = useRef<{ index: number; startX: number; widths: number[] } | null>(null);const columnKey = `${isSingleEnvView ? "single" : "multi"}:${visibleEnvs.map(({ id }) => id).join(":")}`;- const columnMinWidth = isSingleEnvView ? 360 : 240;- const columnWidths = resizedColumns?.key === columnKey ? resizedColumns.widths : null;+ const columnMinWidths = isSingleEnvView ? [280, 368] : Array(visibleEnvs.length + 1).fill(240);+ const minColumnTotal = columnMinWidths.reduce((total, width) => total + width, 0);+ const savedWidths = storedColumnWidths?.[columnKey];+ const columnWidths = (() => {+ const hasSavedWidths =+ Array.isArray(savedWidths) &&+ savedWidths.length === columnMinWidths.length &&+ savedWidths.every((width) => Number.isFinite(width) && width > 0);+ const defaultWidth =+ tableWidth >= 40 + minColumnTotal ? (tableWidth - 40) / columnMinWidths.length : 0;+ const widths = columnMinWidths.map((minWidth, index) =>+ Math.max(minWidth, hasSavedWidths ? savedWidths[index] : defaultWidth)+ );+ if (tableWidth < 40 + minColumnTotal) return widths;++ let excess = Math.max(0, widths.reduce((total, width) => total + width, 0) - (tableWidth - 40));+ for (let index = widths.length - 1; index >= 0 && excess > 0; index -= 1) {+ const shrink = Math.min(excess, widths[index] - columnMinWidths[index]);+ widths[index] -= shrink;+ excess -= shrink;+ }+ return widths;+ })();const getCurrentColumnWidths = () =>Array.from(tableRef.current?.querySelectorAll(":scope > table > thead > tr > th") ?? [])@@ -2550,22 +2571,33 @@ const OverviewPageContent = () => {const resizeColumns = (widths: number[], index: number, delta: number) => {const next = [...widths];- const left = Math.max(columnMinWidth, widths[index] + delta);+ const availableWidth = (tableRef.current?.clientWidth ?? 40) - 40;+ const spareWidth = Math.max(+ 0,+ availableWidth - widths.reduce((total, width) => total + width, 0)+ );+ const maxGrowth = widths[index + 1] - columnMinWidths[index + 1] + spareWidth;+ const left = Math.max(+ columnMinWidths[index],+ Math.min(+ widths[index] + delta,+ availableWidth >= minColumnTotal ? widths[index] + maxGrowth : Infinity+ )+ );next[index] = left;if (left < widths[index]) {- const availableWidth = Math.max(- (tableRef.current?.clientWidth ?? 40) - 40,- widths.length * columnMinWidth- );const overflow = Math.max(0,widths.reduce((total, width) => total + width, 0) - availableWidth);next[index + 1] = widths[index + 1] + Math.max(0, widths[index] - left - overflow);} else {- next[index + 1] = Math.max(columnMinWidth, widths[index + 1] - (left - widths[index]));+ next[index + 1] = Math.max(+ columnMinWidths[index + 1],+ widths[index + 1] - (left - widths[index])+ );}- setResizedColumns({ key: columnKey, widths: next });+ setStoredColumnWidths((current) => ({ ...current, [columnKey]: next }));};const resizeHandle = (index: number) => (@@ -2573,7 +2605,8 @@ const OverviewPageContent = () => {type="button"aria-label={`Resize ${index === 0 ? "Name" : visibleEnvs[index - 1].name} column`}title="Drag or use arrow keys to resize"- className="absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none hover:bg-foreground/15 focus-visible:bg-foreground/15 focus-visible:outline-none"+ className="absolute top-0 -right-1 z-20 w-2 cursor-col-resize touch-none focus-visible:outline-2 focus-visible:outline-ring"+ style={{ height: "var(--resize-handle-height, 100%)" }}onPointerDown={(event) => {if (event.button !== 0) return;event.preventDefault();@@ -2632,10 +2665,12 @@ const OverviewPageContent = () => {useEffect(() => {const element = tableRef.current;if (!element) return;- const nameHeader = element.querySelector(":scope > table > thead > tr > th:nth-child(2)");+ const table = element.querySelector<HTMLTableElement>(":scope > table");+ const nameHeader = table?.querySelector("thead > tr > th:nth-child(2)");const handleResize = () => {setTableWidth(element.clientWidth);+ if (table) element.style.setProperty("--resize-handle-height", `${table.offsetHeight}px`);if (nameHeader) {element.style.setProperty("--name-column-width",@@ -2646,6 +2681,7 @@ const OverviewPageContent = () => {const resizeObserver = new ResizeObserver(handleResize);resizeObserver.observe(element);+ if (table) resizeObserver.observe(table);if (nameHeader) resizeObserver.observe(nameHeader);handleResize();@@ -2995,7 +3031,7 @@ const OverviewPageContent = () => {className="w-full table-fixed border-separate border-spacing-0 [&_tbody>tr>td:nth-child(2)]:pl-1 [&_thead>tr>th:nth-child(2)>button]:pl-1"containerClassName="overscroll-x-none rounded-t-none"style={{- minWidth: 40 + (isSingleEnvView ? 2 * 360 : (visibleEnvs.length + 1) * 240),+ minWidth: 40 + minColumnTotal,width: columnWidths? `max(100%, ${40 + columnWidths.reduce((total, width) => total + width, 0)}px)`: undefined@@ -3012,8 +3048,8 @@ const OverviewPageContent = () => {)))}</colgroup>- <TableHeader>- <TableRow className="h-10 has-[>th:nth-child(2):hover]:[&>th:nth-child(-n+2)]:bg-foreground/5">+ <TableHeader className="relative z-20">+ <TableRow className="h-10 has-[>th:nth-child(2):hover]:[&>th:nth-child(-n+2)]:bg-container-hover"><TableHeadclassName={twMerge(!isSingleEnvView && "sticky",@@ -3033,8 +3069,10 @@ const OverviewPageContent = () => {</TableHead><TableHeadclassName={twMerge(- isSingleEnvView ? "relative" : "sticky left-10",- "z-10 min-w-[240px] border-r bg-container p-0"+ isSingleEnvView+ ? "relative min-w-[280px]"+ : "sticky left-10 min-w-[240px]",+ "z-10 border-r bg-container p-0")}><DropdownMenu>@@ -3044,7 +3082,7 @@ const OverviewPageContent = () => {className="flex h-full w-full cursor-pointer items-center justify-between px-3 text-left focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"aria-label={`Sort secrets. Current order: ${activeSecretSort?.label ?? "Name (A to Z)"}`}>- <span className="text-foreground">Name</span>+ <span className="text-sm font-medium text-muted">Name</span><ChevronDownIcon className="size-3.5 shrink-0 text-muted" /></button></DropdownMenuTrigger>@@ -3087,7 +3125,7 @@ const OverviewPageContent = () => {type="button"title={name}aria-label={`Open ${name} environment menu`}- className="flex h-full w-full min-w-[240px] cursor-pointer items-center justify-center gap-x-2 px-3 hover:bg-foreground/5 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"+ className="flex h-full w-full min-w-[240px] cursor-pointer items-center justify-center gap-x-2 px-3 text-sm font-medium text-muted hover:bg-foreground/5 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"><span className="min-w-0 truncate">{name}</span><ChevronDownIcon className="size-3.5 shrink-0" />@@ -3187,7 +3225,7 @@ const OverviewPageContent = () => {);})) : (- <TableHead className="min-w-[240px]">+ <TableHead className="min-w-[368px] text-sm font-medium text-muted"><div className="flex w-full items-center justify-between gap-2">Value<div className="flex items-center gap-2">diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/QuickAddSecretRow/QuickAddSecretRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/QuickAddSecretRow/QuickAddSecretRow.tsxindex 896307039a..4993a8dd0b 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/QuickAddSecretRow/QuickAddSecretRow.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/QuickAddSecretRow/QuickAddSecretRow.tsx@@ -85,7 +85,7 @@ export const QuickAddSecretRow = ({setValueEditorStyle({left,- width: Math.max(tableContainer.clientWidth - left, 0)+ width: Math.max(tableContainer.clientWidth - left, 240)});};diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsxindex 7146843b15..0cc7deb1ae 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretEditTableRow.tsx@@ -945,32 +945,38 @@ export const SecretEditTableRow = ({control={control}name="key"render={({ field, fieldState: { error } }) => (- <Input- autoComplete="off"- readOnly={isPendingDelete || isImportedSecret || isManagedSecret || !canEditSecretValue}- placeholder={error?.message || "Secret name"}- title={field.value ?? secretName}- isError={Boolean(error)}- {...field}- value={field.value ?? ""}- className={twMerge(- "h-auto w-full rounded-none border-0 bg-transparent px-0 py-0 text-foreground shadow-none placeholder:text-danger focus-visible:border-transparent focus-visible:ring-0",- isPendingDelete && "text-danger/75 line-through"- )}- onChange={(event) => {- const value = currentProject?.autoCapitalization- ? event.currentTarget.value.toUpperCase()- : event.currentTarget.value;- field.onChange(value);- }}- onFocus={() => setIsFieldFocused.on()}- onKeyDown={handleEditShortcut}- onBlur={(e) => {- field.onBlur();- if (!isBatchMode && field.onChange) field.onChange(e);- setIsFieldFocused.off();- }}- />+ <Tooltip open={isFieldFocused ? false : undefined}>+ <TooltipTrigger asChild>+ <Input+ autoComplete="off"+ readOnly={+ isPendingDelete || isImportedSecret || isManagedSecret || !canEditSecretValue+ }+ placeholder={error?.message || "Secret name"}+ isError={Boolean(error)}+ {...field}+ value={field.value ?? ""}+ className={twMerge(+ "h-auto w-full truncate rounded-none border-0 bg-transparent px-0 py-0 text-foreground shadow-none placeholder:text-danger focus-visible:border-transparent focus-visible:ring-0",+ isPendingDelete && "text-danger/75 line-through"+ )}+ onChange={(event) => {+ const value = currentProject?.autoCapitalization+ ? event.currentTarget.value.toUpperCase()+ : event.currentTarget.value;+ field.onChange(value);+ }}+ onFocus={() => setIsFieldFocused.on()}+ onKeyDown={handleEditShortcut}+ onBlur={(e) => {+ field.onBlur();+ if (!isBatchMode && field.onChange) field.onChange(e);+ setIsFieldFocused.off();+ }}+ />+ </TooltipTrigger>+ <TooltipContent>{field.value ?? secretName}</TooltipContent>+ </Tooltip>)}/>) : null;