Repository navigation
refactor(web): decompose NewInspectionDialogComponent into smart and dumb components - #1052
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the new inspection wizard by decomposing the monolithic NewInspectionDialogComponent into a clean, modular architecture consisting of a smart component (NewInspectionDialogComponent), a layout component (NewInspectionLayoutComponent), and dedicated sub-components for each step (InspectionTypeSelectorComponent, FeatureSelectorComponent, and ParameterInputStepComponent). It also extracts core logic into a utility file with comprehensive unit tests and adds Storybook stories. The review feedback highlights several key improvement opportunities: wrapping the asynchronous client fetch in a try-catch block to handle failures and aborts gracefully, cleaning up the 'abort' event listener in the delay helper to prevent memory leaks, securing flattenDefaultValues against prototype pollution by using Object.create(null) and filtering dangerous keys, and tracking queries by id instead of name in the template's @for loop to ensure stable rendering.
…ss ParameterStore
aef8256
Background & Problem
NewInspectionDialogComponentpreviously combined all three wizard steps (inspection type selection, feature selection, and parameter input/metadata preview), backend API orchestration, reactive dryrun streams, and pure domain calculations into a single ~800-line component with a 240-line template and 286-line stylesheet. This monolithic structure violated KHI's Smart-Dumb component architecture and made it impossible to inspect or test the visual states of individual wizard steps in Storybook without mocking the backend API and dialog services.Solution Approach
This PR decomposes the New Inspection dialog into a Smart container, a Layout component, three step-specific Dumb components, and extracted pure utility functions while preserving all existing runtime behavior:
NewInspectionDialogSmartComponent): Retains service dependencies (BACKEND_API,PARAMETER_STORE,FILE_UPLOADER,MatDialogRef,MAT_DIALOG_DATA), manages wizard state via Angular Signals, and coordinates reactive dryrun streams. Its template only renders<khi-new-inspection-layout>with:host { display: contents; }.NewInspectionLayoutComponent: Manages the dialog title and<mat-stepper>layout, delegating each step's content and events viainput()andoutput().InspectionTypeSelectorComponent: Renders Step 1 (inspection target cards and loading progress indicator).FeatureSelectorComponent: Renders Step 2 (feature toggle cards, empty selection validation message, and Next button).ParameterInputStepComponent: Renders Step 3 (parameter form tree, estimated log volume callout, query cards, job command preview, task graph plan, and Run footer). Also speeds upGroupParameterComponentexpand/collapse transitions from500msto150msand adds Storybook coverage forGroupParameterComponent.types/new-inspection.types.tsand pure helper functions (computeTotalEstimatedLogs,hasFormErrors,hasDryRunErrors,flattenDefaultValues,countErrorFields,countPendingFields,countAllFields,buildParameterStepViewModel) intoutils/new-inspection.utils.tswith dedicated unit tests.Alternatives Considered
NewInspectionLayoutComponentwithout per-step Dumb components: Rejected because keeping all three steps inside a single layout template would still leave a ~240-line template and prevent isolated Storybook stories and unit tests per wizard step.Remaining Issues & Future Work
None.