mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-30 22:22:02 +02:00
Refactor desktop app into separate client and proxy apps
This commit is contained in:
40
apps/yaak-client/routes/workspaces/$workspaceId/index.tsx
Normal file
40
apps/yaak-client/routes/workspaces/$workspaceId/index.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
import { Workspace } from '../../../components/Workspace';
|
||||
|
||||
type WorkspaceSearchSchema = {
|
||||
environment_id?: string | null;
|
||||
cookie_jar_id?: string | null;
|
||||
} & (
|
||||
| {
|
||||
request_id: string;
|
||||
}
|
||||
| {
|
||||
folder_id: string;
|
||||
}
|
||||
// biome-ignore lint/complexity/noBannedTypes: Needed to support empty
|
||||
| {}
|
||||
);
|
||||
|
||||
export const Route = createFileRoute('/workspaces/$workspaceId/')({
|
||||
component: RouteComponent,
|
||||
validateSearch: (search: Record<string, unknown>): WorkspaceSearchSchema => {
|
||||
const base: Pick<WorkspaceSearchSchema, 'environment_id' | 'cookie_jar_id'> = {
|
||||
environment_id: search.environment_id as string,
|
||||
cookie_jar_id: search.cookie_jar_id as string,
|
||||
};
|
||||
|
||||
const requestId = search.request_id as string | undefined;
|
||||
const folderId = search.folder_id as string | undefined;
|
||||
if (requestId != null) {
|
||||
return { ...base, request_id: requestId };
|
||||
}
|
||||
if (folderId) {
|
||||
return { ...base, folder_id: folderId };
|
||||
}
|
||||
return base;
|
||||
},
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
return <Workspace />;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { createFileRoute, Navigate, useParams } from '@tanstack/react-router';
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// IMPORTANT: This is a deprecated route. Since the active request is optional, it was
|
||||
// moved from a path param to a query parameter. This route does a redirect to the
|
||||
// parent, while preserving the active request.
|
||||
|
||||
export const Route = createFileRoute('/workspaces/$workspaceId/requests/$requestId')({
|
||||
component: RouteComponent,
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
const { workspaceId, requestId } = useParams({
|
||||
from: '/workspaces/$workspaceId/requests/$requestId',
|
||||
});
|
||||
return (
|
||||
<Navigate
|
||||
to="/workspaces/$workspaceId"
|
||||
params={{ workspaceId }}
|
||||
search={(prev) => ({ ...prev, requestId })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
18
apps/yaak-client/routes/workspaces/$workspaceId/settings.tsx
Normal file
18
apps/yaak-client/routes/workspaces/$workspaceId/settings.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
import type { SettingsTab } from '../../../components/Settings/Settings';
|
||||
import Settings from '../../../components/Settings/Settings';
|
||||
|
||||
interface SettingsSearchSchema {
|
||||
tab?: SettingsTab;
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/workspaces/$workspaceId/settings')({
|
||||
component: RouteComponent,
|
||||
validateSearch: (search: Record<string, unknown>): SettingsSearchSchema => ({
|
||||
tab: (search.tab ?? 'general') as SettingsTab,
|
||||
}),
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
return <Settings />;
|
||||
}
|
||||
10
apps/yaak-client/routes/workspaces/index.tsx
Normal file
10
apps/yaak-client/routes/workspaces/index.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
import { RedirectToLatestWorkspace } from '../../components/RedirectToLatestWorkspace';
|
||||
|
||||
export const Route = createFileRoute('/workspaces/')({
|
||||
component: RouteComponent,
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
return <RedirectToLatestWorkspace />;
|
||||
}
|
||||
Reference in New Issue
Block a user