UI/onboarding: init admin instance

This commit is contained in:
Johannes Kirschbauer
2025-08-09 13:50:25 +02:00
parent 966a3ee919
commit 121548ffb7

View File

@@ -33,6 +33,7 @@ import * as v from "valibot";
import { HostFileInput } from "@/src/components/Form/HostFileInput"; import { HostFileInput } from "@/src/components/Form/HostFileInput";
import { callApi } from "@/src/hooks/api"; import { callApi } from "@/src/hooks/api";
import { Creating } from "./Creating"; import { Creating } from "./Creating";
import { useApiClient } from "@/src/hooks/ApiClient";
type State = "welcome" | "setup" | "creating"; type State = "welcome" | "setup" | "creating";
@@ -208,13 +209,15 @@ export const Onboarding: Component<RouteSectionProps> = (props) => {
throw new Error("No data returned from api call"); throw new Error("No data returned from api call");
}; };
const client = useApiClient();
const onSubmit: SubmitHandler<SetupForm> = async ( const onSubmit: SubmitHandler<SetupForm> = async (
{ name, description, directory }, { name, description, directory },
event, event,
) => { ) => {
const path = `${directory}/${name}`; const path = `${directory}/${name}`;
const req = callApi("create_clan", { const req = client.fetch("create_clan", {
opts: { opts: {
dest: path, dest: path,
// todo allow users to select a template // todo allow users to select a template
@@ -230,6 +233,24 @@ export const Onboarding: Component<RouteSectionProps> = (props) => {
const resp = await req.result; 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") { if (resp.status === "error") {
setWelcomeError(resp.errors[0].message); setWelcomeError(resp.errors[0].message);
setState("welcome"); setState("welcome");