diff --git a/pkgs/clan-app/ui/src/components/machine-list-item/index.tsx b/pkgs/clan-app/ui/src/components/machine-list-item/index.tsx index c523285f3..2cf8dc85e 100644 --- a/pkgs/clan-app/ui/src/components/machine-list-item/index.tsx +++ b/pkgs/clan-app/ui/src/components/machine-list-item/index.tsx @@ -9,7 +9,7 @@ import { Typography } from "../Typography"; import "./css/index.css"; import { useClanContext } from "@/src/contexts/clan"; -type MachineDetails = SuccessQuery<"list_inv_machines">["data"][string]; +type MachineDetails = SuccessQuery<"list_machines">["data"][string]; interface MachineListItemProps { name: string; diff --git a/pkgs/clan-app/ui/src/routes/machines/create.tsx b/pkgs/clan-app/ui/src/routes/machines/create.tsx index 5eaa6ae06..54032f368 100644 --- a/pkgs/clan-app/ui/src/routes/machines/create.tsx +++ b/pkgs/clan-app/ui/src/routes/machines/create.tsx @@ -63,7 +63,7 @@ export function CreateMachine() { reset(formStore); await queryClient.invalidateQueries({ - queryKey: [active_dir, "list_inv_machines"], + queryKey: [active_dir, "list_machines"], }); navigate("/machines"); diff --git a/pkgs/clan-app/ui/src/routes/machines/list.tsx b/pkgs/clan-app/ui/src/routes/machines/list.tsx index c792a0110..6a25aac4b 100644 --- a/pkgs/clan-app/ui/src/routes/machines/list.tsx +++ b/pkgs/clan-app/ui/src/routes/machines/list.tsx @@ -10,7 +10,7 @@ import { makePersisted } from "@solid-primitives/storage"; import { useClanContext } from "@/src/contexts/clan"; type MachinesModel = Extract< - OperationResponse<"list_inv_machines">, + OperationResponse<"list_machines">, { status: "success" } >["data"]; @@ -25,14 +25,14 @@ export const MachineListView: Component = () => { const { activeClanURI } = useClanContext(); const inventoryQuery = useQuery(() => ({ - queryKey: [activeClanURI(), "list_inv_machines"], + queryKey: [activeClanURI(), "list_machines"], placeholderData: {}, enabled: !!activeClanURI(), queryFn: async () => { console.log("fetching inventory", activeClanURI()); const uri = activeClanURI(); if (uri) { - const response = await callApi("list_inv_machines", { + const response = await callApi("list_machines", { flake: { identifier: uri, }, @@ -60,7 +60,7 @@ export const MachineListView: Component = () => { await queryClient.invalidateQueries({ // Invalidates the cache for of all types of machine list at once - queryKey: [clanURI, "list_inv_machines"], + queryKey: [clanURI, "list_machines"], }); }; diff --git a/pkgs/clan-cli/clan_cli/machines/list.py b/pkgs/clan-cli/clan_cli/machines/list.py index 7c26c1b80..25952eaf4 100644 --- a/pkgs/clan-cli/clan_cli/machines/list.py +++ b/pkgs/clan-cli/clan_cli/machines/list.py @@ -20,18 +20,6 @@ from clan_cli.machines.hardware import HardwareConfig log = logging.getLogger(__name__) -@API.register -def list_inv_machines(flake: Flake) -> dict[str, InventoryMachine]: - """ - List machines in the inventory for the UI. - """ - inventory_store = InventoryStore(flake=flake) - inventory = inventory_store.read() - - res = inventory.get("machines", {}) - return res - - def list_machines( flake: Flake, nix_options: list[str] | None = None ) -> dict[str, Machine]: diff --git a/pkgs/clan-cli/clan_lib/machines/actions.py b/pkgs/clan-cli/clan_lib/machines/actions.py index 8d0a48acf..2a42bb0e7 100644 --- a/pkgs/clan-cli/clan_lib/machines/actions.py +++ b/pkgs/clan-cli/clan_lib/machines/actions.py @@ -10,6 +10,18 @@ from clan_lib.persist.inventory_store import InventoryStore from clan_lib.persist.util import set_value_by_path +@API.register +def list_machines(flake: Flake) -> dict[str, InventoryMachine]: + """ + List machines in the inventory for the UI. + """ + inventory_store = InventoryStore(flake=flake) + inventory = inventory_store.read() + + machine = inventory.get("machines", {}) + return machine + + @API.register def get_machine(flake: Flake, name: str) -> InventoryMachine: inventory_store = InventoryStore(flake=flake)