Compare commits

..

2 Commits

Author SHA1 Message Date
MangoPig
fd00f83585 Merge branch 'Features/Backend/Bootstrap-Reset' 2026-06-19 19:26:37 +01:00
MangoPig
935bee357c Feat: Add development bootstrap reset 2026-06-19 19:26:14 +01:00

View File

@@ -45,6 +45,7 @@ const bootstrapStepDefinitions: readonly BootstrapStepDefinition[] = [
]; ];
const bootstrapCompletionStorageKey = "moku.bootstrap.completed"; const bootstrapCompletionStorageKey = "moku.bootstrap.completed";
const isDevelopmentEnvironment = import.meta.env.DEV;
const defaultInstanceForm = { const defaultInstanceForm = {
protocol: "http", protocol: "http",
@@ -57,7 +58,7 @@ const defaultModeForm = {
} as const; } as const;
const defaultAdminForm = { const defaultAdminForm = {
displayName: "Admin", displayName: "First admin",
email: "admin@example.com", email: "admin@example.com",
password: "", password: "",
} as const; } as const;
@@ -291,6 +292,32 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
void submitCurrentStep(); void submitCurrentStep();
}; };
const handleDevelopmentReset = async (): Promise<void> => {
const response = await fetch(`${apiBase()}/dev/bootstrap/reset`, {
method: "POST",
headers: {
Accept: "application/json",
},
});
const data = await readResponseBody(response);
if (!response.ok) {
throw new Error(
typeof data?.message === "string"
? data.message
: typeof data?.error?.message === "string"
? data.error.message
: "Failed to reset development bootstrap state.",
);
}
writeBootstrapCompletion(false);
setIsBootstrapComplete(false);
setIsWizardOpen(true);
resetWizardState();
await appShellData.reload();
};
const statusLabel = (state: BootstrapSubmissionState): string => { const statusLabel = (state: BootstrapSubmissionState): string => {
switch (state.status) { switch (state.status) {
case "submitting": case "submitting":
@@ -352,6 +379,20 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
</button> </button>
</div> </div>
</Show> </Show>
<Show when={isDevelopmentEnvironment && isBootstrapStateResolved()}>
<div class={styles.heroActions}>
<button
type="button"
class={styles.secondaryButton}
data-slot="development-bootstrap-reset"
onClick={() => {
void handleDevelopmentReset();
}}
>
Reset development bootstrap state
</button>
</div>
</Show>
</section> </section>
</main> </main>
@@ -459,7 +500,7 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
type="text" type="text"
value={adminForm.displayName} value={adminForm.displayName}
onInput={(event): void => setAdminForm("displayName", event.currentTarget.value)} onInput={(event): void => setAdminForm("displayName", event.currentTarget.value)}
placeholder="Admin" placeholder="First admin"
/> />
</label> </label>
<label class={styles.field}> <label class={styles.field}>