Compare commits

...

3 Commits

Author SHA1 Message Date
MangoPig
699574e345 Fix: Polish bootstrap flow 2026-06-19 22:47:12 +01:00
MangoPig
35c1a861f5 Merge branch 'Features/Backend/Bootstrap-Reset' 2026-06-19 19:57:46 +01:00
MangoPig
27101bbdd6 Feat: Add development bootstrap reset 2026-06-19 19:57:44 +01:00
7 changed files with 372 additions and 112 deletions

View File

@@ -0,0 +1,9 @@
-- +goose Up
ALTER TABLE installations
ADD COLUMN IF NOT EXISTS name TEXT NOT NULL DEFAULT '';
-- +goose Down
ALTER TABLE installations
DROP COLUMN IF EXISTS name;

View File

@@ -52,6 +52,7 @@ type SaveInstanceInput struct {
type SaveModeInput struct {
Mode string
Name string
}
type SaveAdminInput struct {
@@ -69,6 +70,7 @@ type SaveStructureInput struct {
type InstallationRecord struct {
ID string `json:"id"`
Name string `json:"name"`
Mode string `json:"mode"`
Access string `json:"access"`
Protocol string `json:"protocol"`
@@ -176,9 +178,10 @@ func NewService(db *database.DB) *Service {
func (service *Service) SaveInstance(ctx context.Context, input SaveInstanceInput) (InstallationRecord, error) {
row := service.db.Pool.QueryRow(ctx, `
INSERT INTO installations (singleton, mode, access, protocol, host)
INSERT INTO installations (singleton, name, mode, access, protocol, host)
VALUES (
TRUE,
COALESCE((SELECT name FROM installations WHERE singleton = TRUE LIMIT 1), ''),
COALESCE((SELECT mode FROM installations WHERE singleton = TRUE LIMIT 1), 'personal'::instance_mode),
$1::instance_access,
$2::instance_protocol,
@@ -190,7 +193,7 @@ func (service *Service) SaveInstance(ctx context.Context, input SaveInstanceInpu
protocol = EXCLUDED.protocol,
host = EXCLUDED.host,
updated_at = NOW()
RETURNING id::text, mode::text, access::text, protocol::text, host, is_bootstrapped;
RETURNING id::text, name, mode::text, access::text, protocol::text, host, is_bootstrapped;
`, input.Access, input.Protocol, input.Host)
return scanInstallationRecord(row)
@@ -198,20 +201,22 @@ func (service *Service) SaveInstance(ctx context.Context, input SaveInstanceInpu
func (service *Service) SaveMode(ctx context.Context, input SaveModeInput) (InstallationRecord, error) {
row := service.db.Pool.QueryRow(ctx, `
INSERT INTO installations (singleton, mode, access, protocol, host)
INSERT INTO installations (singleton, name, mode, access, protocol, host)
VALUES (
TRUE,
$2,
$1::instance_mode,
COALESCE((SELECT access FROM installations WHERE singleton = TRUE LIMIT 1), 'local'::instance_access),
COALESCE((SELECT protocol FROM installations WHERE singleton = TRUE LIMIT 1), 'http'::instance_protocol),
COALESCE((SELECT host FROM installations WHERE singleton = TRUE LIMIT 1), $2)
COALESCE((SELECT host FROM installations WHERE singleton = TRUE LIMIT 1), $3)
)
ON CONFLICT (singleton) DO UPDATE
SET
name = EXCLUDED.name,
mode = EXCLUDED.mode,
updated_at = NOW()
RETURNING id::text, mode::text, access::text, protocol::text, host, is_bootstrapped;
`, input.Mode, defaultInstallationHost)
RETURNING id::text, name, mode::text, access::text, protocol::text, host, is_bootstrapped;
`, input.Mode, input.Name, defaultInstallationHost)
return scanInstallationRecord(row)
}
@@ -301,7 +306,7 @@ func (service *Service) SaveStructure(ctx context.Context, input SaveStructureIn
organizationName := strings.TrimSpace(input.OrganizationName)
if organizationName == "" {
organizationName = defaultRootOrganizationName(installation.Mode, installation.Host, admin.DisplayName)
organizationName = defaultRootOrganizationName(installation.Name, installation.Mode, installation.Host, admin.DisplayName)
}
organization, err := upsertNamedRecord(ctx, tx, `
@@ -410,9 +415,39 @@ func (service *Service) SaveStructure(ctx context.Context, input SaveStructureIn
}, nil
}
func (service *Service) ResetDevelopmentState(ctx context.Context) error {
tx, err := service.db.Pool.BeginTx(ctx, pgx.TxOptions{})
if err != nil {
return err
}
defer func() {
_ = tx.Rollback(ctx)
}()
if _, err := tx.Exec(ctx, `
TRUNCATE TABLE
project_memberships,
team_memberships,
organization_memberships,
workspaces,
projects,
teams,
departments,
user_homes,
users,
organizations,
installations
RESTART IDENTITY;
`); err != nil {
return err
}
return tx.Commit(ctx)
}
func (service *Service) GetInstallation(ctx context.Context) (*InstallationRecord, error) {
record, err := scanInstallationRecord(service.db.Pool.QueryRow(ctx, `
SELECT id::text, mode::text, access::text, protocol::text, host, is_bootstrapped
SELECT id::text, name, mode::text, access::text, protocol::text, host, is_bootstrapped
FROM installations
WHERE singleton = TRUE
LIMIT 1;
@@ -567,7 +602,7 @@ func (service *Service) GetAppShellState(ctx context.Context) (AppShellState, er
func scanInstallationRecord(row pgx.Row) (InstallationRecord, error) {
var record InstallationRecord
if err := row.Scan(&record.ID, &record.Mode, &record.Access, &record.Protocol, &record.Host, &record.IsBootstrapped); err != nil {
if err := row.Scan(&record.ID, &record.Name, &record.Mode, &record.Access, &record.Protocol, &record.Host, &record.IsBootstrapped); err != nil {
return InstallationRecord{}, err
}
@@ -772,7 +807,7 @@ func (service *Service) listWorkspaces(ctx context.Context) ([]WorkspaceRecord,
func loadInstallation(ctx context.Context, tx pgx.Tx) (InstallationRecord, error) {
return scanInstallationRecord(tx.QueryRow(ctx, `
SELECT id::text, mode::text, access::text, protocol::text, host, is_bootstrapped
SELECT id::text, name, mode::text, access::text, protocol::text, host, is_bootstrapped
FROM installations
WHERE singleton = TRUE
LIMIT 1;
@@ -799,7 +834,7 @@ func updateBootstrappedInstallation(ctx context.Context, tx pgx.Tx) (Installatio
UPDATE installations
SET is_bootstrapped = TRUE, bootstrapped_at = COALESCE(bootstrapped_at, NOW()), updated_at = NOW()
WHERE singleton = TRUE
RETURNING id::text, mode::text, access::text, protocol::text, host, is_bootstrapped;
RETURNING id::text, name, mode::text, access::text, protocol::text, host, is_bootstrapped;
`))
}
@@ -830,10 +865,15 @@ func upsertWorkspace(ctx context.Context, tx pgx.Tx, organizationID, name, slug,
return err
}
func defaultRootOrganizationName(mode, host, adminDisplayName string) string {
func defaultRootOrganizationName(installationName, mode, host, adminDisplayName string) string {
trimmedInstallationName := strings.TrimSpace(installationName)
trimmedHost := strings.TrimSpace(host)
trimmedAdminDisplayName := strings.TrimSpace(adminDisplayName)
if trimmedInstallationName != "" {
return trimmedInstallationName
}
if strings.EqualFold(mode, defaultInstallationMode) {
if trimmedAdminDisplayName != "" {
return fmt.Sprintf("%s %s", trimmedAdminDisplayName, defaultPersonalServerSuffix)

View File

@@ -20,6 +20,7 @@ type bootstrapInstanceStepRequest struct {
type bootstrapModeStepRequest struct {
Mode string `json:"mode"`
Name string `json:"name"`
}
type bootstrapAdminStepRequest struct {
@@ -166,6 +167,28 @@ func (routes apiRoutes) handleAppShellState(w http.ResponseWriter, r *http.Reque
})
}
func (routes apiRoutes) handleDevelopmentBootstrapReset(w http.ResponseWriter, r *http.Request) {
if !routes.cfg.Config.IsDevelopment() {
WriteError(w, http.StatusNotFound, RequestIDFromContext(r.Context()), "not_found", "The requested endpoint does not exist.")
return
}
if err := routes.bootstrapService().ResetDevelopmentState(r.Context()); err != nil {
routes.writeBootstrapPersistenceError(w, r, err)
return
}
WriteJSON(w, http.StatusOK, map[string]any{
"data": map[string]any{
"reset": true,
},
"meta": map[string]any{
"resource": "development-bootstrap-reset",
"developmentOnly": true,
},
})
}
func (routes apiRoutes) handleBootstrapInstanceStep(w http.ResponseWriter, r *http.Request) {
payload, ok := decodeBootstrapRequest[bootstrapInstanceStepRequest](w, r)
if !ok {
@@ -212,13 +235,19 @@ func (routes apiRoutes) handleBootstrapModeStep(w http.ResponseWriter, r *http.R
return
}
payload.Mode = strings.ToLower(strings.TrimSpace(payload.Mode))
payload.Name = strings.TrimSpace(payload.Name)
if payload.Mode != "personal" && payload.Mode != "organizational" {
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Mode must be either 'personal' or 'organizational'.")
return
}
record, err := routes.bootstrapService().SaveMode(r.Context(), bootstrapservice.SaveModeInput{Mode: payload.Mode})
if payload.Name == "" {
WriteError(w, http.StatusBadRequest, RequestIDFromContext(r.Context()), "invalid_request", "Name is required.")
return
}
record, err := routes.bootstrapService().SaveMode(r.Context(), bootstrapservice.SaveModeInput{Mode: payload.Mode, Name: payload.Name})
if err != nil {
routes.writeBootstrapPersistenceError(w, r, err)
return
@@ -334,7 +363,11 @@ func (routes apiRoutes) writeBootstrapPersistenceError(w http.ResponseWriter, r
WriteError(w, http.StatusConflict, RequestIDFromContext(r.Context()), "bootstrap_prerequisite_missing", err.Error())
default:
routes.cfg.Logger.Error("persist bootstrap step", "error", err, "path", r.URL.Path)
WriteError(w, http.StatusInternalServerError, RequestIDFromContext(r.Context()), "bootstrap_persist_failed", "Failed to persist bootstrap data.")
message := "Failed to persist bootstrap data."
if routes.cfg.Config.IsDevelopment() {
message = message + " " + err.Error()
}
WriteError(w, http.StatusInternalServerError, RequestIDFromContext(r.Context()), "bootstrap_persist_failed", message)
}
}

View File

@@ -33,6 +33,10 @@ func (routes apiRoutes) Register(router chi.Router) {
apiRouter.Get("/app-shell", routes.handleAppShellState)
apiRouter.Get("/organizations", routes.handleOrganizations)
apiRouter.Get("/workspaces", routes.handleWorkspaces)
if routes.cfg.Config.IsDevelopment() {
apiRouter.Post("/dev/bootstrap/reset", routes.handleDevelopmentBootstrapReset)
}
})
}

View File

@@ -34,6 +34,7 @@ import {
type AppShellInstallation = {
id: string;
name: string;
mode: "personal" | "organizational" | string;
access: string;
protocol: string;
@@ -100,9 +101,20 @@ type AppShellPayload = {
workspaces: AppShellWorkspace[];
};
const normalizeAppShellPayload = (payload: AppShellPayload | null | undefined): AppShellPayload => ({
installation: payload?.installation,
admin: payload?.admin,
organizations: Array.isArray(payload?.organizations) ? payload.organizations : [],
departments: Array.isArray(payload?.departments) ? payload.departments : [],
teams: Array.isArray(payload?.teams) ? payload.teams : [],
projects: Array.isArray(payload?.projects) ? payload.projects : [],
workspaces: Array.isArray(payload?.workspaces) ? payload.workspaces : [],
});
type AppShellContextValue = {
status: Accessor<"idle" | "loading" | "success" | "error">;
error: Accessor<string>;
installation: Accessor<AppShellInstallation | undefined>;
railItems: Accessor<readonly RailItem[]>;
activeServer: Accessor<ActiveServer>;
activeProject: Accessor<ActiveProject>;
@@ -140,11 +152,12 @@ const buildRailItems = (payload: AppShellPayload | null): readonly RailItem[] =>
}
const kind = payload.installation.mode === "personal" ? "personal" : "organization";
const serverName = payload.installation.name || payload.organizations[0]?.name || payload.installation.host;
return payload.organizations.map((organization, index) => ({
id: organization.id,
label: organization.name,
abbreviation: buildAbbreviation(organization.name, kind === "personal" ? "P" : "O"),
label: serverName || organization.name,
abbreviation: buildAbbreviation(serverName || organization.name, kind === "personal" ? "P" : "O"),
kind,
active: index === 0,
}));
@@ -159,11 +172,12 @@ const buildActiveServer = (payload: AppShellPayload | null): ActiveServer => {
}
const kind = installation.mode === "personal" ? "personal" : "organization";
const serverName = installation.name || organization.name || installation.host;
return {
id: installation.id,
name: organization.name || installation.host || fallbackActiveServer.name,
abbreviation: buildAbbreviation(organization.name || installation.host, kind === "personal" ? "P" : "O"),
name: serverName || fallbackActiveServer.name,
abbreviation: buildAbbreviation(serverName, kind === "personal" ? "P" : "O"),
kind,
connectedLabel: kind === "organization" ? `${payload?.teams.length ?? 0} connected` : undefined,
subtitle: kind === "personal" ? installation.host || payload?.admin?.homeTitle || "Personal home" : undefined,
@@ -244,7 +258,7 @@ const buildActiveUserProfile = (payload: AppShellPayload | null): ActiveUserProf
return fallbackActiveUserProfile;
}
const organizationName = payload.organizations[0]?.name ?? fallbackActiveServer.name;
const organizationName = payload.installation?.name || payload.organizations[0]?.name || fallbackActiveServer.name;
const departmentName = payload.departments[0]?.name;
return {
@@ -271,13 +285,23 @@ export const AppShellDataProvider = (props: { children: JSX.Element }): JSX.Elem
},
});
const body = (await response.json()) as { data?: AppShellPayload; error?: { message?: string } };
const body = (await response.json()) as {
data?: AppShellPayload;
error?: { message?: string } | string;
message?: string;
};
const errorMessage =
typeof body.message === "string"
? body.message
: typeof body.error === "string"
? body.error
: body.error?.message;
if (!response.ok || !body.data) {
throw new Error(body.error?.message || "Failed to load app shell state.");
throw new Error(errorMessage || "Failed to load app shell state.");
}
setPayload(body.data);
setPayload(normalizeAppShellPayload(body.data));
setStatus("success");
} catch (loadError) {
setStatus("error");
@@ -292,6 +316,7 @@ export const AppShellDataProvider = (props: { children: JSX.Element }): JSX.Elem
const value: AppShellContextValue = {
status,
error,
installation: createMemo(() => payload()?.installation),
railItems: createMemo(() => buildRailItems(payload())),
activeServer: createMemo(() => buildActiveServer(payload())),
activeProject: createMemo(() => buildActiveProject(payload())),

View File

@@ -92,12 +92,6 @@
flex-wrap: wrap;
}
.eyebrow {
@include text-caption;
color: var(--color-text-muted);
text-transform: uppercase;
}
.title {
@include text-display;
font-family: var(--font-family-display);
@@ -246,10 +240,16 @@
color: var(--color-text-muted);
}
.fieldHelp {
@include text-caption;
color: var(--color-text-muted);
}
.field input,
.field select {
min-height: var(--control-size-md);
width: 100%;
font: inherit;
border: 1px solid var(--color-border);
border-radius: var(--radius-lg);
background: var(--color-surface-elevated);
@@ -261,6 +261,14 @@
background 160ms var(--easing-standard);
}
.field input:disabled,
.field select:disabled {
cursor: not-allowed;
color: var(--color-text-muted);
background: color-mix(in srgb, var(--color-surface-secondary) 92%, transparent);
border-color: color-mix(in srgb, var(--color-border) 72%, transparent);
}
.field input:focus-visible,
.field select:focus-visible {
outline: none;
@@ -519,13 +527,45 @@
}
.wizardPanel {
width: calc(100vw - (var(--space-4) * 2));
max-height: calc(100dvh - (var(--space-4) * 2));
margin: var(--space-4) auto;
width: 100vw;
max-height: 100dvh;
margin: 0;
padding: var(--space-3);
padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
border-radius: 0;
}
.wizardHeader,
.wizardBody,
.wizardSidebar {
gap: var(--space-3);
}
.wizardSteps {
grid-auto-flow: column;
grid-auto-columns: minmax(10rem, 1fr);
overflow-x: auto;
padding-bottom: var(--space-1);
scrollbar-width: thin;
}
.wizardStepButton {
min-width: 10rem;
}
.wizardFormActions {
gap: var(--space-2);
flex-direction: column-reverse;
align-items: stretch;
}
.wizardFormActions .primaryButton {
margin-left: 0;
}
.wizardFormActions .primaryButton,
.wizardFormActions .secondaryButton,
.wizardCloseButton {
width: 100%;
}
}

View File

@@ -1,6 +1,6 @@
// Path: Frontend/src/components/workspace-home/WorkspaceHome/WorkspaceHome.tsx
import { For, Show, createMemo, createSignal, onMount, type JSX } from "solid-js";
import { For, Show, createEffect, createMemo, createSignal, type JSX } from "solid-js";
import { Portal } from "solid-js/web";
import { createStore } from "solid-js/store";
import { resolveAPIBase } from "../../../lib/api";
@@ -44,34 +44,43 @@ const bootstrapStepDefinitions: readonly BootstrapStepDefinition[] = [
},
];
const bootstrapCompletionStorageKey = "moku.bootstrap.completed";
const defaultInstanceForm = {
protocol: "http",
access: "local",
host: "localhost",
} as const;
const defaultModeForm = {
mode: "personal",
name: "",
} as const;
const defaultAdminForm = {
displayName: "Admin",
email: "admin@example.com",
password: "",
} as const;
const personalStructureDefaults = {
departmentName: "Default",
teamName: "Personal",
} as const;
const organizationalStructureDefaults = {
departmentName: "Department",
teamName: "Team",
} as const;
const defaultStructureForm = {
...personalStructureDefaults,
projectName: "Project",
} as const;
const initialSubmissionState = (): BootstrapSubmissionState => ({
status: "idle",
error: "",
});
const readBootstrapCompletion = (): boolean => {
if (typeof window === "undefined") {
return false;
}
return window.localStorage.getItem(bootstrapCompletionStorageKey) === "true";
};
const writeBootstrapCompletion = (isComplete: boolean): void => {
if (typeof window === "undefined") {
return;
}
if (isComplete) {
window.localStorage.setItem(bootstrapCompletionStorageKey, "true");
return;
}
window.localStorage.removeItem(bootstrapCompletionStorageKey);
};
const readResponseBody = async (response: Response): Promise<unknown> => {
const raw = await response.text();
@@ -86,6 +95,52 @@ const readResponseBody = async (response: Response): Promise<unknown> => {
}
};
const readResponseError = (step: BootstrapStepKey, data: unknown): string => {
const fallback = `Bootstrap ${step} request failed.`;
if (typeof data === "string") {
const message = data.trim();
return message || fallback;
}
if (!data || typeof data !== "object") {
return fallback;
}
const record = data as {
error?: string;
message?: string;
requestId?: string;
};
const message = typeof record.message === "string" ? record.message.trim() : "";
const errorCode = typeof record.error === "string" ? record.error.trim() : "";
const requestId = typeof record.requestId === "string" ? record.requestId.trim() : "";
if (!message && !errorCode && !requestId) {
return fallback;
}
const details: string[] = [];
if (errorCode) {
details.push(`code: ${errorCode}`);
}
if (requestId) {
details.push(`request: ${requestId}`);
}
if (message && details.length > 0) {
return `${message} (${details.join(", ")})`;
}
if (message) {
return message;
}
return `${fallback} (${details.join(", ")})`;
};
type WorkspaceHomeProps = {
sidebarCollapsed: boolean;
onToggleSidebarCollapse: () => void;
@@ -93,24 +148,10 @@ type WorkspaceHomeProps = {
export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
const appShellData = useAppShellData();
const [instanceForm, setInstanceForm] = createStore({
protocol: "http",
access: "local",
host: "localhost",
});
const [modeForm, setModeForm] = createStore({
mode: "personal",
});
const [adminForm, setAdminForm] = createStore({
displayName: "Ronald",
email: "admin@example.com",
password: "",
});
const [structureForm, setStructureForm] = createStore({
departmentName: "Platform",
teamName: "Core",
projectName: "Moku",
});
const [instanceForm, setInstanceForm] = createStore({ ...defaultInstanceForm });
const [modeForm, setModeForm] = createStore({ ...defaultModeForm });
const [adminForm, setAdminForm] = createStore({ ...defaultAdminForm });
const [structureForm, setStructureForm] = createStore({ ...defaultStructureForm });
const [stepState, setStepState] = createStore<Record<BootstrapStepKey, BootstrapSubmissionState>>({
instance: initialSubmissionState(),
mode: initialSubmissionState(),
@@ -122,10 +163,43 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
const [isWizardOpen, setIsWizardOpen] = createSignal(false);
const [currentStepIndex, setCurrentStepIndex] = createSignal(0);
onMount(() => {
const isComplete = readBootstrapCompletion();
setIsBootstrapComplete(isComplete);
setIsWizardOpen(!isComplete);
createEffect(() => {
if (modeForm.mode === "personal") {
setStructureForm("departmentName", personalStructureDefaults.departmentName);
setStructureForm("teamName", personalStructureDefaults.teamName);
return;
}
if (structureForm.departmentName === personalStructureDefaults.departmentName) {
setStructureForm("departmentName", organizationalStructureDefaults.departmentName);
}
if (structureForm.teamName === personalStructureDefaults.teamName) {
setStructureForm("teamName", organizationalStructureDefaults.teamName);
}
});
createEffect(() => {
const shellStatus = appShellData.status();
if (shellStatus === "idle" || shellStatus === "loading") {
return;
}
if (shellStatus !== "success") {
return;
}
const installationAccessor = appShellData.installation;
const installation = typeof installationAccessor === "function" ? installationAccessor() : undefined;
const isPersistedBootstrap = installation?.isBootstrapped ?? false;
if (!isPersistedBootstrap) {
resetWizardState();
}
setIsBootstrapComplete(isPersistedBootstrap);
setIsWizardOpen(!isPersistedBootstrap);
setIsBootstrapStateResolved(true);
});
@@ -133,6 +207,10 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
props.sidebarCollapsed ? "Expand left workspace sidebar" : "Collapse left workspace sidebar";
const breadcrumb = (): string => `${appShellData.activeServer().name} / ${appShellData.activeProject().name} / Home`;
const apiBase = (): string => resolveAPIBase();
const bootstrapTargetLabel = (): string =>
modeForm.mode === "personal" ? "Personal server" : "Organization server";
const bootstrapNamePlaceholder = (): string =>
modeForm.mode === "personal" ? "Personal server name" : "Organization server name";
const currentStep = createMemo<BootstrapStepDefinition>(
() => bootstrapStepDefinitions[currentStepIndex()] ?? bootstrapStepDefinitions[0]!,
);
@@ -141,6 +219,20 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
const isLastStep = (): boolean => currentStepIndex() === bootstrapStepDefinitions.length - 1;
const canDismissWizard = (): boolean => isBootstrapComplete();
const resetWizardState = (): void => {
setInstanceForm({ ...defaultInstanceForm });
setModeForm({ ...defaultModeForm });
setAdminForm({ ...defaultAdminForm });
setStructureForm({ ...defaultStructureForm });
setStepState({
instance: initialSubmissionState(),
mode: initialSubmissionState(),
admin: initialSubmissionState(),
structure: initialSubmissionState(),
});
setCurrentStepIndex(0);
};
const submitStep = async (step: BootstrapStepKey, payload: unknown): Promise<boolean> => {
setStepState(step, { status: "submitting", error: "" });
@@ -156,11 +248,7 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
const data = await readResponseBody(response);
if (!response.ok) {
throw new Error(
typeof data?.error?.message === "string"
? data.error.message
: `Bootstrap ${step} request failed.`,
);
throw new Error(readResponseError(step, data));
}
setStepState(step, {
@@ -201,9 +289,14 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
}
if (isLastStep()) {
writeBootstrapCompletion(true);
setIsBootstrapComplete(true);
setIsWizardOpen(false);
await appShellData.reload();
const installationAccessor = appShellData.installation;
const installation = typeof installationAccessor === "function" ? installationAccessor() : undefined;
const isPersistedBootstrap = installation?.isBootstrapped ?? false;
setIsBootstrapComplete(isPersistedBootstrap);
setIsWizardOpen(!isPersistedBootstrap);
setIsBootstrapStateResolved(true);
return;
}
@@ -267,8 +360,7 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
</div>
<section class={styles.hero} data-slot="workspace-home-hero">
<span class={styles.eyebrow}>Bootstrap</span>
<h1 class={styles.title}>{appShellData.activeServer().name}</h1>
<h1 class={styles.title}>{isBootstrapComplete() ? appShellData.activeServer().name : bootstrapTargetLabel()}</h1>
<Show when={isBootstrapStateResolved() && !isBootstrapComplete()}>
<div class={styles.heroActions}>
<button type="button" class={styles.primaryButton} onClick={(): void => setIsWizardOpen(true)}>
@@ -288,7 +380,7 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
<header class={styles.wizardHeader} data-slot="bootstrap-wizard-header">
<div class={styles.wizardHeaderCopy}>
<h2 id="bootstrap-wizard-title" class={styles.wizardTitle}>
Bootstrap {appShellData.activeServer().name}
Bootstrap {bootstrapTargetLabel()}
</h2>
</div>
<Show when={canDismissWizard()}>
@@ -365,27 +457,39 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
</>
</Show>
<Show when={currentStep().id === "mode"}>
<label class={styles.field}>
<span class={styles.fieldLabel}>Mode</span>
<select value={modeForm.mode} onInput={(event): void => setModeForm("mode", event.currentTarget.value)}>
<option value="personal">personal</option>
<option value="organizational">organizational</option>
</select>
</label>
</Show>
<Show when={currentStep().id === "mode"}>
<>
<label class={styles.field}>
<span class={styles.fieldLabel}>Mode</span>
<select value={modeForm.mode} onInput={(event): void => setModeForm("mode", event.currentTarget.value)}>
<option value="personal">personal</option>
<option value="organizational">organizational</option>
</select>
</label>
<label class={styles.field}>
<span class={styles.fieldLabel}>Server name</span>
<input
type="text"
value={modeForm.name}
required
onInput={(event): void => setModeForm("name", event.currentTarget.value)}
placeholder={bootstrapNamePlaceholder()}
/>
</label>
</>
</Show>
<Show when={currentStep().id === "admin"}>
<>
<label class={styles.field}>
<span class={styles.fieldLabel}>Display name</span>
<input
type="text"
value={adminForm.displayName}
onInput={(event): void => setAdminForm("displayName", event.currentTarget.value)}
placeholder="First admin"
/>
</label>
<input
type="text"
value={adminForm.displayName}
onInput={(event): void => setAdminForm("displayName", event.currentTarget.value)}
placeholder="Admin"
/>
</label>
<label class={styles.field}>
<span class={styles.fieldLabel}>Email</span>
<input
@@ -397,13 +501,16 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
</label>
<label class={styles.field}>
<span class={styles.fieldLabel}>Password</span>
<input
type="password"
value={adminForm.password}
onInput={(event): void => setAdminForm("password", event.currentTarget.value)}
placeholder="Temporary for echo testing"
/>
</label>
<input
type="password"
value={adminForm.password}
onInput={(event): void => setAdminForm("password", event.currentTarget.value)}
placeholder="Create a strong password"
/>
<small class={styles.fieldHelp}>
Use at least 12 characters with uppercase, lowercase, numbers, and symbols.
</small>
</label>
</>
</Show>
@@ -414,8 +521,9 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
<input
type="text"
value={structureForm.departmentName}
disabled={modeForm.mode === "personal"}
onInput={(event): void => setStructureForm("departmentName", event.currentTarget.value)}
placeholder="Platform"
placeholder={organizationalStructureDefaults.departmentName}
/>
</label>
<label class={styles.field}>
@@ -423,8 +531,9 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
<input
type="text"
value={structureForm.teamName}
disabled={modeForm.mode === "personal"}
onInput={(event): void => setStructureForm("teamName", event.currentTarget.value)}
placeholder="Core"
placeholder={organizationalStructureDefaults.teamName}
/>
</label>
<label class={styles.field}>