mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-20 03:02:58 +02:00
Pass 2 showing the usage commands
This commit is contained in:
@@ -36,7 +36,6 @@ import {
|
||||
import { getLauncherResourceAdminHref } from "@app/lib/launcherResourceAdminHref";
|
||||
import { isSafeUrlForLink } from "@app/lib/launcherResourceAccess";
|
||||
import { launcherQueries } from "@app/lib/queries";
|
||||
import { formatVirtualApiKeyPreview } from "@app/lib/virtualApiKeyFormat";
|
||||
import type { LauncherResource } from "@server/routers/launcher/types";
|
||||
import type { GetResourceAuthInfoResponse } from "@server/routers/resource/getResourceAuthInfo";
|
||||
import type { GetResourceResponse } from "@server/routers/resource/getResource";
|
||||
@@ -350,10 +349,6 @@ function PublicResourceDetails({
|
||||
endpoint={launcherResource.accessUrl ?? ""}
|
||||
auth={{
|
||||
mode: "keyed",
|
||||
keyDisplay: formatVirtualApiKeyPreview(
|
||||
aiKeysData.userKey.virtualApiKeyId,
|
||||
aiKeysData.userKey.lastChars
|
||||
),
|
||||
getKeyText: getAiKeyCopyText
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
parseLauncherUrlState,
|
||||
serializeLauncherUrlState
|
||||
} from "@app/lib/launcherUrlState";
|
||||
import { buildLauncherSearchParams } from "@app/lib/launcherSearchParams";
|
||||
import { useToast } from "@app/hooks/useToast";
|
||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||
import {
|
||||
@@ -38,13 +39,16 @@ import {
|
||||
import { launcherQueries } from "@app/lib/queries";
|
||||
import {
|
||||
getEffectiveDefaultLauncherConfig,
|
||||
LAUNCHER_FLAT_GROUP_KEY,
|
||||
type LauncherDefaultViewOverrides,
|
||||
type LauncherGroup,
|
||||
type LauncherResource,
|
||||
type LauncherScaleInfo,
|
||||
type LauncherViewConfig,
|
||||
type LauncherViewRecord
|
||||
type LauncherViewRecord,
|
||||
type ListLauncherResourcesResponse
|
||||
} from "@server/routers/launcher/types";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { Search } from "lucide-react";
|
||||
import { useTranslations } from "next-intl";
|
||||
@@ -580,6 +584,61 @@ export default function ResourceLauncher({
|
||||
}
|
||||
}, []);
|
||||
|
||||
const hasHandledAutoOpen = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (hasHandledAutoOpen.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
const targetNiceId = searchParams.get("openResource");
|
||||
if (!targetNiceId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The launcher search endpoint matches on name/domain/labels, not
|
||||
// niceId, so search by name (if provided) and pick the exact niceId
|
||||
// match out of the results.
|
||||
const searchTerm =
|
||||
searchParams.get("openResourceQuery") ?? targetNiceId;
|
||||
|
||||
hasHandledAutoOpen.current = true;
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const sp = buildLauncherSearchParams(
|
||||
{
|
||||
query: searchTerm,
|
||||
groupBy: configRef.current.groupBy,
|
||||
groupKey: LAUNCHER_FLAT_GROUP_KEY,
|
||||
siteIds: [],
|
||||
labelIds: [],
|
||||
sort_by: configRef.current.sortBy,
|
||||
order: configRef.current.order
|
||||
},
|
||||
1
|
||||
);
|
||||
const res = await api.get<
|
||||
AxiosResponse<ListLauncherResourcesResponse>
|
||||
>(`/org/${orgId}/launcher/resources?${sp.toString()}`);
|
||||
const resources = res.data.data.resources ?? [];
|
||||
const match =
|
||||
resources.find((r) => r.niceId === targetNiceId) ??
|
||||
resources[0];
|
||||
if (match) {
|
||||
handleResourceSelect(match);
|
||||
}
|
||||
} catch {
|
||||
// Resource may no longer exist or be accessible; ignore.
|
||||
} finally {
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
params.delete("openResource");
|
||||
params.delete("openResourceQuery");
|
||||
navigate({ searchParams: params, replace: true });
|
||||
}
|
||||
})();
|
||||
}, [api, handleResourceSelect, navigate, orgId, searchParams]);
|
||||
|
||||
const savedViewTabs = views.map((view) => ({
|
||||
viewId: view.viewId,
|
||||
name: view.name
|
||||
|
||||
Reference in New Issue
Block a user