mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-25 10:51:57 +01:00
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import type { Folder, GrpcRequest, WebsocketRequest, Workspace } from "@yaakapp-internal/models";
|
|
import type { HttpRequest } from "@yaakapp-internal/sync";
|
|
import { router } from "./router.js";
|
|
|
|
/**
|
|
* Setting search params using "from" on the global router instance in tanstack router does not
|
|
* currently behave very well, so this is a wrapper function that gives a typesafe interface
|
|
* for the same thing.
|
|
*/
|
|
export function setWorkspaceSearchParams(
|
|
search: Partial<{
|
|
cookie_jar_id: string | null;
|
|
environment_id: string | null;
|
|
request_id: string | null;
|
|
folder_id: string | null;
|
|
}>,
|
|
) {
|
|
// oxlint-disable-next-line no-explicit-any
|
|
(router as any)
|
|
.navigate({
|
|
// oxlint-disable-next-line no-explicit-any
|
|
search: (prev: any) => {
|
|
// console.log('Navigating to', { prev, search });
|
|
const o = { ...prev, ...search };
|
|
for (const k of Object.keys(o)) {
|
|
if (o[k] == null) {
|
|
delete o[k];
|
|
}
|
|
}
|
|
return o;
|
|
},
|
|
})
|
|
.catch(console.error);
|
|
}
|
|
|
|
export function navigateToRequestOrFolderOrWorkspace(
|
|
id: string,
|
|
model: (Workspace | Folder | HttpRequest | GrpcRequest | WebsocketRequest)["model"],
|
|
) {
|
|
if (model === "workspace") {
|
|
setWorkspaceSearchParams({ request_id: null, folder_id: null });
|
|
} else if (model === "folder") {
|
|
setWorkspaceSearchParams({ request_id: null, folder_id: id });
|
|
} else {
|
|
setWorkspaceSearchParams({ request_id: id, folder_id: null });
|
|
}
|
|
}
|