UI: add update service
This commit is contained in:
@@ -21,21 +21,32 @@ export const Service = (props: RouteSectionProps) => {
|
||||
ctx.setWorldMode("service");
|
||||
});
|
||||
|
||||
const handleClose = () => {
|
||||
console.log("Service closed, navigating back");
|
||||
navigate(buildClanPath(ctx.clanURI), { replace: true });
|
||||
ctx.setWorldMode("select");
|
||||
};
|
||||
|
||||
const handleSubmit: SubmitServiceHandler = async (instance, action) => {
|
||||
console.log("Service submitted", instance, action);
|
||||
|
||||
if (action !== "create") {
|
||||
console.warn("Updating service instances is not supported yet");
|
||||
return;
|
||||
}
|
||||
|
||||
const call = client.fetch("create_service_instance", {
|
||||
let call;
|
||||
if (action === "update") {
|
||||
call = client.fetch("set_service_instance", {
|
||||
flake: {
|
||||
identifier: ctx.clanURI,
|
||||
},
|
||||
instance_ref: instance.name,
|
||||
roles: instance.roles,
|
||||
});
|
||||
} else {
|
||||
call = client.fetch("create_service_instance", {
|
||||
flake: {
|
||||
identifier: ctx.clanURI,
|
||||
},
|
||||
module_ref: instance.module,
|
||||
roles: instance.roles,
|
||||
});
|
||||
}
|
||||
|
||||
const result = await call.result;
|
||||
|
||||
if (result.status === "error") {
|
||||
@@ -46,13 +57,7 @@ export const Service = (props: RouteSectionProps) => {
|
||||
queryKey: clanKey(ctx.clanURI),
|
||||
});
|
||||
|
||||
ctx.setWorldMode("select");
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
console.log("Service closed, navigating back");
|
||||
navigate(buildClanPath(ctx.clanURI), { replace: true });
|
||||
ctx.setWorldMode("select");
|
||||
handleClose();
|
||||
};
|
||||
|
||||
return <ServiceWorkflow handleSubmit={handleSubmit} onClose={handleClose} />;
|
||||
|
||||
@@ -129,7 +129,8 @@ const ConfigureService = () => {
|
||||
// Wait for all queries to be ready
|
||||
if (!instances || !machines) return;
|
||||
const instance = instances[routerProps.id || routerProps.name];
|
||||
|
||||
// Init once
|
||||
if (!store.roles) {
|
||||
set("roles", {});
|
||||
if (!instance) {
|
||||
set("action", "create");
|
||||
@@ -142,6 +143,7 @@ const ConfigureService = () => {
|
||||
set("roles", role, roleMembers);
|
||||
}
|
||||
set("action", "update");
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -360,7 +362,10 @@ const ConfigureRole = () => {
|
||||
if (!store.roles) {
|
||||
set("roles", {});
|
||||
}
|
||||
set("roles", (r) => ({ ...r, [store.currentRole as string]: members() }));
|
||||
set("roles", (r) => ({
|
||||
...r,
|
||||
[store.currentRole as string]: members(),
|
||||
}));
|
||||
stepper.setActiveStep("view:members");
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user