diff --git a/client/src/pages/Config/Inventory/InventoryList.tsx b/client/src/pages/Config/Inventory/InventoryList.tsx index 0dc4cd63..548f8e53 100644 --- a/client/src/pages/Config/Inventory/InventoryList.tsx +++ b/client/src/pages/Config/Inventory/InventoryList.tsx @@ -4,10 +4,24 @@ import Menubar from "@thorium/ui/Menubar"; import Button from "@thorium/ui/Button"; import {toast} from "client/src/context/ToastContext"; import SearchableList from "@thorium/ui/SearchableList"; -import {Fragment} from "react"; +import {Fragment, Suspense} from "react"; import {q} from "@client/context/AppContext"; export function InventoryList() { + const {pluginId} = useParams() as { + pluginId: string; + }; + return ( +
+ + + + +
+ ); +} + +function InventoryListInner() { const {pluginId, inventoryId} = useParams() as { pluginId: string; inventoryId?: string; @@ -16,61 +30,59 @@ export function InventoryList() { const prompt = usePrompt(); const [data] = q.plugin.inventory.all.useNetRequest({pluginId}); const inventory = data.find(d => d.name === inventoryId); + return ( -
- -
-

Inventory Config

-
-
- + } + }} + > + New Inventory Item + - ({ - id: d.name, - name: d.name, - description: d.description, - }))} - searchKeys={["name"]} - selectedItem={inventoryId || null} - setSelectedItem={({id}) => navigate(`${id}`)} - renderItem={c => ( -
-
{c.name}
-
- )} - /> -
- - - + ({ + id: d.name, + name: d.name, + description: d.description, + }))} + searchKeys={["name"]} + selectedItem={inventoryId || null} + setSelectedItem={({id}) => navigate(`${id}`)} + renderItem={c => ( +
+
{c.name}
+
+ )} + />
+ + +
); diff --git a/client/src/pages/Config/PluginEdit.tsx b/client/src/pages/Config/PluginEdit.tsx index 9104b36c..d2804fc9 100644 --- a/client/src/pages/Config/PluginEdit.tsx +++ b/client/src/pages/Config/PluginEdit.tsx @@ -13,80 +13,87 @@ import {toast} from "@client/context/ToastContext"; import {q} from "@client/context/AppContext"; export default function PluginEdit() { + return ( +
+ + + + +
+ ); +} + +function PluginEditInner() { const {pluginId} = useParams() as {pluginId: string}; const [plugins] = q.plugin.all.useNetRequest(); const navigate = useNavigate(); const prompt = usePrompt(); - return ( -
- -
-

Plugin Config

+
+

Plugin Config

-
-
- + } + }} + > + New Plugin + - ({ - id: d.id, - name: d.name, - description: d.description, - tags: d.tags, - author: d.author, - active: d.active, - }))} - searchKeys={["name", "author", "tags"]} - selectedItem={pluginId || null} - setSelectedItem={({id}) => navigate(`/config/${id}`)} - renderItem={c => ( -
+ ({ + id: d.id, + name: d.name, + description: d.description, + tags: d.tags, + author: d.author, + active: d.active, + }))} + searchKeys={["name", "author", "tags"]} + selectedItem={pluginId || null} + setSelectedItem={({id}) => navigate(`/config/${id}`)} + renderItem={c => ( +
+
+ {c.name} + {c.active ? ( + "" + ) : ( + (inactive) + )}
- {c.name} - {c.active ? ( - "" - ) : ( - (inactive) - )} -
- {c.author} -
+ {c.author}
- e.stopPropagation()} - > - -
- )} - /> -
- }> - - + e.stopPropagation()} + > + + +
+ )} + />
+ }> + +
); diff --git a/client/src/pages/Config/ShipSystems/ShipSystemsList.tsx b/client/src/pages/Config/ShipSystems/ShipSystemsList.tsx index 4bcf8a2d..411ce7cf 100644 --- a/client/src/pages/Config/ShipSystems/ShipSystemsList.tsx +++ b/client/src/pages/Config/ShipSystems/ShipSystemsList.tsx @@ -2,7 +2,7 @@ import {usePrompt} from "@thorium/ui/AlertDialog"; import Menubar from "@thorium/ui/Menubar"; import SearchableList from "@thorium/ui/SearchableList"; import {Outlet, useParams, useNavigate} from "react-router-dom"; -import {Fragment} from "react"; +import {Fragment, Suspense} from "react"; import {toast} from "client/src/context/ToastContext"; import Dropdown, {DropdownItem} from "@thorium/ui/Dropdown"; import {HiChevronDown} from "react-icons/hi"; @@ -11,6 +11,20 @@ import {capitalCase} from "change-case"; import {q} from "@client/context/AppContext"; export function ShipSystemsList() { + const {pluginId} = useParams() as { + pluginId: string; + }; + return ( +
+ + + + +
+ ); +} + +function ShipSystemsInner() { const {pluginId, systemId} = useParams() as { pluginId: string; systemId?: string; @@ -20,82 +34,80 @@ export function ShipSystemsList() { const [data] = q.plugin.systems.all.useNetRequest({pluginId}); const [availableShipSystems] = q.plugin.systems.available.useNetRequest(); const system = data.find(d => d.name === systemId); + return ( -
- -
-

- Ship Systems Config -

-
-
- - New Ship System - - } - > - {availableShipSystems.map(system => ( - { - const name = await prompt({ - header: "Enter system name", - defaultValue: capitalCase(system.type), +
+

+ Ship Systems Config +

+
+
+ + New Ship System + + } + > + {availableShipSystems.map(system => ( + { + const name = await prompt({ + header: "Enter system name", + defaultValue: capitalCase(system.type), + }); + if (typeof name !== "string") return; + try { + const result = await q.plugin.systems.create.netSend({ + name, + type: system.type, + pluginId, }); - if (typeof name !== "string") return; - try { - const result = await q.plugin.systems.create.netSend({ - name, - type: system.type, - pluginId, + navigate(`${result.shipSystemId}`); + } catch (err) { + if (err instanceof Error) { + toast({ + title: "Error creating system", + body: err.message, + color: "error", }); - navigate(`${result.shipSystemId}`); - } catch (err) { - if (err instanceof Error) { - toast({ - title: "Error creating system", - body: err.message, - color: "error", - }); - return; - } + return; } - }} - > - {capitalCase(system.type)} - - ))} - + } + }} + > + {capitalCase(system.type)} + + ))} + - ({ - id: d.name, - name: d.name, - description: d.description, - category: capitalCase(d.type), - tags: d.tags, - }))} - searchKeys={["name", "category", "tags"]} - selectedItem={systemId || null} - setSelectedItem={({id}) => navigate(`${id}`)} - renderItem={c => ( -
+ ({ + id: d.name, + name: d.name, + description: d.description, + category: capitalCase(d.type), + tags: d.tags, + }))} + searchKeys={["name", "category", "tags"]} + selectedItem={systemId || null} + setSelectedItem={({id}) => navigate(`${id}`)} + renderItem={c => ( +
+
+ {c.name}
- {c.name} -
- {c.category} -
+ {c.category}
- )} - /> -
- - - +
+ )} + />
+ + +
); diff --git a/client/src/pages/Config/Ships/ShipList.tsx b/client/src/pages/Config/Ships/ShipList.tsx index abc5ca9b..c8693114 100644 --- a/client/src/pages/Config/Ships/ShipList.tsx +++ b/client/src/pages/Config/Ships/ShipList.tsx @@ -3,77 +3,87 @@ import Menubar from "@thorium/ui/Menubar"; import SearchableList from "@thorium/ui/SearchableList"; import Button from "@thorium/ui/Button"; import {Outlet, useParams, useNavigate} from "react-router-dom"; -import {Fragment} from "react"; +import {Fragment, Suspense} from "react"; import {toast} from "@client/context/ToastContext"; import {q} from "@client/context/AppContext"; export function ShipList() { + const {pluginId} = useParams() as {pluginId: string}; + + return ( +
+ + + + +
+ ); +} + +function ShipListInner() { const {pluginId, shipId} = useParams() as {pluginId: string; shipId?: string}; const navigate = useNavigate(); const prompt = usePrompt(); const [ships] = q.plugin.ship.all.useNetRequest({pluginId}); const ship = ships.find(d => d.name === shipId); + return ( -
- -
-

Ships Config

-
-
- + } + }} + > + New Ship + - ({ - id: d.name, - name: d.name, - description: d.description, - category: d.category, - tags: d.tags, - }))} - searchKeys={["name", "category", "tags"]} - selectedItem={shipId || null} - setSelectedItem={({id}) => navigate(`${id}`)} - renderItem={c => ( -
+ ({ + id: d.name, + name: d.name, + description: d.description, + category: d.category, + tags: d.tags, + }))} + searchKeys={["name", "category", "tags"]} + selectedItem={shipId || null} + setSelectedItem={({id}) => navigate(`${id}`)} + renderItem={c => ( +
+
+ {c.name}
- {c.name} -
- {c.category} -
+ {c.category}
- )} - /> -
- - - +
+ )} + />
+ + +
); diff --git a/client/src/pages/Config/Themes/ThemeList.tsx b/client/src/pages/Config/Themes/ThemeList.tsx index bba6c59b..806a7879 100644 --- a/client/src/pages/Config/Themes/ThemeList.tsx +++ b/client/src/pages/Config/Themes/ThemeList.tsx @@ -3,11 +3,25 @@ import Menubar from "@thorium/ui/Menubar"; import SearchableList from "@thorium/ui/SearchableList"; import Button from "@thorium/ui/Button"; import {Outlet, useParams, useNavigate} from "react-router-dom"; -import {Fragment} from "react"; +import {Fragment, Suspense} from "react"; import {toast} from "client/src/context/ToastContext"; import {q} from "@client/context/AppContext"; export function ThemeList() { + const {pluginId} = useParams() as { + pluginId: string; + }; + return ( +
+ + + + +
+ ); +} + +function ThemeListInner() { const {pluginId, themeId} = useParams() as { pluginId: string; themeId?: string; @@ -16,59 +30,56 @@ export function ThemeList() { const prompt = usePrompt(); const [data] = q.plugin.theme.all.useNetRequest({pluginId}); const theme = data.find(d => d.name === themeId); + return ( -
- -
-

Themes Config

-
-
- + } + }} + > + New theme + - ({ - id: d.name, - name: d.name, - }))} - searchKeys={["name"]} - selectedItem={themeId || null} - setSelectedItem={({id}) => navigate(`${id}`)} - renderItem={c => ( -
-
{c.name}
-
- )} - /> -
- - - + ({ + id: d.name, + name: d.name, + }))} + searchKeys={["name"]} + selectedItem={themeId || null} + setSelectedItem={({id}) => navigate(`${id}`)} + renderItem={c => ( +
+
{c.name}
+
+ )} + />
+ + +
); diff --git a/client/src/pages/Config/index.tsx b/client/src/pages/Config/index.tsx index fc0bd956..57db10e9 100644 --- a/client/src/pages/Config/index.tsx +++ b/client/src/pages/Config/index.tsx @@ -1,5 +1,5 @@ import {q} from "@client/context/AppContext"; -import {lazy} from "react"; +import {lazy, Suspense} from "react"; import {Navigate, Route, Routes} from "react-router-dom"; const PluginEdit = lazy(() => import("./PluginEdit")); @@ -16,15 +16,25 @@ export default function ConfigRoutes() { if (!client.isHost) return ; return ( - - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - + <> +
+ + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } + /> + + +
+
+ ); }