Skip to content

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

improvement(secrets): unify overview navigation and query state (#7738)

Andrew Huanga12d1f9bce6e
diff --git a/frontend/src/hooks/useNavigationBlocker.tsx b/frontend/src/hooks/useNavigationBlocker.tsx
index e427d6a7d1..ea48122c11 100644
--- a/frontend/src/hooks/useNavigationBlocker.tsx
+++ b/frontend/src/hooks/useNavigationBlocker.tsx
@@ -1,5 +1,5 @@
import { useCallback } from "react";
-import { useBlocker } from "@tanstack/react-router";
+import { type ShouldBlockFn, useBlocker } from "@tanstack/react-router";
import {
BatchContext,
@@ -12,27 +12,37 @@ type TNavigationBlockerReturn = {
export const useNavigationBlocker = ({
shouldBlock = false,
+ shouldBlockNavigation,
message = "Are you sure you want to leave? You may have unsaved changes.",
context
}: {
shouldBlock: boolean;
+ shouldBlockNavigation?: ShouldBlockFn;
message: string;
context: BatchContext;
}): TNavigationBlockerReturn => {
const { clearAllPendingChanges } = useBatchModeActions();
- const blockerFn = useCallback(() => {
- if (!shouldBlock) return false;
+ const blockerFn: ShouldBlockFn = useCallback(
+ async (args) => {
+ if (!shouldBlock) return false;
+ if (shouldBlockNavigation && !(await shouldBlockNavigation(args))) return false;
- // eslint-disable-next-line no-alert
- const confirmed = window.confirm(message);
- if (confirmed) {
- clearAllPendingChanges(context);
- }
+ // eslint-disable-next-line no-alert
+ const confirmed = window.confirm(message);
+ if (confirmed) {
+ clearAllPendingChanges(context);
+ }
- return !confirmed;
- }, [shouldBlock, message, context]);
+ return !confirmed;
+ },
+ [shouldBlock, shouldBlockNavigation, message, context, clearAllPendingChanges]
+ );
- useBlocker(blockerFn, shouldBlock);
+ useBlocker({
+ shouldBlockFn: blockerFn,
+ disabled: !shouldBlock,
+ enableBeforeUnload: shouldBlock
+ });
return {
isBlocked: shouldBlock
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
index 4497397b97..7b7d7ad3a9 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
@@ -248,6 +248,16 @@ import {
SecretSyncStatusBadgeOverview,
SecretTableRow
} from "./components";
+import {
+ hasOverviewScopeChanged,
+ hasSensitiveOverviewSearchState,
+ normalizeOverviewEnvironments,
+ parseOverviewTags,
+ resolveOverviewEnvironmentSlugs,
+ serializeOverviewResourceFilter,
+ stripSensitiveOverviewSearchState,
+ updateOverviewSecretPath
+} from "./overviewSearchState";
type TParsedEnv = { value: string; comments: string[]; secretPath?: string; secretKey: string }[];
type TParsedFolderEnv = Record<
@@ -273,10 +283,6 @@ export enum RowType {
ProxiedService = "proxiedService"
}
-type Filter = {
- [key in RowType]: boolean;
-};
-
const DEFAULT_FILTER_STATE = {
[RowType.Folder]: false,
[RowType.DynamicSecret]: false,
@@ -333,7 +339,8 @@ const OverviewPageContent = () => {
) ?? false;
const isProjectV3 = currentProject?.version === ProjectVersion.V3;
const projectSlug = currentProject?.slug as string;
- const [searchFilter, setSearchFilter] = useState("");
+ const [searchFilter, setSearchFilter] = useState(routerSearch.search);
+ const [tagFilter, setTagFilter] = useState(() => parseOverviewTags(routerSearch.tags));
const secretPath = (routerSearch?.secretPath as string) || "/";
const { subscription } = useSubscription();
const { mutateAsync: importVaultSecrets } = useImportVaultSecrets();
@@ -360,11 +367,21 @@ const OverviewPageContent = () => {
// }
// };
- const [filter, setFilter] = useState<Filter>(DEFAULT_FILTER_STATE);
- const [tagFilter, setTagFilter] = useState<Record<string, boolean>>({});
- const [filterHistory, setFilterHistory] = useState<
- Map<string, { filter: Filter; searchFilter: string }>
- >(new Map());
+ const filter = useMemo(() => {
+ const nextFilter = { ...DEFAULT_FILTER_STATE };
+
+ routerSearch.filterBy
+ ?.split(",")
+ .map((value) => value.trim())
+ .filter((value): value is RowType => Object.values(RowType).includes(value as RowType))
+ .forEach((rowType) => {
+ nextFilter[rowType] = true;
+ });
+
+ if (Object.keys(tagFilter).length > 0) nextFilter[RowType.Secret] = true;
+
+ return nextFilter;
+ }, [routerSearch.filterBy, tagFilter]);
const [selectedEntries, setSelectedEntries] = useState<{
// selectedEntries[name/key][envSlug][resource]
@@ -408,8 +425,13 @@ const OverviewPageContent = () => {
}, []);
useEffect(() => {
- const onRouteChangeStart = () => {
- resetSelectedEntries();
+ const onRouteChangeStart = (event: {
+ fromLocation: { pathname: string; search: unknown };
+ toLocation: { pathname: string; search: unknown };
+ }) => {
+ if (hasOverviewScopeChanged(event.fromLocation, event.toLocation)) {
+ resetSelectedEntries();
+ }
};
const unsubscribeRouterEvent = router.subscribe("onLoad", onRouteChangeStart);
@@ -457,85 +479,67 @@ const OverviewPageContent = () => {
userAvailableEnvs?.[0]?.id ? [userAvailableEnvs[0].id] : []
);
- // Apply one-shot deep-link inputs to local filters, then strip them from the URL in a SINGLE
- // navigate. These arrive from notifications, legacy dashboard bookmarks (`tags`, `filterBy`),
- // or the secret reference tree (`environments` + `search`). Handling them in one effect/navigate
- // (rather than two racing effects) guarantees every param is cleared after it's applied. That
- // matters most for `environments`: re-selecting the same environment from the reference tree
- // changes the param again and re-fires this effect instead of being a no-op. Runs reactively
- // (not mount-only) because the tree is rendered inside this page, so navigating from a node
- // updates the params without remounting.
- useEffect(() => {
- const { search, tags, filterBy, environments: envSlugs, ...query } = routerSearch;
- const hasEnvLink = Boolean(envSlugs?.length);
-
- if (!search && !tags && !filterBy && !hasEnvLink) return;
- // Env link present but envs not loaded yet → wait so we don't strip it before applying.
- if (hasEnvLink && userAvailableEnvs.length === 0) return;
-
- if (envSlugs && envSlugs.length > 0) {
- const envIds = userAvailableEnvs
- .filter((env) => envSlugs.includes(env.slug))
- .map((env) => env.id);
- if (envIds.length > 0) {
- setStoredEnvIds(envIds);
- }
- }
+ const selectedEnvironmentSlugs = useMemo(
+ () =>
+ resolveOverviewEnvironmentSlugs(routerSearch.environments, storedEnvIds, userAvailableEnvs),
+ [routerSearch.environments, storedEnvIds, userAvailableEnvs]
+ );
- if (search || tags || filterBy) {
- const initialFilter = { ...DEFAULT_FILTER_STATE };
- if (filterBy) {
- filterBy
- .split(",")
- .map((value) => value.trim())
- .filter((value): value is RowType => Object.values(RowType).includes(value as RowType))
- .forEach((rowType) => {
- initialFilter[rowType] = true;
- });
- }
+ useEffect(() => {
+ if (routerSearch.search) setSearchFilter(routerSearch.search);
+ if (routerSearch.tags !== undefined) setTagFilter(parseOverviewTags(routerSearch.tags));
+ }, [routerSearch.search, routerSearch.tags]);
- const initialTagFilter = (tags ?? "")
- .split(",")
- .reduce<Record<string, boolean>>((acc, tag) => {
- const tagSlug = tag.trim();
- if (tagSlug) acc[tagSlug] = true;
- return acc;
- }, {});
- if (Object.keys(initialTagFilter).length > 0) {
- initialFilter[RowType.Secret] = true;
- }
+ useEffect(() => {
+ const requestedSlugs = normalizeOverviewEnvironments(
+ routerSearch.environments,
+ userAvailableEnvs.map((env) => env.slug)
+ );
+ const isCanonical =
+ requestedSlugs.length === routerSearch.environments.length &&
+ requestedSlugs.join(",") === selectedEnvironmentSlugs.join(",");
+ const shouldNormalizeEnvironments = userAvailableEnvs.length > 0 && !isCanonical;
+ const shouldStripSensitiveState = hasSensitiveOverviewSearchState(routerSearch);
+ const normalizedEnvironments = selectedEnvironmentSlugs.length
+ ? selectedEnvironmentSlugs
+ : undefined;
- setFilter(initialFilter);
- setTagFilter(initialTagFilter);
+ if (!shouldNormalizeEnvironments && !shouldStripSensitiveState) return;
- if (search) {
- setSearchFilter(search as string);
- }
- }
+ navigate({
+ search: (prev) => {
+ const nextSearch = shouldStripSensitiveState
+ ? stripSensitiveOverviewSearchState(prev)
+ : prev;
- navigate({ search: query, replace: true });
- }, [
- routerSearch.search,
- routerSearch.tags,
- routerSearch.filterBy,
- routerSearch.environments?.join(","),
- userAvailableEnvs.length
- ]);
+ return {
+ ...nextSearch,
+ environments: shouldNormalizeEnvironments
+ ? normalizedEnvironments
+ : nextSearch.environments
+ };
+ },
+ replace: true
+ });
+ }, [navigate, routerSearch, selectedEnvironmentSlugs, userAvailableEnvs]);
- const filteredEnvs = useMemo(() => {
- if (!storedEnvIds.length) return [];
- return userAvailableEnvs.filter((env) => storedEnvIds.includes(env.id));
- }, [storedEnvIds, userAvailableEnvs]);
+ const filteredEnvs = useMemo(
+ () => userAvailableEnvs.filter((env) => selectedEnvironmentSlugs.includes(env.slug)),
+ [selectedEnvironmentSlugs, userAvailableEnvs]
+ );
const setFilteredEnvs = useCallback(
(value: SetStateAction<ProjectEnv[]>) => {
- setStoredEnvIds((prev) => {
- const prevEnvs = userAvailableEnvs.filter((env) => prev.includes(env.id));
- const next = typeof value === "function" ? value(prevEnvs) : value;
- return next.map((env) => env.id);
+ const next = typeof value === "function" ? value(filteredEnvs) : value;
+ navigate({
+ search: (prev) => ({
+ ...prev,
+ environments: next.length > 0 ? next.map((env) => env.slug) : undefined
+ })
});
+ setStoredEnvIds(next.map((env) => env.id));
},
- [setStoredEnvIds, userAvailableEnvs]
+ [filteredEnvs, navigate, setStoredEnvIds]
);
const visibleEnvs = filteredEnvs.length ? filteredEnvs : userAvailableEnvs;
@@ -850,6 +854,7 @@ const OverviewPageContent = () => {
useNavigationBlocker({
shouldBlock:
isBatchModeActive && (pendingChanges.secrets.length > 0 || pendingChanges.folders.length > 0),
+ shouldBlockNavigation: ({ current, next }) => hasOverviewScopeChanged(current, next),
message:
"You have unsaved changes. If you leave now, your work will be lost. Do you want to continue?",
context: {
@@ -2197,62 +2202,66 @@ const OverviewPageContent = () => {
handlePopUpClose("confirmDisableBatchMode");
}, [singleVisibleEnv, clearAllPendingChanges, projectId, secretPath, handlePopUpClose]);
- const handleResetSearch = (path: string) => {
- const restore = filterHistory.get(path);
- setFilter(restore?.filter ?? DEFAULT_FILTER_STATE);
- const el = restore?.searchFilter ?? "";
- setSearchFilter(el);
- };
-
const handleFolderClick = (path: string) => {
if (isOverviewFetching) return;
- // store for breadcrumb nav to restore previously used filters
- setFilterHistory((prev) => {
- const curr = new Map(prev);
- curr.set(secretPath, { filter, searchFilter });
- return curr;
- });
-
navigate({
search: (prev) => ({
- ...prev,
- secretPath: `${routerSearch.secretPath === "/" ? "" : routerSearch.secretPath}/${path}`
+ ...updateOverviewSecretPath(
+ prev,
+ `${routerSearch.secretPath === "/" ? "" : routerSearch.secretPath}/${path}`
+ )
})
- }).then(() => {
- setFilter(DEFAULT_FILTER_STATE);
- setSearchFilter("");
});
};
+ const handleSearchChange = useCallback((search: string) => setSearchFilter(search), []);
+
const handleClearTags = useCallback(() => {
setTagFilter({});
}, []);
const handleToggleRowType = useCallback(
- (rowType: RowType) =>
- setFilter((state) => {
- const newValue = !state[rowType];
- if (rowType === RowType.Secret && !newValue) {
- setTagFilter({});
- }
- return {
- ...state,
- [rowType]: newValue
- };
- }),
- []
+ (rowType: RowType) => {
+ const nextFilter = { ...filter, [rowType]: !filter[rowType] };
+ if (rowType === RowType.Secret && filter[rowType]) setTagFilter({});
+
+ navigate({
+ search: (prev) => ({
+ ...prev,
+ filterBy: serializeOverviewResourceFilter(nextFilter, Object.values(RowType))
+ }),
+ replace: true
+ });
+ },
+ [filter, navigate]
);
- const handleToggleTag = useCallback((tagSlug: string) => {
- setTagFilter((state) => {
- const isActivating = !state[tagSlug];
- if (isActivating) {
- setFilter((filterState) => ({ ...filterState, [RowType.Secret]: true }));
+ const handleToggleTag = useCallback(
+ (tagSlug: string) => {
+ const isEnabling = !tagFilter[tagSlug];
+ setTagFilter((prev) => {
+ const next = { ...prev };
+ if (next[tagSlug]) delete next[tagSlug];
+ else next[tagSlug] = true;
+ return next;
+ });
+
+ if (isEnabling && !filter[RowType.Secret]) {
+ navigate({
+ search: (prev) => ({
+ ...prev,
+ filterBy: [
+ ...Object.values(RowType).filter((type) => filter[type]),
+ RowType.Secret
+ ].join(",")
+ }),
+ replace: true
+ });
}
- return { ...state, [tagSlug]: isActivating };
- });
- }, []);
+ },
+ [filter, navigate, tagFilter]
+ );
const allRowsSelectedOnPage = useMemo(() => {
if (
@@ -2654,7 +2663,7 @@ const OverviewPageContent = () => {
(pendingChanges.secrets.length > 0 || pendingChanges.folders.length > 0)
}
/>
- <FolderBreadcrumb secretPath={secretPath} onResetSearch={handleResetSearch} />
+ <FolderBreadcrumb secretPath={secretPath} />
</div>
<div className="flex flex-wrap items-center gap-3">
{userAvailableEnvs.length > 0 && (
@@ -2675,10 +2684,20 @@ const OverviewPageContent = () => {
/>
)}
<ResourceSearchInput
- key={secretPath}
value={searchFilter}
tags={tags}
- onChange={setSearchFilter}
+ onChange={handleSearchChange}
+ onSelectResult={({ search, tags: selectedTags }) => {
+ setSearchFilter(search);
+ if (selectedTags !== undefined) {
+ setTagFilter(
+ selectedTags.reduce<Record<string, boolean>>((acc, tag) => {
+ acc[tag] = true;
+ return acc;
+ }, {})
+ );
+ }
+ }}
environments={userAvailableEnvs}
projectId={currentProject?.id}
/>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/FolderBreadcrumb/FolderBreadcrumb.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/FolderBreadcrumb/FolderBreadcrumb.tsx
index 20ba1006b5..53405a8dea 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/FolderBreadcrumb/FolderBreadcrumb.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/FolderBreadcrumb/FolderBreadcrumb.tsx
@@ -23,7 +23,6 @@ import { useTimedReset } from "@app/hooks";
type Props = {
secretPath?: string;
- onResetSearch: (secretPath: string) => void;
};
type Measurements = {
@@ -34,7 +33,7 @@ type Measurements = {
separatorWidth: number;
};
-export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
+export function FolderBreadcrumb({ secretPath = "" }: Props) {
const containerRef = useRef<HTMLDivElement>(null);
const measureContainerRef = useRef<HTMLDivElement>(null);
@@ -55,21 +54,8 @@ export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
[secretPath]
);
- // The crumb is a real link, so the browser owns the navigation; this only restores the
- // filters previously used at that depth, and must not run when the click is a new-tab
- // gesture that leaves this tab where it is.
- const onFolderCrumbClick = useCallback(
- (event: React.MouseEvent, index: number) => {
- if (event.defaultPrevented) return;
- if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0)
- return;
- const newSecPath = getCrumbPath(index);
- if (secretPath === newSecPath) return;
- onResetSearch(newSecPath);
- },
- [getCrumbPath, secretPath, onResetSearch]
- );
-
+ // The crumb is a real link, so the browser owns the navigation and preserves the other search
+ // parameters through the route transition.
// Measure all elements and track container width
const measureElements = useCallback(() => {
const container = containerRef.current;
@@ -264,7 +250,6 @@ export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
from="/organizations/$orgId/projects/secret-management/$projectId/overview"
to="."
search={(prev) => ({ ...prev, secretPath: getCrumbPath(0) })}
- onClick={(event) => onFolderCrumbClick(event, 0)}
aria-label="Root folder"
>
<FolderIcon />
@@ -289,7 +274,6 @@ export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
from="/organizations/$orgId/projects/secret-management/$projectId/overview"
to="."
search={(prev) => ({ ...prev, secretPath: getCrumbPath(index + 1) })}
- onClick={(event) => onFolderCrumbClick(event, index + 1)}
>
{path}
</Link>
@@ -330,7 +314,6 @@ export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
...prev,
secretPath: getCrumbPath(originalIndex + 1)
})}
- onClick={(event) => onFolderCrumbClick(event, originalIndex + 1)}
>
<div className="absolute top-1/2 -left-[3px] h-px w-2 bg-muted/50 transition-colors" />
@@ -369,7 +352,6 @@ export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
...prev,
secretPath: getCrumbPath(originalIndex + 1)
})}
- onClick={(event) => onFolderCrumbClick(event, originalIndex + 1)}
>
{path}
</Link>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/FolderTableRow/FolderTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/FolderTableRow/FolderTableRow.tsx
index 12aa80dcab..bec97e6983 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/FolderTableRow/FolderTableRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/FolderTableRow/FolderTableRow.tsx
@@ -141,6 +141,7 @@ export const FolderTableRow = ({
<Tooltip disableHoverableContent>
<TooltipTrigger>
<IconButton
+ aria-label="Move folder"
variant="ghost"
size="xs"
className="w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7"
@@ -159,6 +160,7 @@ export const FolderTableRow = ({
<Tooltip disableHoverableContent>
<TooltipTrigger>
<IconButton
+ aria-label="Edit folder"
variant="ghost"
size="xs"
className="w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7"
@@ -177,6 +179,7 @@ export const FolderTableRow = ({
<Tooltip disableHoverableContent>
<TooltipTrigger>
<IconButton
+ aria-label="Discard pending folder changes"
variant="ghost"
className="w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7 hover:text-danger"
size="xs"
@@ -194,6 +197,7 @@ export const FolderTableRow = ({
<Tooltip disableHoverableContent>
<TooltipTrigger>
<IconButton
+ aria-label="Delete folder"
variant="ghost"
size="xs"
className="w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7 hover:text-danger"
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceFilter/ResourceFilter.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceFilter/ResourceFilter.tsx
index 5296cc9fa9..74174f8d9b 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceFilter/ResourceFilter.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceFilter/ResourceFilter.tsx
@@ -77,16 +77,21 @@ export function ResourceFilter({
return (
<DropdownMenu>
- <DropdownMenuTrigger className="outline-0">
- <Tooltip>
- <TooltipTrigger asChild>
- <IconButton className="relative" size="md" variant={isActive ? "project" : "outline"}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ aria-label="Filter resources"
+ className="relative"
+ size="md"
+ variant={isActive ? "project" : "outline"}
+ >
<FilterIcon />
</IconButton>
- </TooltipTrigger>
- <TooltipContent>Filter resources</TooltipContent>
- </Tooltip>
- </DropdownMenuTrigger>
+ </DropdownMenuTrigger>
+ </TooltipTrigger>
+ <TooltipContent>Filter resources</TooltipContent>
+ </Tooltip>
<DropdownMenuContent align="end">
<ResourceFilterMenuContent
resourceTypes={OVERVIEW_RESOURCE_TYPES}
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/ResourceSearchInput.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/ResourceSearchInput.tsx
index 57b3eaf58b..5e542bd012 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/ResourceSearchInput.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/ResourceSearchInput.tsx
@@ -17,6 +17,7 @@ import {
import { useDebounce } from "@app/hooks";
import { QuickSearchModal, QuickSearchModalProps } from "../SecretSearchInput/components";
+import { getResourceSearchStateTransition } from "./resourceSearchState";
type Props = Omit<QuickSearchModalProps, "isOpen" | "onClose" | "onOpenChange" | "initialValue"> & {
value: string;
@@ -40,21 +41,29 @@ export const ResourceSearchInput = ({
// local input state so typing doesn't re-render the whole table
const [inputValue, setInputValue] = useState(externalValue);
const [debouncedInputValue] = useDebounce(inputValue);
+ const previousExternalValue = useRef(externalValue);
const lastEmittedValue = useRef(externalValue);
useEffect(() => {
- if (externalValue !== lastEmittedValue.current) {
- setInputValue(externalValue);
- lastEmittedValue.current = externalValue;
- }
- }, [externalValue]);
+ const transition = getResourceSearchStateTransition({
+ externalValue,
+ previousExternalValue: previousExternalValue.current,
+ debouncedInputValue,
+ lastEmittedValue: lastEmittedValue.current
+ });
- useEffect(() => {
- if (debouncedInputValue !== lastEmittedValue.current) {
- lastEmittedValue.current = debouncedInputValue;
- onChange(debouncedInputValue);
+ if (!transition) return;
+
+ if (transition.type === "sync") {
+ previousExternalValue.current = transition.value;
+ lastEmittedValue.current = transition.value;
+ setInputValue(transition.value);
+ return;
}
- }, [debouncedInputValue, onChange]);
+
+ lastEmittedValue.current = transition.value;
+ onChange(transition.value);
+ }, [debouncedInputValue, externalValue, onChange]);
const handleClear = () => {
setInputValue("");
@@ -69,7 +78,11 @@ export const ResourceSearchInput = ({
<ButtonGroup>
<Tooltip>
<TooltipTrigger asChild>
- <IconButton variant="outline" onClick={() => setIsOpen(true)}>
+ <IconButton
+ aria-label="Search all folders"
+ variant="outline"
+ onClick={() => setIsOpen(true)}
+ >
<SearchIcon />
</IconButton>
</TooltipTrigger>
@@ -117,7 +130,12 @@ export const ResourceSearchInput = ({
/>
{hasSearch && (
<InputGroupAddon align="inline-end">
- <IconButton variant="ghost" size="xs" onClick={handleClear}>
+ <IconButton
+ aria-label="Clear search"
+ variant="ghost"
+ size="xs"
+ onClick={handleClear}
+ >
<XIcon />
</IconButton>
</InputGroupAddon>
@@ -154,9 +172,9 @@ export const ResourceSearchInput = ({
isOpen={isOpen}
onOpenChange={setIsOpen}
initialValue={inputValue}
- onClose={() => {
+ onClose={(clearSearch = true) => {
setIsOpen(false);
- handleClear();
+ if (clearSearch) handleClear();
}}
{...props}
/>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/resourceSearchState.test.ts b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/resourceSearchState.test.ts
new file mode 100644
index 0000000000..212ffc88a5
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/resourceSearchState.test.ts
@@ -0,0 +1,42 @@
+import assert from "node:assert/strict";
+import { describe, it } from "node:test";
+
+import { getResourceSearchStateTransition } from "./resourceSearchState";
+
+describe("Resource search state", () => {
+ it("syncs an external navigation without re-emitting the stale debounced value", () => {
+ assert.deepEqual(
+ getResourceSearchStateTransition({
+ externalValue: "DATABASE_URL",
+ previousExternalValue: "api",
+ debouncedInputValue: "api",
+ lastEmittedValue: "api"
+ }),
+ { type: "sync", value: "DATABASE_URL" }
+ );
+ });
+
+ it("emits a locally debounced search change", () => {
+ assert.deepEqual(
+ getResourceSearchStateTransition({
+ externalValue: "api",
+ previousExternalValue: "api",
+ debouncedInputValue: "api-key",
+ lastEmittedValue: "api"
+ }),
+ { type: "emit", value: "api-key" }
+ );
+ });
+
+ it("does nothing when external and local search state are synchronized", () => {
+ assert.equal(
+ getResourceSearchStateTransition({
+ externalValue: "api",
+ previousExternalValue: "api",
+ debouncedInputValue: "api",
+ lastEmittedValue: "api"
+ }),
+ undefined
+ );
+ });
+});
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/resourceSearchState.ts b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/resourceSearchState.ts
new file mode 100644
index 0000000000..1c6638ea5e
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/resourceSearchState.ts
@@ -0,0 +1,27 @@
+type ResourceSearchState = {
+ externalValue: string;
+ previousExternalValue: string;
+ debouncedInputValue: string;
+ lastEmittedValue: string;
+};
+
+export type ResourceSearchStateTransition =
+ | { type: "sync"; value: string }
+ | { type: "emit"; value: string };
+
+export const getResourceSearchStateTransition = ({
+ externalValue,
+ previousExternalValue,
+ debouncedInputValue,
+ lastEmittedValue
+}: ResourceSearchState): ResourceSearchStateTransition | undefined => {
+ if (externalValue !== previousExternalValue) {
+ return { type: "sync", value: externalValue };
+ }
+
+ if (debouncedInputValue !== lastEmittedValue) {
+ return { type: "emit", value: debouncedInputValue };
+ }
+
+ return undefined;
+};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/SecretSearchInput.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/SecretSearchInput.tsx
index cf665ac0c6..4b79c25943 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/SecretSearchInput.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/SecretSearchInput.tsx
@@ -10,7 +10,7 @@ import { QuickSearchModal, QuickSearchModalProps } from "./components";
type ModalProps = Omit<
QuickSearchModalProps,
- "isOpen" | "onClose" | "onOpenChange" | "initialValue"
+ "isOpen" | "onClose" | "onOpenChange" | "initialValue" | "onSelectResult"
> & {
value: string;
onChange: (search: string) => void;
@@ -109,9 +109,10 @@ export const SecretSearchInput = ({
isOpen={isOpen}
onOpenChange={setIsOpen}
initialValue={value}
- onClose={() => {
+ onSelectResult={({ search }) => onChange(search)}
+ onClose={(clearSearch = true) => {
setIsOpen(false);
- onChange("");
+ if (clearSearch) onChange("");
}}
{...props}
/>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchDynamicSecretItem.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchDynamicSecretItem.tsx
index ed7f458187..7c05d916df 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchDynamicSecretItem.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchDynamicSecretItem.tsx
@@ -4,28 +4,38 @@ import { ChevronRightIcon, FingerprintIcon } from "lucide-react";
import { TableCell, TableRow, Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3";
import { TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";
+import { QuickSearchSelection } from "./quickSearchTypes";
+
type Props = {
dynamicSecret: TDynamicSecret & { environment: string; path: string };
envSlug: string;
- onClose: () => void;
+ onClose: (clearSearch?: boolean) => void;
+ onSelectResult: (selection: QuickSearchSelection) => void;
};
-export const QuickSearchDynamicSecretItem = ({ dynamicSecret, envSlug, onClose }: Props) => {
+export const QuickSearchDynamicSecretItem = ({
+ dynamicSecret,
+ envSlug,
+ onClose,
+ onSelectResult
+}: Props) => {
const navigate = useNavigate({
from: "/organizations/$orgId/projects/secret-management/$projectId/overview"
});
const handleNavigate = () => {
+ onSelectResult({ search: dynamicSecret.name });
navigate({
search: (prev) => ({
...prev,
secretPath: dynamicSecret.path,
- search: dynamicSecret.name,
+ search: undefined,
+ tags: undefined,
filterBy: "dynamic",
environments: [envSlug]
})
});
- onClose();
+ onClose(false);
};
return (
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchFolderItem.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchFolderItem.tsx
index 1ecb86e625..229d6e80ae 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchFolderItem.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchFolderItem.tsx
@@ -4,28 +4,33 @@ import { ChevronRightIcon, FolderIcon } from "lucide-react";
import { TableCell, TableRow, Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3";
import { TSecretFolder } from "@app/hooks/api/secretFolders/types";
+import { QuickSearchSelection } from "./quickSearchTypes";
+
type Props = {
folder: TSecretFolder & { envId: string; path: string };
envSlug: string;
- onClose: () => void;
+ onClose: (clearSearch?: boolean) => void;
+ onSelectResult: (selection: QuickSearchSelection) => void;
};
-export const QuickSearchFolderItem = ({ folder, envSlug, onClose }: Props) => {
+export const QuickSearchFolderItem = ({ folder, envSlug, onClose, onSelectResult }: Props) => {
const navigate = useNavigate({
from: "/organizations/$orgId/projects/secret-management/$projectId/overview"
});
const handleNavigate = () => {
+ onSelectResult({ search: "" });
navigate({
search: (prev) => ({
...prev,
- search: "",
+ search: undefined,
+ tags: undefined,
filterBy: undefined,
secretPath: folder.path,
environments: [envSlug]
})
});
- onClose();
+ onClose(false);
};
return (
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchMetadataSecretItem.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchMetadataSecretItem.tsx
index 1984e98bc2..6d1baa9046 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchMetadataSecretItem.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchMetadataSecretItem.tsx
@@ -11,31 +11,40 @@ import {
} from "@app/components/v3";
import { TMetadataMatchedSecret } from "@app/hooks/api/dashboard/types";
+import { QuickSearchSelection } from "./quickSearchTypes";
+
type Props = {
secret: TMetadataMatchedSecret;
envSlug: string;
- onClose: () => void;
+ onClose: (clearSearch?: boolean) => void;
+ onSelectResult: (selection: QuickSearchSelection) => void;
};
const MAX_VISIBLE_BADGES = 3;
-export const QuickSearchMetadataSecretItem = ({ secret, envSlug, onClose }: Props) => {
+export const QuickSearchMetadataSecretItem = ({
+ secret,
+ envSlug,
+ onClose,
+ onSelectResult
+}: Props) => {
const navigate = useNavigate({
from: "/organizations/$orgId/projects/secret-management/$projectId/overview"
});
const handleNavigate = () => {
+ onSelectResult({ search: secret.secretKey, tags: [] });
navigate({
search: (prev) => ({
...prev,
secretPath: secret.secretPath,
- search: secret.secretKey,
+ search: undefined,
filterBy: "secret",
environments: [envSlug],
tags: undefined
})
});
- onClose();
+ onClose(false);
};
const visibleMetadata = secret.metadata.slice(0, MAX_VISIBLE_BADGES);
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 fa72872b77..6b6f5316a0 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
@@ -71,19 +71,23 @@ import { QuickSearchEnvTable } from "./QuickSearchEnvTable";
import { QuickSearchFolderItem } from "./QuickSearchFolderItem";
import { QuickSearchMetadataSecretItem } from "./QuickSearchMetadataSecretItem";
import { QuickSearchSecretItem } from "./QuickSearchSecretItem";
+import { QuickSearchSelection } from "./quickSearchTypes";
import {
MetadataMatchType,
MetadataSearchCondition,
SecretMetadataSearchBuilder
} from "./SecretMetadataSearchBuilder";
+export type { QuickSearchSelection } from "./quickSearchTypes";
+
export type QuickSearchModalProps = {
environments: ProjectEnv[];
projectId: string;
tags?: WsTag[];
isSingleEnv?: boolean;
initialValue: string;
- onClose: () => void;
+ onSelectResult: (selection: QuickSearchSelection) => void;
+ onClose: (clearSearch?: boolean) => void;
isOpen: boolean;
onOpenChange: (isOpen: boolean) => void;
};
@@ -167,6 +171,7 @@ const Content = ({
environments,
projectId,
onClose,
+ onSelectResult,
tags,
initialValue = "",
searchInputRef
@@ -476,6 +481,7 @@ const Content = ({
secret={secret}
envSlug={env.slug}
onClose={onClose}
+ onSelectResult={onSelectResult}
/>
))}
</QuickSearchEnvTable>
@@ -506,6 +512,7 @@ const Content = ({
folder={folder}
envSlug={env.slug}
onClose={onClose}
+ onSelectResult={onSelectResult}
/>
))}
{envDynamic.map((ds) => (
@@ -514,6 +521,7 @@ const Content = ({
dynamicSecret={ds}
envSlug={env.slug}
onClose={onClose}
+ onSelectResult={onSelectResult}
/>
))}
{envRotations.map((rotation) => (
@@ -522,6 +530,7 @@ const Content = ({
secretRotation={rotation}
envSlug={env.slug}
onClose={onClose}
+ onSelectResult={onSelectResult}
/>
))}
{envSecrets.map((secret) => (
@@ -532,6 +541,7 @@ const Content = ({
search={debouncedSearch}
tags={Object.keys(filterTags)}
onClose={onClose}
+ onSelectResult={onSelectResult}
/>
))}
</QuickSearchEnvTable>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchSecretItem.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchSecretItem.tsx
index 669bd836d2..7759f8aed3 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchSecretItem.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchSecretItem.tsx
@@ -16,15 +16,25 @@ import { useTimedReset } from "@app/hooks";
import { fetchSecretValue } from "@app/hooks/api/dashboard/queries";
import { SecretV3RawSanitized } from "@app/hooks/api/secrets/types";
+import { QuickSearchSelection } from "./quickSearchTypes";
+
type Props = {
secret: SecretV3RawSanitized;
envSlug: string;
- onClose: () => void;
+ onClose: (clearSearch?: boolean) => void;
tags: string[];
search: string;
+ onSelectResult: (selection: QuickSearchSelection) => void;
};
-export const QuickSearchSecretItem = ({ secret, envSlug, onClose, tags, search }: Props) => {
+export const QuickSearchSecretItem = ({
+ secret,
+ envSlug,
+ onClose,
+ onSelectResult,
+ tags,
+ search
+}: Props) => {
const navigate = useNavigate({
from: "/organizations/$orgId/projects/secret-management/$projectId/overview"
});
@@ -35,17 +45,18 @@ export const QuickSearchSecretItem = ({ secret, envSlug, onClose, tags, search }
const { currentProject } = useProject();
const handleNavigate = () => {
+ onSelectResult({ search: secret.key, tags });
navigate({
search: (prev) => ({
...prev,
secretPath: secret.path,
- search: secret.key,
- tags: tags.length ? tags.join(",") : undefined,
+ search: undefined,
+ tags: undefined,
filterBy: "secret",
environments: [envSlug]
})
});
- onClose();
+ onClose(false);
};
const handleCopy = async () => {
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchSecretRotationItem.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchSecretRotationItem.tsx
index 89a7a4502f..82bcc86d5d 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchSecretRotationItem.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/QuickSearchSecretRotationItem.tsx
@@ -4,28 +4,38 @@ import { ChevronRightIcon, RefreshCwIcon } from "lucide-react";
import { TableCell, TableRow, Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3";
import { TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
+import { QuickSearchSelection } from "./quickSearchTypes";
+
type Props = {
secretRotation: TSecretRotationV2;
envSlug: string;
- onClose: () => void;
+ onClose: (clearSearch?: boolean) => void;
+ onSelectResult: (selection: QuickSearchSelection) => void;
};
-export const QuickSearchSecretRotationItem = ({ secretRotation, envSlug, onClose }: Props) => {
+export const QuickSearchSecretRotationItem = ({
+ secretRotation,
+ envSlug,
+ onClose,
+ onSelectResult
+}: Props) => {
const navigate = useNavigate({
from: "/organizations/$orgId/projects/secret-management/$projectId/overview"
});
const handleNavigate = () => {
+ onSelectResult({ search: secretRotation.name });
navigate({
search: (prev) => ({
...prev,
secretPath: secretRotation.folder.path,
- search: secretRotation.name,
+ search: undefined,
+ tags: undefined,
filterBy: "rotation",
environments: [envSlug]
})
});
- onClose();
+ onClose(false);
};
return (
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/quickSearchTypes.ts b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/quickSearchTypes.ts
new file mode 100644
index 0000000000..708383b104
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretSearchInput/components/quickSearchTypes.ts
@@ -0,0 +1,4 @@
+export type QuickSearchSelection = {
+ search: string;
+ tags?: string[];
+};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/overviewSearchState.test.ts b/frontend/src/pages/secret-manager/OverviewPage/overviewSearchState.test.ts
new file mode 100644
index 0000000000..fb33e3df9d
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/overviewSearchState.test.ts
@@ -0,0 +1,124 @@
+import assert from "node:assert/strict";
+import { describe, it } from "node:test";
+
+import {
+ hasOverviewScopeChanged,
+ hasSensitiveOverviewSearchState,
+ normalizeOverviewEnvironments,
+ parseOverviewTags,
+ resolveOverviewEnvironmentSlugs,
+ serializeOverviewResourceFilter,
+ stripSensitiveOverviewSearchState,
+ updateOverviewSecretPath
+} from "./overviewSearchState";
+
+describe("Secrets overview query state", () => {
+ it("parses one-shot tag links and serializes resource filters canonically", () => {
+ assert.deepEqual(parseOverviewTags("team-b, team-a ,team-b"), {
+ "team-a": true,
+ "team-b": true
+ });
+ assert.equal(
+ serializeOverviewResourceFilter({ folder: true, secret: false, dynamic: true }, [
+ "folder",
+ "dynamic",
+ "secret"
+ ]),
+ "folder,dynamic"
+ );
+ assert.deepEqual(parseOverviewTags(), {});
+ assert.equal(serializeOverviewResourceFilter({}, ["folder", "secret"]), undefined);
+ });
+
+ it("removes secret identifiers from durable URL state while preserving navigation state", () => {
+ const current = {
+ secretPath: "/apps",
+ environments: ["prod"],
+ search: "DATABASE_URL",
+ tags: "team-a",
+ filterBy: "secret",
+ unrelated: "preserved"
+ };
+
+ assert.equal(hasSensitiveOverviewSearchState(current), true);
+ assert.deepEqual(stripSensitiveOverviewSearchState(current), {
+ secretPath: "/apps",
+ environments: ["prod"],
+ search: undefined,
+ tags: undefined,
+ filterBy: "secret",
+ unrelated: "preserved"
+ });
+ assert.equal(
+ hasSensitiveOverviewSearchState({ secretPath: "/apps", environments: ["prod"] }),
+ false
+ );
+ });
+
+ it("normalizes direct environment links to accessible project slugs", () => {
+ assert.deepEqual(normalizeOverviewEnvironments(["removed", "prod", "prod"], ["dev", "prod"]), [
+ "prod"
+ ]);
+ });
+
+ it("resolves environment preferences before the URL is canonicalized", () => {
+ const environments = [
+ { id: "dev-id", slug: "dev" },
+ { id: "prod-id", slug: "prod" }
+ ];
+
+ assert.deepEqual(resolveOverviewEnvironmentSlugs([], ["prod-id"], environments), ["prod"]);
+ assert.deepEqual(resolveOverviewEnvironmentSlugs(["removed"], ["prod-id"], environments), [
+ "prod"
+ ]);
+ assert.deepEqual(
+ resolveOverviewEnvironmentSlugs(["dev", "removed"], ["prod-id"], environments),
+ ["dev"]
+ );
+ });
+
+ it("treats filters as view state and folders or environments as scope state", () => {
+ const current = {
+ pathname: "/organizations/org/projects/secret-management/project/overview",
+ search: { secretPath: "/", environments: ["prod"], search: "api" }
+ };
+
+ assert.equal(
+ hasOverviewScopeChanged(current, {
+ ...current,
+ search: { ...current.search, search: "token", filterBy: "secret" }
+ }),
+ false
+ );
+ assert.equal(
+ hasOverviewScopeChanged(current, {
+ ...current,
+ search: { ...current.search, secretPath: "/apps" }
+ }),
+ true
+ );
+ assert.equal(
+ hasOverviewScopeChanged(current, {
+ ...current,
+ search: { ...current.search, environments: ["dev"] }
+ }),
+ true
+ );
+ });
+
+ it("changes only secretPath during folder and breadcrumb transitions", () => {
+ const current = {
+ secretPath: "/",
+ environments: ["prod"],
+ search: "api",
+ tags: "team-a",
+ filterBy: "folder,secret",
+ unrelated: "preserved"
+ };
+
+ assert.deepEqual(updateOverviewSecretPath(current, "/apps"), {
+ ...current,
+ secretPath: "/apps"
+ });
+ });
+});
diff --git a/frontend/src/pages/secret-manager/OverviewPage/overviewSearchState.ts b/frontend/src/pages/secret-manager/OverviewPage/overviewSearchState.ts
new file mode 100644
index 0000000000..8f3f26b80f
--- /dev/null
+++ b/frontend/src/pages/secret-manager/OverviewPage/overviewSearchState.ts
@@ -0,0 +1,79 @@
+export type OverviewSearchState = {
+ secretPath?: string;
+ environments?: string[];
+ search?: string;
+ tags?: string;
+ filterBy?: string;
+};
+
+export const parseOverviewTags = (tags?: string) =>
+ (tags ?? "").split(",").reduce<Record<string, boolean>>((acc, tag) => {
+ const tagSlug = tag.trim();
+ if (tagSlug) acc[tagSlug] = true;
+ return acc;
+ }, {});
+
+export const hasSensitiveOverviewSearchState = (search: OverviewSearchState) =>
+ Boolean(search.search) || search.tags !== undefined;
+
+export const stripSensitiveOverviewSearchState = <T extends OverviewSearchState>(search: T): T => ({
+ ...search,
+ search: undefined,
+ tags: undefined
+});
+
+export const serializeOverviewResourceFilter = (
+ filter: Record<string, boolean>,
+ resourceTypes: string[]
+) => {
+ const serialized = resourceTypes.filter((resourceType) => filter[resourceType]).join(",");
+ return serialized || undefined;
+};
+
+export const normalizeOverviewEnvironments = (
+ requestedSlugs: string[],
+ availableSlugs: string[]
+) => {
+ const available = new Set(availableSlugs);
+ const normalized = availableSlugs.filter(
+ (slug) => requestedSlugs.includes(slug) && available.has(slug)
+ );
+ return [...new Set(normalized)];
+};
+
+export const resolveOverviewEnvironmentSlugs = (
+ requestedSlugs: string[],
+ storedIds: string[],
+ availableEnvironments: { id: string; slug: string }[]
+) => {
+ const requestedEnvironments = normalizeOverviewEnvironments(
+ requestedSlugs,
+ availableEnvironments.map(({ slug }) => slug)
+ );
+
+ if (requestedEnvironments.length > 0) return requestedEnvironments;
+
+ return availableEnvironments.filter(({ id }) => storedIds.includes(id)).map(({ slug }) => slug);
+};
+
+type OverviewLocation = {
+ pathname: string;
+ search: unknown;
+};
+
+export const hasOverviewScopeChanged = (current: OverviewLocation, next: OverviewLocation) => {
+ if (current.pathname !== next.pathname) return true;
+
+ const currentSearch = current.search as OverviewSearchState;
+ const nextSearch = next.search as OverviewSearchState;
+
+ return (
+ currentSearch.secretPath !== nextSearch.secretPath ||
+ (currentSearch.environments ?? []).join(",") !== (nextSearch.environments ?? []).join(",")
+ );
+};
+
+export const updateOverviewSecretPath = <T extends OverviewSearchState>(
+ search: T,
+ secretPath: string
+): T => ({ ...search, secretPath });
diff --git a/frontend/src/pages/secret-manager/OverviewPage/route.tsx b/frontend/src/pages/secret-manager/OverviewPage/route.tsx
index 16d5249a17..e21184e07a 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/route.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/route.tsx
@@ -22,7 +22,15 @@ export const Route = createFileRoute(
component: OverviewPage,
validateSearch: zodValidator(SecretOverviewPageQuerySchema),
search: {
- middlewares: [stripSearchParams({ secretPath: "/", search: "", environments: [] })]
+ middlewares: [
+ stripSearchParams({
+ secretPath: "/",
+ search: "",
+ environments: [],
+ tags: undefined,
+ filterBy: undefined
+ })
+ ]
},
beforeLoad: ({ context, params }) => ({
...context,