Compare commits
2 Commits
Fix/Fronte
...
fd00f83585
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd00f83585 | ||
|
|
935bee357c |
@@ -1,9 +0,0 @@
|
||||
-- +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;
|
||||
@@ -52,7 +52,6 @@ type SaveInstanceInput struct {
|
||||
|
||||
type SaveModeInput struct {
|
||||
Mode string
|
||||
Name string
|
||||
}
|
||||
|
||||
type SaveAdminInput struct {
|
||||
@@ -70,7 +69,6 @@ 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"`
|
||||
@@ -178,10 +176,9 @@ 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, name, mode, access, protocol, host)
|
||||
INSERT INTO installations (singleton, 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,
|
||||
@@ -193,7 +190,7 @@ func (service *Service) SaveInstance(ctx context.Context, input SaveInstanceInpu
|
||||
protocol = EXCLUDED.protocol,
|
||||
host = EXCLUDED.host,
|
||||
updated_at = NOW()
|
||||
RETURNING id::text, name, mode::text, access::text, protocol::text, host, is_bootstrapped;
|
||||
RETURNING id::text, mode::text, access::text, protocol::text, host, is_bootstrapped;
|
||||
`, input.Access, input.Protocol, input.Host)
|
||||
|
||||
return scanInstallationRecord(row)
|
||||
@@ -201,22 +198,20 @@ 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, name, mode, access, protocol, host)
|
||||
INSERT INTO installations (singleton, 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), $3)
|
||||
COALESCE((SELECT host FROM installations WHERE singleton = TRUE LIMIT 1), $2)
|
||||
)
|
||||
ON CONFLICT (singleton) DO UPDATE
|
||||
SET
|
||||
name = EXCLUDED.name,
|
||||
mode = EXCLUDED.mode,
|
||||
updated_at = NOW()
|
||||
RETURNING id::text, name, mode::text, access::text, protocol::text, host, is_bootstrapped;
|
||||
`, input.Mode, input.Name, defaultInstallationHost)
|
||||
RETURNING id::text, mode::text, access::text, protocol::text, host, is_bootstrapped;
|
||||
`, input.Mode, defaultInstallationHost)
|
||||
|
||||
return scanInstallationRecord(row)
|
||||
}
|
||||
@@ -306,7 +301,7 @@ func (service *Service) SaveStructure(ctx context.Context, input SaveStructureIn
|
||||
|
||||
organizationName := strings.TrimSpace(input.OrganizationName)
|
||||
if organizationName == "" {
|
||||
organizationName = defaultRootOrganizationName(installation.Name, installation.Mode, installation.Host, admin.DisplayName)
|
||||
organizationName = defaultRootOrganizationName(installation.Mode, installation.Host, admin.DisplayName)
|
||||
}
|
||||
|
||||
organization, err := upsertNamedRecord(ctx, tx, `
|
||||
@@ -447,7 +442,7 @@ func (service *Service) ResetDevelopmentState(ctx context.Context) error {
|
||||
|
||||
func (service *Service) GetInstallation(ctx context.Context) (*InstallationRecord, error) {
|
||||
record, err := scanInstallationRecord(service.db.Pool.QueryRow(ctx, `
|
||||
SELECT id::text, name, mode::text, access::text, protocol::text, host, is_bootstrapped
|
||||
SELECT id::text, mode::text, access::text, protocol::text, host, is_bootstrapped
|
||||
FROM installations
|
||||
WHERE singleton = TRUE
|
||||
LIMIT 1;
|
||||
@@ -602,7 +597,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.Name, &record.Mode, &record.Access, &record.Protocol, &record.Host, &record.IsBootstrapped); err != nil {
|
||||
if err := row.Scan(&record.ID, &record.Mode, &record.Access, &record.Protocol, &record.Host, &record.IsBootstrapped); err != nil {
|
||||
return InstallationRecord{}, err
|
||||
}
|
||||
|
||||
@@ -807,7 +802,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, name, mode::text, access::text, protocol::text, host, is_bootstrapped
|
||||
SELECT id::text, mode::text, access::text, protocol::text, host, is_bootstrapped
|
||||
FROM installations
|
||||
WHERE singleton = TRUE
|
||||
LIMIT 1;
|
||||
@@ -834,7 +829,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, name, mode::text, access::text, protocol::text, host, is_bootstrapped;
|
||||
RETURNING id::text, mode::text, access::text, protocol::text, host, is_bootstrapped;
|
||||
`))
|
||||
}
|
||||
|
||||
@@ -865,15 +860,10 @@ func upsertWorkspace(ctx context.Context, tx pgx.Tx, organizationID, name, slug,
|
||||
return err
|
||||
}
|
||||
|
||||
func defaultRootOrganizationName(installationName, mode, host, adminDisplayName string) string {
|
||||
trimmedInstallationName := strings.TrimSpace(installationName)
|
||||
func defaultRootOrganizationName(mode, host, adminDisplayName string) string {
|
||||
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)
|
||||
|
||||
@@ -20,7 +20,6 @@ type bootstrapInstanceStepRequest struct {
|
||||
|
||||
type bootstrapModeStepRequest struct {
|
||||
Mode string `json:"mode"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type bootstrapAdminStepRequest struct {
|
||||
@@ -235,19 +234,13 @@ 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
|
||||
}
|
||||
|
||||
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})
|
||||
record, err := routes.bootstrapService().SaveMode(r.Context(), bootstrapservice.SaveModeInput{Mode: payload.Mode})
|
||||
if err != nil {
|
||||
routes.writeBootstrapPersistenceError(w, r, err)
|
||||
return
|
||||
@@ -363,11 +356,7 @@ 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)
|
||||
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)
|
||||
WriteError(w, http.StatusInternalServerError, RequestIDFromContext(r.Context()), "bootstrap_persist_failed", "Failed to persist bootstrap data.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import {
|
||||
|
||||
type AppShellInstallation = {
|
||||
id: string;
|
||||
name: string;
|
||||
mode: "personal" | "organizational" | string;
|
||||
access: string;
|
||||
protocol: string;
|
||||
@@ -152,12 +151,11 @@ 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: serverName || organization.name,
|
||||
abbreviation: buildAbbreviation(serverName || organization.name, kind === "personal" ? "P" : "O"),
|
||||
label: organization.name,
|
||||
abbreviation: buildAbbreviation(organization.name, kind === "personal" ? "P" : "O"),
|
||||
kind,
|
||||
active: index === 0,
|
||||
}));
|
||||
@@ -172,12 +170,11 @@ 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: serverName || fallbackActiveServer.name,
|
||||
abbreviation: buildAbbreviation(serverName, kind === "personal" ? "P" : "O"),
|
||||
name: organization.name || installation.host || fallbackActiveServer.name,
|
||||
abbreviation: buildAbbreviation(organization.name || installation.host, 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,
|
||||
@@ -258,7 +255,7 @@ const buildActiveUserProfile = (payload: AppShellPayload | null): ActiveUserProf
|
||||
return fallbackActiveUserProfile;
|
||||
}
|
||||
|
||||
const organizationName = payload.installation?.name || payload.organizations[0]?.name || fallbackActiveServer.name;
|
||||
const organizationName = payload.organizations[0]?.name ?? fallbackActiveServer.name;
|
||||
const departmentName = payload.departments[0]?.name;
|
||||
|
||||
return {
|
||||
@@ -285,20 +282,10 @@ export const AppShellDataProvider = (props: { children: JSX.Element }): JSX.Elem
|
||||
},
|
||||
});
|
||||
|
||||
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;
|
||||
const body = (await response.json()) as { data?: AppShellPayload; error?: { message?: string } };
|
||||
|
||||
if (!response.ok || !body.data) {
|
||||
throw new Error(errorMessage || "Failed to load app shell state.");
|
||||
throw new Error(body.error?.message || "Failed to load app shell state.");
|
||||
}
|
||||
|
||||
setPayload(normalizeAppShellPayload(body.data));
|
||||
|
||||
@@ -92,6 +92,12 @@
|
||||
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);
|
||||
@@ -240,16 +246,10 @@
|
||||
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);
|
||||
@@ -527,45 +527,13 @@
|
||||
}
|
||||
|
||||
.wizardPanel {
|
||||
width: 100vw;
|
||||
max-height: 100dvh;
|
||||
margin: 0;
|
||||
width: calc(100vw - (var(--space-4) * 2));
|
||||
max-height: calc(100dvh - (var(--space-4) * 2));
|
||||
margin: var(--space-4) auto;
|
||||
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%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Path: Frontend/src/components/workspace-home/WorkspaceHome/WorkspaceHome.tsx
|
||||
|
||||
import { For, Show, createEffect, createMemo, createSignal, type JSX } from "solid-js";
|
||||
import { For, Show, createEffect, createMemo, createSignal, onMount, type JSX } from "solid-js";
|
||||
import { Portal } from "solid-js/web";
|
||||
import { createStore } from "solid-js/store";
|
||||
import { resolveAPIBase } from "../../../lib/api";
|
||||
@@ -44,6 +44,9 @@ const bootstrapStepDefinitions: readonly BootstrapStepDefinition[] = [
|
||||
},
|
||||
];
|
||||
|
||||
const bootstrapCompletionStorageKey = "moku.bootstrap.completed";
|
||||
const isDevelopmentEnvironment = import.meta.env.DEV;
|
||||
|
||||
const defaultInstanceForm = {
|
||||
protocol: "http",
|
||||
access: "local",
|
||||
@@ -52,11 +55,10 @@ const defaultInstanceForm = {
|
||||
|
||||
const defaultModeForm = {
|
||||
mode: "personal",
|
||||
name: "",
|
||||
} as const;
|
||||
|
||||
const defaultAdminForm = {
|
||||
displayName: "Admin",
|
||||
displayName: "First admin",
|
||||
email: "admin@example.com",
|
||||
password: "",
|
||||
} as const;
|
||||
@@ -81,6 +83,27 @@ const initialSubmissionState = (): BootstrapSubmissionState => ({
|
||||
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();
|
||||
|
||||
@@ -95,52 +118,6 @@ 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;
|
||||
@@ -163,6 +140,13 @@ 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);
|
||||
setIsBootstrapStateResolved(true);
|
||||
});
|
||||
|
||||
createEffect(() => {
|
||||
if (modeForm.mode === "personal") {
|
||||
setStructureForm("departmentName", personalStructureDefaults.departmentName);
|
||||
@@ -180,27 +164,29 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
});
|
||||
|
||||
createEffect(() => {
|
||||
const shellStatus = appShellData.status();
|
||||
|
||||
if (shellStatus === "idle" || shellStatus === "loading") {
|
||||
if (!isBootstrapStateResolved()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (shellStatus !== "success") {
|
||||
if (appShellData.status() !== "success") {
|
||||
return;
|
||||
}
|
||||
|
||||
const installationAccessor = appShellData.installation;
|
||||
const installation = typeof installationAccessor === "function" ? installationAccessor() : undefined;
|
||||
const installation = appShellData.installation();
|
||||
const isPersistedBootstrap = installation?.isBootstrapped ?? false;
|
||||
|
||||
if (!isPersistedBootstrap) {
|
||||
resetWizardState();
|
||||
if (isPersistedBootstrap) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsBootstrapComplete(isPersistedBootstrap);
|
||||
setIsWizardOpen(!isPersistedBootstrap);
|
||||
setIsBootstrapStateResolved(true);
|
||||
if (!isBootstrapComplete() && isWizardOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeBootstrapCompletion(false);
|
||||
setIsBootstrapComplete(false);
|
||||
setIsWizardOpen(true);
|
||||
resetWizardState();
|
||||
});
|
||||
|
||||
const sidebarToggleLabel = (): string =>
|
||||
@@ -209,8 +195,6 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
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]!,
|
||||
);
|
||||
@@ -248,7 +232,11 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
const data = await readResponseBody(response);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(readResponseError(step, data));
|
||||
throw new Error(
|
||||
typeof data?.error?.message === "string"
|
||||
? data.error.message
|
||||
: `Bootstrap ${step} request failed.`,
|
||||
);
|
||||
}
|
||||
|
||||
setStepState(step, {
|
||||
@@ -290,13 +278,9 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
|
||||
if (isLastStep()) {
|
||||
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);
|
||||
writeBootstrapCompletion(true);
|
||||
setIsBootstrapComplete(true);
|
||||
setIsWizardOpen(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -308,6 +292,32 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
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 => {
|
||||
switch (state.status) {
|
||||
case "submitting":
|
||||
@@ -360,6 +370,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}>{isBootstrapComplete() ? appShellData.activeServer().name : bootstrapTargetLabel()}</h1>
|
||||
<Show when={isBootstrapStateResolved() && !isBootstrapComplete()}>
|
||||
<div class={styles.heroActions}>
|
||||
@@ -368,6 +379,20 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
</button>
|
||||
</div>
|
||||
</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>
|
||||
</main>
|
||||
|
||||
@@ -458,7 +483,6 @@ 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)}>
|
||||
@@ -466,17 +490,6 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
<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"}>
|
||||
@@ -487,7 +500,7 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
type="text"
|
||||
value={adminForm.displayName}
|
||||
onInput={(event): void => setAdminForm("displayName", event.currentTarget.value)}
|
||||
placeholder="Admin"
|
||||
placeholder="First admin"
|
||||
/>
|
||||
</label>
|
||||
<label class={styles.field}>
|
||||
@@ -505,11 +518,8 @@ export const WorkspaceHome = (props: WorkspaceHomeProps): JSX.Element => {
|
||||
type="password"
|
||||
value={adminForm.password}
|
||||
onInput={(event): void => setAdminForm("password", event.currentTarget.value)}
|
||||
placeholder="Create a strong password"
|
||||
placeholder="Temporary for echo testing"
|
||||
/>
|
||||
<small class={styles.fieldHelp}>
|
||||
Use at least 12 characters with uppercase, lowercase, numbers, and symbols.
|
||||
</small>
|
||||
</label>
|
||||
</>
|
||||
</Show>
|
||||
|
||||
Reference in New Issue
Block a user