Files
pangolin/src/lib/hydrateNavHref.ts
Laurence 2e9a040174 Add global Ctrl+K command palette for navigation and search.
Provides quick access to sidebar destinations, org switching, server-filtered entity lookup, and common actions from anywhere in the authenticated layout.
2026-05-29 11:22:14 +01:00

36 lines
1.1 KiB
TypeScript

export type NavHrefParams = {
orgId?: string;
niceId?: string;
resourceId?: string;
userId?: string;
apiKeyId?: string;
clientId?: string;
};
export function hydrateNavHref(
val: string | undefined,
params: NavHrefParams
): string | undefined {
if (!val) return undefined;
return val
.replace("{orgId}", params.orgId ?? "")
.replace("{niceId}", params.niceId ?? "")
.replace("{resourceId}", params.resourceId ?? "")
.replace("{userId}", params.userId ?? "")
.replace("{apiKeyId}", params.apiKeyId ?? "")
.replace("{clientId}", params.clientId ?? "");
}
export function navHrefParamsFromRoute(
params: Record<string, string | string[] | undefined>
): NavHrefParams {
return {
orgId: params.orgId as string | undefined,
niceId: params.niceId as string | undefined,
resourceId: params.resourceId as string | undefined,
userId: params.userId as string | undefined,
apiKeyId: params.apiKeyId as string | undefined,
clientId: params.clientId as string | undefined
};
}