Mne 412 refactor template builder in mnestix browser#544
Mne 412 refactor template builder in mnestix browser#544LuisSchweinberger merged 13 commits intodevfrom
Conversation
…ncies added resultions for vulnerable prisma dependencies
Increased version to 2.1.2
…f github.com:eclipse-mnestix/mnestix-browser into MNE-412-refactor-template-builder-in-mnestix-browser
There was a problem hiding this comment.
Pull request overview
This PR refactors the template/blueprint editor to centralize state management in a new React Context provider, simplifies the tree/field editing flow, and bumps dependencies + application version.
Changes:
- Introduces
BlueprintContextas the single source of truth for blueprint tree state, selection, change tracking, duplicate/delete operations, and Submodel conversion. - Refactors the
/templates/[id]page and blueprint edit components (tree + fields) to consume the context and removes the prior “soft delete/restore” UI flow. - Updates dependencies/lockfile and bumps the app + Docker image version to
2.1.2.
Reviewed changes
Copilot reviewed 19 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Dependency lockfile updates (eslint/jest/mui/prisma/etc.). |
| src/lib/util/submodelHelpers/SubmodelViewObjectUtil.ts | Removes isAboutToBeDeleted usage and makes rewriteNodeIds synchronous. |
| src/lib/types/SubmodelViewObject.ts | Removes isAboutToBeDeleted from the view object type. |
| src/app/[locale]/templates/[id]/page.tsx | Wraps the page in BlueprintProvider and migrates fetch/save/revert logic to context. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/SubmodelEditComponent.tsx | Adjusts event typing and switches to onBlur commit behavior. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/property/data-specific/StringPropertyEditComponent.tsx | Switches to onBlur commit behavior. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/property/data-specific/LongPropertyEditComponent.tsx | Switches handler signature and (intended) onBlur commit behavior. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/mapping-info/MappingInfoEditComponent.tsx | Consolidates mapping-info editing into a generic component driven by config props. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/mapping-info/filter-mapping-info.json | Adds filter mapping qualifier config. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/mapping-info/collection-mapping-info-data.json | Adds collection mapping qualifier config. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/index/index-data.json | Removes index qualifier config file. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/filter-mapping-info/FilterMappingInfoEditComponent.tsx | Removes dedicated filter mapping editor (replaced by generic component). |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/collection-mapping-info/CollectionMappingInfoEditComponent.tsx | Removes dedicated collection mapping editor (replaced by generic component). |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditTreeItemMenu.tsx | Removes restore/soft-delete menu logic. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditTreeItem.tsx | Removes deleted-state rendering/restore behavior and simplifies delete handling. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditTree.tsx | Refactors tree to read/write through BlueprintContext and removes local tree mutation logic. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditFields.tsx | Refactors fields panel to use context selection and generic mapping editors. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintContext.tsx | Adds new context provider implementing blueprint editing operations and API↔tree conversion helpers. |
| package.json | Bumps version to 2.1.2, updates prisma version, adds resolutions, and modifies dev script. |
| eslint.config.js | Changes Cypress plugin import path. |
| compose.yml | Updates Docker image tag to 2.1.2. |
| .github/workflows/docker-build.yml | Updates workflow image tag version to 2.1.2. |
You can also share your feedback on Copilot code review. Take the survey.
...mponents/blueprint-edit/edit-components/property/data-specific/LongPropertyEditComponent.tsx
Show resolved
Hide resolved
src/app/[locale]/templates/_components/blueprint-edit/BlueprintContext.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR refactors the template editor page to centralize blueprint tree state, selection, and update operations into a new BlueprintContext/BlueprintProvider, reducing prop drilling and local state in the editor UI.
Changes:
- Introduces
BlueprintContextto manage blueprint tree state, selection, duplication/deletion, and conversion back toSubmodelfor saving. - Refactors template editor page and blueprint edit components (
BlueprintEditTree,BlueprintEditFields, menus/items) to consume context instead of passing/maintaining local state. - Updates tooling/scripts and configs (version bumps, dev script, ESLint Cypress plugin import) and adjusts Cypress E2E coverage.
Reviewed changes
Copilot reviewed 20 out of 23 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/util/submodelHelpers/SubmodelViewObjectUtil.ts | Removes soft-delete flag usage and makes rewriteNodeIds synchronous. |
| src/lib/types/SubmodelViewObject.ts | Removes isAboutToBeDeleted from the view object type. |
| src/app/[locale]/templates/[id]/page.tsx | Wraps the page in BlueprintProvider and replaces local blueprint state/logic with context methods. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/SubmodelEditComponent.tsx | Updates display name input handler types and switches to onBlur. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/property/data-specific/StringPropertyEditComponent.tsx | Broadens event typing to include HTMLTextAreaElement. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/property/data-specific/LongPropertyEditComponent.tsx | Broadens event typing to include HTMLTextAreaElement and adds React import. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/mapping-info/MappingInfoEditComponent.tsx | Generalizes mapping-info editing into a single configurable component. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/mapping-info/filter-mapping-info.json | Adds filter mapping-info qualifier configuration. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/mapping-info/collection-mapping-info-data.json | Adds collection mapping-info qualifier configuration. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/index/index-data.json | Removes legacy index config JSON. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/filter-mapping-info/FilterMappingInfoEditComponent.tsx | Removes specialized filter mapping-info component (replaced by generic one). |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/collection-mapping-info/CollectionMappingInfoEditComponent.tsx | Removes specialized collection mapping-info component (replaced by generic one). |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditTreeItemMenu.tsx | Simplifies tree item menu actions; removes restore-related wiring. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditTreeItem.tsx | Removes soft-delete UI state and restore handling from tree items. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditTree.tsx | Refactors tree rendering to use context state/actions instead of prop callbacks. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditFields.tsx | Refactors edit fields to use context-selected element and generic mapping-info editor. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintContext.tsx | Adds the new centralized blueprint state provider, actions, and (de)serialization helpers. |
| package.json | Bumps version/deps, changes dev script to always enable Node inspector, adds resolutions. |
| eslint.config.js | Changes Cypress ESLint plugin import path. |
| cypress/e2e/templateTest.spec.js | Adjusts login flow and reduces CRUD test to create+delete only. |
| compose.yml | Bumps Docker image tag to 2.1.2. |
| .github/workflows/docker-build.yml | Bumps image tag version to 2.1.2. |
src/app/[locale]/templates/_components/blueprint-edit/BlueprintContext.tsx
Show resolved
Hide resolved
src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditTreeItemMenu.tsx
Show resolved
Hide resolved
...onents/blueprint-edit/edit-components/property/data-specific/StringPropertyEditComponent.tsx
Show resolved
Hide resolved
src/app/[locale]/templates/_components/blueprint-edit/edit-components/SubmodelEditComponent.tsx
Show resolved
Hide resolved
…Blur to minimize rerenders
There was a problem hiding this comment.
Pull request overview
This PR refactors the template editing page to centralize blueprint/template editing state and operations into a new BlueprintContext provider, simplifying the page/component wiring and improving maintainability. It also updates related edit components, E2E tests, and bumps the app version/deps/tooling config to support the refactor.
Changes:
- Introduce
BlueprintProvider/useBlueprintContextas the single source of truth for blueprint tree state, selection, duplicate/delete, and save conversion. - Simplify template editor page, tree, and edit-field components to consume context (and consolidate MappingInfo editing into a generic component + JSON configs).
- Update Cypress template CRUD flow for improved reliability; bump version to
2.1.2and adjust tooling config (ESLint/Cypress plugin import, resolutions, docker tags).
Reviewed changes
Copilot reviewed 20 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/util/submodelHelpers/SubmodelViewObjectUtil.ts | Removes deletion flag from view objects; makes rewriteNodeIds synchronous. |
| src/lib/types/SubmodelViewObject.ts | Removes isAboutToBeDeleted from the view-object type. |
| src/app/[locale]/templates/[id]/page.tsx | Wraps editor in BlueprintProvider and shifts most editing state/logic into context. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintContext.tsx | New context provider implementing blueprint state, selection, duplicate/delete, and Submodel conversion. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditTree.tsx | Converts tree component to be context-driven (no longer receives tree/handlers via props). |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditFields.tsx | Converts edit fields to be context-driven; replaces specialized mapping components with a generic one. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/mapping-info/MappingInfoEditComponent.tsx | Refactors into a generic, configurable mapping-info editor. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/mapping-info/*.json | Adds mapping-info configs (collection/filter) to drive the generic component. |
| src/app/[locale]/templates/_components/blueprint-edit/edit-components/*PropertyEditComponent.tsx | Switches several field updates to commit on blur. |
| src/app/[locale]/templates/_components/blueprint-edit/BlueprintEditTreeItem*.tsx | Removes “marked for deletion/restore” UI paths to align with hard delete behavior. |
| cypress/e2e/templateTest.spec.js | Makes template CRUD test more robust (unique name + login helper + no logout). |
| package.json | Bumps version to 2.1.2, updates prisma, adds dev:inspect, adds resolutions. |
| eslint.config.js | Updates Cypress ESLint plugin import. |
| compose.yml | Updates image tag to 2.1.2. |
| .github/workflows/docker-build.yml | Updates workflow image tag version to 2.1.2. |
Comments suppressed due to low confidence (1)
src/app/[locale]/templates/_components/blueprint-edit/edit-components/property/data-specific/LongPropertyEditComponent.tsx:37
- LongPropertyEditComponent is a controlled TextField (value={data}), but the state update is now wired to onBlur. This prevents the user from typing because the input’s value will not update on keystrokes. Keep the controlled input’s state updates on onChange (you can still debounce/commit to parent onBlur if desired).
return (
<TextField
label={t('labels.value')}
value={data}
onBlur={onValueChange}
fullWidth
error={!isValidInput}
helperText={!isValidInput && t('validation.errors.invalidLong')}
/>
This pull request introduces a new version (2.1.2) of the application with a significant refactor of the template editing page to improve maintainability and state management. The template editing logic is now encapsulated in a context provider, resulting in cleaner, more modular code. Additionally, there are updates to dependencies, workflow files, and end-to-end tests to support these changes and improve reliability.
Refactor: Template Editing Page State Management
src/app/[locale]/templates/[id]/page.tsxto move blueprint/template editing logic into a newBlueprintContextprovider. This removes large blocks of local state and helper functions, centralizing state and logic for editing, saving, and managing templates. The component is now wrapped inBlueprintProvider, and interactions are handled via context hooks, simplifying the main component and improving maintainability. (src/app/[locale]/templates/[id]/page.tsxL3-L9, src/app/[locale]/templates/[id]/page.tsxL20-L69, src/app/[locale]/templates/[id]/page.tsxR74-R100, src/app/[locale]/templates/[id]/page.tsxL135-L143, src/app/[locale]/templates/[id]/page.tsxL153-L176, src/app/[locale]/templates/[id]/page.tsxL191-L327, src/app/[locale]/templates/[id]/page.tsxL346-L358, src/app/[locale]/templates/[id]/page.tsxL446-R290)Testing Improvements
cypress/e2e/templateTest.spec.js) is improved to use a unique template name for each run, adds aloginIfNeededhelper for more robust authentication, and avoids logging out after each test to prevent misleading timeouts. The test flow is updated for better reliability and clarity.Dependency and Tooling Updates
package.json, Docker, and Compose files. [1] [2] [3]prismadependency to^7.4.2and add several package resolutions for security and compatibility (lodash,hono,@hono/node-server). [1] [2]dev:inspectscript for running the dev server with Node.js inspector enabled.These changes collectively improve the project's code quality, maintainability, and reliability, especially around template editing and developer experience.