Étend le flux de création de layout backend (DTO, usecases, store) et le frontend (sélecteur, adaptateurs, LayoutTabs/LayoutGrid) pour permettre d'ouvrir un layout déclaré par un plugin installé (ex. Android Health), sans passer par le message bloquant "extension backend pas encore livrée". Ticket #141 — QA vert. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
/**
|
|
* Tauri adapter for {@link LayoutGateway} (L4). Together with the sibling
|
|
* adapters this is the *only* place that calls `invoke()`; components reach it
|
|
* exclusively through the port.
|
|
*
|
|
* Commands and payload keys are camelCase, matching the backend DTO convention.
|
|
* The `load_layout`/`mutate_layout` commands return the layout tree directly
|
|
* (the backend `LayoutDto` is `#[serde(transparent)]` over the tree).
|
|
*/
|
|
|
|
import { invoke } from "@tauri-apps/api/core";
|
|
|
|
import type {
|
|
LayoutKind,
|
|
LayoutList,
|
|
LayoutOperation,
|
|
LayoutTree,
|
|
PluginLayoutOrigin,
|
|
} from "@/domain";
|
|
import type { LayoutGateway } from "@/ports";
|
|
|
|
export class TauriLayoutGateway implements LayoutGateway {
|
|
loadLayout(projectId: string, layoutId?: string): Promise<LayoutTree> {
|
|
return invoke<LayoutTree>("load_layout", { projectId, layoutId });
|
|
}
|
|
|
|
mutateLayout(
|
|
projectId: string,
|
|
operation: LayoutOperation,
|
|
layoutId?: string,
|
|
): Promise<LayoutTree> {
|
|
return invoke<LayoutTree>("mutate_layout", { projectId, layoutId, operation });
|
|
}
|
|
|
|
listLayouts(projectId: string): Promise<LayoutList> {
|
|
return invoke<LayoutList>("list_layouts", { projectId });
|
|
}
|
|
|
|
createLayout(
|
|
projectId: string,
|
|
name: string,
|
|
kind?: LayoutKind,
|
|
pluginOrigin?: PluginLayoutOrigin,
|
|
): Promise<{ layoutId: string }> {
|
|
return invoke<{ layoutId: string }>("create_layout", {
|
|
request: { projectId, name, kind, pluginOrigin },
|
|
});
|
|
}
|
|
|
|
renameLayout(projectId: string, layoutId: string, name: string): Promise<void> {
|
|
return invoke<void>("rename_layout", {
|
|
request: { projectId, layoutId, name },
|
|
});
|
|
}
|
|
|
|
deleteLayout(projectId: string, layoutId: string): Promise<{ activeId: string }> {
|
|
return invoke<{ activeId: string }>("delete_layout", {
|
|
request: { projectId, layoutId },
|
|
});
|
|
}
|
|
|
|
setActiveLayout(projectId: string, layoutId: string): Promise<{ activeId: string }> {
|
|
return invoke<{ activeId: string }>("set_active_layout", {
|
|
request: { projectId, layoutId },
|
|
});
|
|
}
|
|
}
|