From 121548ffb7dc366cbe17bebc6e93903f3be377a6 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sat, 9 Aug 2025 13:50:25 +0200 Subject: [PATCH] UI/onboarding: init admin instance --- .../ui/src/routes/Onboarding/Onboarding.tsx | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pkgs/clan-app/ui/src/routes/Onboarding/Onboarding.tsx b/pkgs/clan-app/ui/src/routes/Onboarding/Onboarding.tsx index 099b070bb..03b406ca3 100644 --- a/pkgs/clan-app/ui/src/routes/Onboarding/Onboarding.tsx +++ b/pkgs/clan-app/ui/src/routes/Onboarding/Onboarding.tsx @@ -33,6 +33,7 @@ import * as v from "valibot"; import { HostFileInput } from "@/src/components/Form/HostFileInput"; import { callApi } from "@/src/hooks/api"; import { Creating } from "./Creating"; +import { useApiClient } from "@/src/hooks/ApiClient"; type State = "welcome" | "setup" | "creating"; @@ -208,13 +209,15 @@ export const Onboarding: Component = (props) => { throw new Error("No data returned from api call"); }; + const client = useApiClient(); + const onSubmit: SubmitHandler = async ( { name, description, directory }, event, ) => { const path = `${directory}/${name}`; - const req = callApi("create_clan", { + const req = client.fetch("create_clan", { opts: { dest: path, // todo allow users to select a template @@ -230,6 +233,24 @@ export const Onboarding: Component = (props) => { const resp = await req.result; + // Set up default services + await client.fetch("create_service_instance", { + flake: { + identifier: path, + }, + module_ref: { + name: "admin", + input: "clan-core", + }, + roles: { + default: { + tags: { + all: {}, + }, + }, + }, + }).result; + if (resp.status === "error") { setWelcomeError(resp.errors[0].message); setState("welcome");