mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-25 10:42:45 +00:00
* feat(plugins): open external links and workspace browsers * fix(plugins): refuse invalid links and unavailable browser workspaces * docs(plugins): clarify external links and browser navigation
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
import { useSessionStore } from "@/stores/session-store";
|
|
import { resolveWorkspaceMapKeyByIdentity } from "@/utils/workspace-identity";
|
|
import { useMemo } from "react";
|
|
import { navigateToWorkspace } from "@/stores/navigation-active-workspace-store";
|
|
import { navigateToAgent } from "@/utils/navigate-to-agent";
|
|
|
|
import { getIsElectron } from "@/constants/platform";
|
|
import { createWorkspaceBrowser } from "@/desktop/browser/store";
|
|
import { createPluginHostNavigation } from "./host-navigation-model";
|
|
|
|
export function usePluginHostNavigation(
|
|
serverId: string,
|
|
): NonNullable<PluginSurfaceProps["navigation"]> {
|
|
return useMemo(
|
|
() =>
|
|
createPluginHostNavigation(serverId, {
|
|
browserAvailable: getIsElectron(),
|
|
openAgent: navigateToAgent,
|
|
openWorkspace: navigateToWorkspace,
|
|
createBrowser: createWorkspaceBrowser,
|
|
resolveWorkspace: ({ serverId: targetServerId, workspaceId }) =>
|
|
resolveWorkspaceMapKeyByIdentity({
|
|
workspaces: useSessionStore.getState().sessions[targetServerId]?.workspaces,
|
|
workspaceId,
|
|
}),
|
|
}),
|
|
[serverId],
|
|
);
|
|
}
|