Skip to content

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

UI: get back to previous design

adilson4310dca53915
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchModal.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchModal.tsx
index d801004586..d91d378ad7 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchModal.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchModal.tsx
@@ -58,8 +58,8 @@ import { QuickSearchSecretItem } from "./QuickSearchSecretItem";
import {
MetadataMatchType,
MetadataSearchCondition,
- SecretMetadataSearchInput
-} from "./SecretMetadataSearchInput";
+ SecretMetadataSearchBuilder
+} from "./SecretMetadataSearchBuilder";
export type QuickSearchModalProps = {
environments: ProjectEnv[];
@@ -117,6 +117,16 @@ const Content = ({
const [isBuilderOpen, setIsBuilderOpen] = useState(false);
const conditionIdRef = useRef(0);
+ const createCondition = (): MetadataSearchCondition => {
+ conditionIdRef.current += 1;
+ return {
+ id: `cond-${conditionIdRef.current}`,
+ key: "",
+ value: "",
+ operator: SecretMetadataSearchOperator.Is
+ };
+ };
+
const activeConditions = useMemo(
() => metadataConditions.filter((condition) => condition.key.trim() && condition.value.trim()),
[metadataConditions]
@@ -268,38 +278,19 @@ const Content = ({
const handleOpenMetadata = () => {
setIsBuilderOpen(true);
+ setMetadataConditions((prev) => (prev.length ? prev : [createCondition()]));
};
- const handleAddCondition = (
- key: string,
- value: string,
- operator: SecretMetadataSearchOperator
- ) => {
- setMetadataConditions((prev) => {
- // ignore exact duplicates, but allow the same key/value with a different operator
- if (
- prev.some(
- (condition) =>
- condition.key === key && condition.value === value && condition.operator === operator
- )
- ) {
- return prev;
- }
- conditionIdRef.current += 1;
- return [...prev, { id: `cond-${conditionIdRef.current}`, key, value, operator }];
- });
+ const handleAddCondition = () => {
+ setMetadataConditions((prev) => [...prev, createCondition()]);
};
- const handleEditCondition = (
+ const handleUpdateCondition = (
id: string,
- key: string,
- value: string,
- operator: SecretMetadataSearchOperator
+ patch: Partial<Pick<MetadataSearchCondition, "key" | "value">>
) => {
setMetadataConditions((prev) =>
- prev.map((condition) =>
- condition.id === id ? { ...condition, key, value, operator } : condition
- )
+ prev.map((condition) => (condition.id === id ? { ...condition, ...patch } : condition))
);
};
@@ -479,7 +470,7 @@ const Content = ({
<div className="min-h-0 thin-scrollbar flex-1 overflow-y-auto pt-4">
{isBuilderOpen && (
- <SecretMetadataSearchInput
+ <SecretMetadataSearchBuilder
conditions={metadataConditions}
match={metadataMatch}
matchingCount={metadataResultCount}
@@ -487,7 +478,7 @@ const Content = ({
hasActiveConditions={isMetadataMode}
onChangeMatch={setMetadataMatch}
onAddCondition={handleAddCondition}
- onEditCondition={handleEditCondition}
+ onUpdateCondition={handleUpdateCondition}
onRemoveCondition={handleRemoveCondition}
onClear={handleClearMetadata}
onClose={handleCloseBuilder}
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/SecretMetadataSearchBuilder.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/SecretMetadataSearchBuilder.tsx
new file mode 100644
index 0000000000..0963a0086e
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/SecretMetadataSearchBuilder.tsx
@@ -0,0 +1,174 @@
+import { BracesIcon, InfoIcon, PlusIcon, XIcon, ZapIcon } from "lucide-react";
+
+import {
+ Button,
+ IconButton,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupInput,
+ InputGroupText,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
+} from "@app/components/v3";
+import { cn } from "@app/components/v3/utils";
+import { SecretMetadataSearchOperator } from "@app/hooks/api/dashboard/types";
+
+export type MetadataSearchCondition = {
+ id: string;
+ key: string;
+ value: string;
+ // Only "is" exists today; rendered as the static "is" separator between key and value.
+ operator: SecretMetadataSearchOperator;
+};
+
+export type MetadataMatchType = "all" | "any";
+
+type Props = {
+ conditions: MetadataSearchCondition[];
+ match: MetadataMatchType;
+ matchingCount: number;
+ isPending: boolean;
+ hasActiveConditions: boolean;
+ onChangeMatch: (match: MetadataMatchType) => void;
+ onAddCondition: () => void;
+ onUpdateCondition: (
+ id: string,
+ patch: Partial<Pick<MetadataSearchCondition, "key" | "value">>
+ ) => void;
+ onRemoveCondition: (id: string) => void;
+ onClear: () => void;
+ onClose: () => void;
+};
+
+export const SecretMetadataSearchBuilder = ({
+ conditions,
+ match,
+ matchingCount,
+ isPending,
+ hasActiveConditions,
+ onChangeMatch,
+ onAddCondition,
+ onUpdateCondition,
+ onRemoveCondition,
+ onClear,
+ onClose
+}: Props) => {
+ return (
+ <div className="mb-5 rounded-lg border border-border bg-popover">
+ <div className="flex items-center gap-3 border-b border-border px-4 py-3">
+ <BracesIcon className="size-4 text-muted" />
+ <span className="font-medium">Filter by metadata</span>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ className="ml-auto"
+ aria-label="Close metadata filter"
+ onClick={onClose}
+ >
+ <XIcon />
+ </IconButton>
+ </div>
+
+ <div className="p-4">
+ <div className="mb-4 flex flex-wrap items-center gap-3 text-sm text-muted">
+ <span>Match</span>
+ <div className="inline-flex rounded-md border border-border p-0.5">
+ {(["all", "any"] as const).map((option) => (
+ <button
+ key={option}
+ type="button"
+ onClick={() => onChangeMatch(option)}
+ className={cn(
+ "h-6 rounded px-3 text-xs font-semibold tracking-wide transition-colors",
+ match === option
+ ? "bg-project/15 text-project"
+ : "text-muted hover:text-foreground"
+ )}
+ >
+ {option.toUpperCase()}
+ </button>
+ ))}
+ </div>
+ <span>of the conditions below</span>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="cursor-default text-muted">
+ <InfoIcon className="size-3.5" />
+ </span>
+ </TooltipTrigger>
+ <TooltipContent className="max-w-xs">
+ <span className="font-semibold text-project">ALL</span> returns secrets matching every
+ condition (AND). <span className="font-semibold text-project">ANY</span> returns
+ secrets matching at least one condition (OR).
+ </TooltipContent>
+ </Tooltip>
+ </div>
+
+ <div className="mb-3 flex flex-col gap-2.5">
+ {conditions.map((condition) => (
+ <div key={condition.id} className="flex items-center gap-2.5">
+ <InputGroup className="w-52 flex-none">
+ <InputGroupAddon>
+ <InputGroupText className="font-mono">#</InputGroupText>
+ </InputGroupAddon>
+ <InputGroupInput
+ className="font-mono"
+ placeholder="Key"
+ value={condition.key}
+ onChange={(e) => onUpdateCondition(condition.id, { key: e.target.value })}
+ />
+ </InputGroup>
+ <span className="flex h-9 flex-none items-center rounded-md border border-border px-3 font-mono text-sm text-muted">
+ is
+ </span>
+ <InputGroup className="flex-1">
+ <InputGroupInput
+ className="font-mono"
+ placeholder="Value"
+ value={condition.value}
+ onChange={(e) => onUpdateCondition(condition.id, { value: e.target.value })}
+ />
+ </InputGroup>
+ <IconButton
+ variant="ghost"
+ size="sm"
+ className="flex-none text-muted hover:text-danger"
+ aria-label="Remove condition"
+ onClick={() => onRemoveCondition(condition.id)}
+ >
+ <XIcon />
+ </IconButton>
+ </div>
+ ))}
+ </div>
+
+ <Button variant="outline" size="sm" onClick={onAddCondition}>
+ <PlusIcon />
+ Add condition
+ </Button>
+ </div>
+
+ <div className="flex items-center justify-between border-t border-border px-4 py-3">
+ <span className="flex items-center gap-2 text-sm text-muted">
+ <ZapIcon className="size-3.5 text-project" />
+ {hasActiveConditions ? (
+ <span>
+ <span className="font-semibold text-foreground">
+ {isPending ? "…" : matchingCount}
+ </span>{" "}
+ matching {matchingCount === 1 && !isPending ? "secret" : "secrets"}
+ </span>
+ ) : (
+ <span>Add a condition to search</span>
+ )}
+ </span>
+ <div className="flex items-center gap-2">
+ <Button variant="ghost" size="sm" onClick={onClear}>
+ Clear
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/SecretMetadataSearchInput.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/SecretMetadataSearchInput.tsx
deleted file mode 100644
index 22be620090..0000000000
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/SecretMetadataSearchInput.tsx
+++ /dev/null
@@ -1,332 +0,0 @@
-import React, { useEffect, useRef, useState } from "react";
-import { BracesIcon, ChevronDownIcon, InfoIcon, SearchIcon, XIcon, ZapIcon } from "lucide-react";
-
-import {
- Button,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
- IconButton,
- Tooltip,
- TooltipContent,
- TooltipTrigger
-} from "@app/components/v3";
-import { cn } from "@app/components/v3/utils";
-import { SecretMetadataSearchOperator } from "@app/hooks/api/dashboard/types";
-
-export type MetadataSearchCondition = {
- id: string;
- key: string;
- value: string;
- operator: SecretMetadataSearchOperator;
-};
-
-export type MetadataMatchType = "all" | "any";
-
-// Selectable comparison operators. Only "is" exists today; adding a new operator here surfaces it
-// in the dropdown automatically.
-const METADATA_OPERATORS: { value: SecretMetadataSearchOperator; label: string }[] = [
- { value: SecretMetadataSearchOperator.Is, label: "is" }
-];
-
-const DEFAULT_OPERATOR = METADATA_OPERATORS[0].value;
-
-const getOperatorLabel = (operator: SecretMetadataSearchOperator) =>
- METADATA_OPERATORS.find((op) => op.value === operator)?.label ?? operator;
-
-type Props = {
- conditions: MetadataSearchCondition[];
- match: MetadataMatchType;
- matchingCount: number;
- isPending: boolean;
- hasActiveConditions: boolean;
- onChangeMatch: (match: MetadataMatchType) => void;
- onAddCondition: (key: string, value: string, operator: SecretMetadataSearchOperator) => void;
- onEditCondition: (
- id: string,
- key: string,
- value: string,
- operator: SecretMetadataSearchOperator
- ) => void;
- onRemoveCondition: (id: string) => void;
- onClear: () => void;
- onClose: () => void;
-};
-
-export const SecretMetadataSearchInput = ({
- conditions,
- match,
- matchingCount,
- isPending,
- hasActiveConditions,
- onChangeMatch,
- onAddCondition,
- onEditCondition,
- onRemoveCondition,
- onClear,
- onClose
-}: Props) => {
- // raw "key:value" text for the chip being composed; metadata keys are free-form so we just
- // split on the first colon rather than matching against a fixed property list.
- const [query, setQuery] = useState("");
- const [editingId, setEditingId] = useState<string | null>(null);
- const [composingOperator, setComposingOperator] =
- useState<SecretMetadataSearchOperator>(DEFAULT_OPERATOR);
- const inputRef = useRef<HTMLInputElement>(null);
-
- const colonIndex = query.indexOf(":");
- const isComposing = colonIndex > 0;
- const propertyKey = isComposing ? query.slice(0, colonIndex).trim() : "";
- const typedValue = isComposing ? query.slice(colonIndex + 1) : "";
-
- const focusInput = () => {
- setTimeout(() => inputRef.current?.focus(), 0);
- };
-
- const resetQuery = () => {
- setQuery("");
- setEditingId(null);
- setComposingOperator(DEFAULT_OPERATOR);
- };
-
- // refocus the input when swapping between the free-text field and the composing pill
- useEffect(() => {
- if (isComposing) inputRef.current?.focus();
- }, [isComposing]);
-
- const commit = () => {
- const key = propertyKey.trim();
- const value = typedValue.trim();
- if (!key || !value) return;
-
- if (editingId !== null) {
- onEditCondition(editingId, key, value, composingOperator);
- } else {
- onAddCondition(key, value, composingOperator);
- }
- resetQuery();
- focusInput();
- };
-
- const editCondition = (condition: MetadataSearchCondition) => {
- setEditingId(condition.id);
- setComposingOperator(condition.operator);
- setQuery(`${condition.key}:${condition.value}`);
- focusInput();
- };
-
- const handleKeyDown = (keyEvent: React.KeyboardEvent) => {
- switch (keyEvent.key) {
- case "Enter":
- keyEvent.preventDefault();
- commit();
- break;
- case "Escape":
- resetQuery();
- break;
- case "Backspace":
- if (query === "" && conditions.length > 0) {
- onRemoveCondition(conditions[conditions.length - 1].id);
- }
- break;
- default:
- break;
- }
- };
-
- const operatorDropdown = (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <button
- type="button"
- aria-label="Select operator"
- onClick={(clickEvent) => clickEvent.stopPropagation()}
- className="inline-flex items-center gap-0.5 rounded bg-neutral/15 px-1.5 py-0.5 text-muted transition-colors hover:bg-neutral/25 hover:text-foreground"
- >
- {getOperatorLabel(composingOperator)}
- <ChevronDownIcon className="size-2.5" />
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start" className="min-w-[6rem]">
- {METADATA_OPERATORS.map((op) => (
- <DropdownMenuItem
- key={op.value}
- onSelect={() => {
- setComposingOperator(op.value);
- focusInput();
- }}
- >
- {op.label}
- </DropdownMenuItem>
- ))}
- </DropdownMenuContent>
- </DropdownMenu>
- );
-
- const composingInput = (
- <span
- key="composing"
- className="inline-flex shrink-0 items-center gap-1 rounded-md border border-border py-1 pr-1 pl-1.5 font-mono text-xs"
- >
- <span className="text-muted">{propertyKey}</span>
- {operatorDropdown}
- <input
- ref={inputRef}
- type="text"
- className="w-auto bg-transparent font-mono text-xs text-foreground outline-none"
- style={{ width: `${Math.max(typedValue.length, 1)}ch` }}
- value={typedValue}
- onChange={(inputEvent) => setQuery(`${propertyKey}:${inputEvent.target.value}`)}
- onKeyDown={handleKeyDown}
- />
- <button
- type="button"
- aria-label="Cancel condition"
- onClick={(clickEvent) => {
- clickEvent.stopPropagation();
- resetQuery();
- }}
- className="ml-0.5 text-muted transition-colors hover:text-foreground"
- >
- <XIcon className="size-2.5" />
- </button>
- </span>
- );
-
- const renderChip = (condition: MetadataSearchCondition) => (
- <span
- key={condition.id}
- className="inline-flex shrink-0 items-center gap-1 rounded-md border border-border bg-container px-2.5 py-1 font-mono text-xs"
- >
- <button
- type="button"
- className="text-foreground transition-colors hover:text-foreground"
- onClick={(clickEvent) => {
- clickEvent.stopPropagation();
- editCondition(condition);
- }}
- >
- <span className="text-muted">{`${condition.key} ${getOperatorLabel(condition.operator)} `}</span>
- {condition.value}
- </button>
- <button
- type="button"
- aria-label="Remove condition"
- onClick={(clickEvent) => {
- clickEvent.stopPropagation();
- onRemoveCondition(condition.id);
- }}
- className="ml-0.5 text-muted transition-colors hover:text-foreground"
- >
- <XIcon className="size-2.5" />
- </button>
- </span>
- );
-
- return (
- <div className="mb-5 rounded-lg border border-border bg-popover">
- <div className="border-b border-border px-4 py-3">
- <div className="flex items-center gap-3">
- <BracesIcon className="size-4 text-muted" />
- <span className="font-medium">Filter by metadata</span>
- <div className="ml-auto flex items-center gap-2">
- <div className="inline-flex rounded-md border border-border p-0.5">
- {(["all", "any"] as const).map((option) => (
- <button
- key={option}
- type="button"
- onClick={() => onChangeMatch(option)}
- className={cn(
- "h-6 rounded px-3 text-xs font-semibold tracking-wide transition-colors",
- match === option
- ? "bg-project/15 text-project"
- : "text-muted hover:text-foreground"
- )}
- >
- {option.toUpperCase()}
- </button>
- ))}
- </div>
- <Tooltip>
- <TooltipTrigger asChild>
- <span className="cursor-default text-muted">
- <InfoIcon className="size-3.5" />
- </span>
- </TooltipTrigger>
- <TooltipContent className="max-w-xs">
- <span className="font-semibold text-project">ALL</span> returns secrets matching
- every condition (AND). <span className="font-semibold text-project">ANY</span>{" "}
- returns secrets matching at least one condition (OR).
- </TooltipContent>
- </Tooltip>
- <IconButton
- variant="ghost"
- size="xs"
- aria-label="Close metadata filter"
- onClick={onClose}
- >
- <XIcon />
- </IconButton>
- </div>
- </div>
- <p className="mt-1 pl-7 text-xs text-muted">
- Type <code> key : value </code> and press Enter to add a filter, e.g. env is production.
- </p>
- </div>
-
- <div className="p-4">
- <div
- className="flex cursor-text flex-wrap items-center gap-2 rounded-md border border-border bg-card px-3 py-2 transition-colors focus-within:border-foreground/30"
- role="button"
- tabIndex={-1}
- onClick={() => inputRef.current?.focus()}
- onKeyDown={(wrapperEvent) => {
- if (wrapperEvent.key === "Enter" || wrapperEvent.key === " ") {
- inputRef.current?.focus();
- }
- }}
- >
- <SearchIcon className="size-3.5 shrink-0 text-muted" />
-
- {conditions.map((condition) =>
- isComposing && editingId === condition.id ? composingInput : renderChip(condition)
- )}
-
- {isComposing && editingId === null && composingInput}
-
- {!isComposing && (
- <input
- ref={inputRef}
- type="text"
- placeholder="Add filter..."
- className="min-w-[160px] flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted"
- value={query}
- onChange={(inputEvent) => setQuery(inputEvent.target.value)}
- onKeyDown={handleKeyDown}
- />
- )}
- </div>
- </div>
-
- <div className="flex items-center justify-between border-t border-border px-4 py-3">
- <span className="flex items-center gap-2 text-sm text-muted">
- <ZapIcon className="size-3.5 text-project" />
- {hasActiveConditions ? (
- <span>
- <span className="font-semibold text-foreground">
- {isPending ? "…" : matchingCount}
- </span>{" "}
- matching {matchingCount === 1 && !isPending ? "secret" : "secrets"}
- </span>
- ) : (
- <span>Add a condition to search</span>
- )}
- </span>
- <Button variant="ghost" size="sm" onClick={onClear}>
- Clear
- </Button>
- </div>
- </div>
- );
-};