Files
ss-tools/frontend/src/lib/models/Migration.WizardModel.svelte.ts
busya 149c05bf1c fix(frontend): full ADR compliance — Model-View concept, model decomposition, button migration
P0 — Model-first ADR compliance:
  - Decompose DashboardHubModel (590→496 lines) into Dashboards.FiltersModel,
    Dashboards.SelectionModel, Dashboards.GitActionsModel (DG split per plan)
  - Decompose AgentChatModel (630→356 lines) into ConnectionManager,
    StreamProcessor, LocalStorage, shared types
  - Decompose MigrationModel (457→389 lines) into WizardModel, ExecutorModel

P0 — /ui atom compliance:
  - Replace all raw <button> with <Button> from /ui in dashboards/+page.svelte
    (~20 replacements) and 16 additional routes/ files (~70 replacements total)

P0 — Hierarchical region IDs (ATTN_2):
  - Rename all 22 model #region/#endregion IDs from flat to Domain.Name format
  - Update @ingroup from generic 'Models' to domain-specific (Dashboards, Git, etc.)

P1 — UX contract compliance:
  - Add @UX_STATE declarations to agent/+page.svelte
  - Extract Gradio Client.connect from page into AgentChatModel.retryConnection()

All new model files have proper GRACE anchors (#region/#endregion, @ingroup,
@BRIEF, @INVARIANT, @STATE, @ACTION, @RELATION).

Build: npm run build passes.
Tests: DashboardHubModel 112/112, MigrationModel 74/74 pass.
2026-06-17 14:02:17 +03:00

43 lines
1.6 KiB
TypeScript

// frontend/src/lib/models/Migration.WizardModel.svelte.ts
// #region Migration.WizardModel [C:3] [TYPE Model] [SEMANTICS migration,wizard,step-navigation]
// @ingroup Migration
// @BRIEF Wizard step navigation sub-model — currentStep, gated goToStep(), clearError().
// @RELATION DEPENDS_ON -> [Migration.Model]
// @INVARIANT Backward navigation (step <= currentStep) is always allowed.
// @INVARIANT Step 2 requires source !== target and both envs selected (delegates to parent.stepReady).
// @INVARIANT Step 3 requires step 1 and step 2 ready.
// @INVARIANT Step 4 requires a dry-run result.
// @STATE currentStep — Active wizard step (1=environments, 2=dashboards, 3=review, 4=execute).
// @ACTION goToStep(step) — Navigates to a wizard step with readiness gating.
// @ACTION clearError() — Clears the error message on the parent model.
import type { MigrationModel } from "./MigrationModel.svelte.ts";
export class WizardState {
parent: MigrationModel;
currentStep: number = $state(1);
constructor(parent: MigrationModel) {
this.parent = parent;
}
/** Navigate to a wizard step. Gated by step readiness and dry-run result. */
goToStep(step: number): void {
const dryRunResult = this.parent.executor?.dryRunResult ?? null;
if (
step <= this.currentStep ||
(step === 2 && this.parent.stepReady[1]) ||
(step === 3 && this.parent.stepReady[1] && this.parent.stepReady[2]) ||
(step === 4 && dryRunResult)
) {
this.currentStep = step;
}
}
/** Clear error message on the parent model. */
clearError(): void {
this.parent.error = "";
}
}
// #endregion Migration.WizardModel