* wip: Add gridstack board * wip: Centralize board pages, Add board settings page * fix: remove cyclic dependency and rename widget-sort to kind * improve: Add header actions as parallel route * feat: add item select modal, add category edit modal, * feat: add edit item modal * feat: add remove item modal * wip: add category actions * feat: add saving of board, wip: add app widget * Merge branch 'main' into add-board * chore: update turbo dependencies * chore: update mantine dependencies * chore: fix typescript errors, lint and format * feat: add confirm modal to category removal, move items of removed category to above wrapper * feat: remove app widget to continue in another branch * feat: add loading spinner until board is initialized * fix: issue with cellheight of gridstack items * feat: add translations for board * fix: issue with translation for settings page * feat: add widget server loader * fix: typing issue * chore: address pull request feedback * fix: formatting
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import type { PropsWithChildren } from "react";
|
|
import { Suspense } from "react";
|
|
|
|
import type { RouterOutputs } from "@homarr/api";
|
|
|
|
import { widgetImports } from "..";
|
|
import { ClientServerDataInitalizer } from "./client";
|
|
import { GlobalItemServerDataProvider } from "./provider";
|
|
|
|
type Board = RouterOutputs["board"]["default"];
|
|
|
|
type Props = PropsWithChildren<{
|
|
board: Board;
|
|
}>;
|
|
|
|
export const GlobalItemServerDataRunner = ({ board, children }: Props) => {
|
|
const allItems = board.sections.flatMap((section) => section.items);
|
|
|
|
return (
|
|
<GlobalItemServerDataProvider initalItemIds={allItems.map(({ id }) => id)}>
|
|
{allItems.map((item) => (
|
|
<Suspense key={item.id}>
|
|
<ItemDataLoader item={item} />
|
|
</Suspense>
|
|
))}
|
|
{children}
|
|
</GlobalItemServerDataProvider>
|
|
);
|
|
};
|
|
|
|
interface ItemDataLoaderProps {
|
|
item: Board["sections"][number]["items"][number];
|
|
}
|
|
|
|
const ItemDataLoader = async ({ item }: ItemDataLoaderProps) => {
|
|
const widgetImport = widgetImports[item.kind];
|
|
if (!("serverDataLoader" in widgetImport)) {
|
|
return <ClientServerDataInitalizer id={item.id} serverData={undefined} />;
|
|
}
|
|
const loader = await widgetImport.serverDataLoader();
|
|
const data = await loader.default(item as never);
|
|
return <ClientServerDataInitalizer id={item.id} serverData={data} />;
|
|
};
|