Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLSP-1349 Improve container configuration #355

Merged
merged 2 commits into from
Jun 9, 2024
Merged

GLSP-1349 Improve container configuration #355

merged 2 commits into from
Jun 9, 2024

Conversation

tortmayr
Copy link
Contributor

@tortmayr tortmayr commented Jun 6, 2024

What it does

  • Add replace property to ModulConfiguration interface. When resolving feature modules of the replace property, any potential already configured module with the same id will be replaced with the defined module. If there is nothing to replace, the module will be added to the end of the resolved configuration
  • Add check for non-unique feature module ids to resolveContainerConfiguration function.
  • Add option to enable additional debug logging when loading feature modules. This is usefull during development to get insights about why the container modules are not loaded as expected
  • Add dedicated featureIds to all default modules. If no featureId is provided the number id of the module is reused for creating the featureId. While this works perfectly fine, it makes debugging harder because feature modules are hard to indentify based on their featureid. With this change its now easier to derive the corresponding feature module from the featureid.

Fixes eclipse-glsp/glsp#1349

How to test

  • Unit tests for the resolveContainerConfiguration function are inplace and they are also testing the replace behavior
  • To test debugLogging of feature modules you can adapt the di.config file of the workflow-standalone example:
export default function createContainer(options: IDiagramOptions): Container {
    ...
    FeatureModule.DEBUG_LOG_ENABLED=true
    const container = createWorkflowDiagramContainer(
        createDiagramOptionsModule(options),
        {
            add: accessibilityModule,
            remove: toolPaletteModule
        },
        STANDALONE_MODULE_CONFIG
    );
    FeatureModule.DEBUG_LOG_ENABLED=false;
    ...
    }

Follow-ups

Changelog

  • This PR should be mentioned in the changelog
  • This PR introduces a breaking change (if yes, provide more details below for the changelog and the migration guide)

- Add `replace` property to `ModulConfiguration` interface. When resolving feature modules of the replace property, any potential already configured module with the same id will be replaced with the defined module. If there is nothing to replace, the module will be added to the end of the resolved configuration
- Add check for non-unique feature module ids to `resolveContainerConfiguration` function.
- Add option to enable additional debug logging when loading feature modules. This is usefull during development to get insights about why the container modules are not loaded as expected
- Add dedicated `featureIds` to all default modules. If no featureId is provided the number id of the module is reused for creating the featureId. While this works perfectly fine, it makes debugging harder because feature modules are hard to indentify based on their featureid.
With this change its now easier to derive the corresponding feature module from the featureid.

Fixes eclipse-glsp/glsp#1349
Copy link
Contributor

@martin-fleck-at martin-fleck-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good to me and I really like the semantics that replace brings with it. Just two minor comments inline.

@@ -46,5 +46,5 @@ export const standaloneExportModule = new FeatureModule(
bind(ExportSvgActionHandler).toSelf().inSingletonScope();
configureActionHandler(context, ExportSvgAction.KIND, ExportSvgActionHandler);
},
{ requires: exportModule }
{ featureId: Symbol('standaloneExport'), requires: exportModule }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exportModule a few lines up could also profit from an actual Symbol because currently it just gets a number assigned.

if (existingIndex >= 0) {
modules[existingIndex] = replace;
} else {
distinctAdd(modules, replace);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you defined this as the intended behavior in the function comments but I feel that the replace behavior should still log a warning if it does not actually replace another module but defaults to the adding behavior. What do you think?

Copy link
Contributor

@martin-fleck-at martin-fleck-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tortmayr tortmayr merged commit 9f5e1eb into master Jun 9, 2024
6 checks passed
@tortmayr tortmayr deleted the glsp-1349 branch June 9, 2024 22:17
tortmayr added a commit that referenced this pull request Jun 18, 2024
- Update `onSelect` method of autocomplete Widget to dispatch a `input` event instead of a `keyup` event. (Since autocompleter 8.x the suggestion update uses `input` instead of `keyup`
- Enable task editor in standalone example by adding an explicit standaloneTaskEditorModule.
Fixes eclipse-glsp/glsp#1347

In addition:
- Update dependencies and align with sprotty
- Use fixed version of vscode-jsonrpc to avoid conflicts with Theia
- Restore original container configuration order in `workflow-diagram-module`
  (was changed on accident in #355)
@tortmayr tortmayr mentioned this pull request Jun 18, 2024
2 tasks
tortmayr added a commit that referenced this pull request Jun 18, 2024
- Update `onSelect` method of autocomplete Widget to dispatch a `input` event instead of a `keyup` event. (Since autocompleter 8.x the suggestion update uses `input` instead of `keyup`
- Enable task editor in standalone example by adding an explicit standaloneTaskEditorModule.
Fixes eclipse-glsp/glsp#1347

In addition:
- Update dependencies and align with sprotty
- Use fixed version of vscode-jsonrpc to avoid conflicts with Theia
- Restore original container configuration order in `workflow-diagram-module`
  (was changed on accident in #355)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve working with featureModules, container configurations
2 participants