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

globalRegistry.get('frontendConfiguration') doesnt work in plugin/manifest bootstrap #3098

Open
mhsdesign opened this issue Apr 8, 2022 · 2 comments
Labels
7.3 8.3 Bug Label to mark the change as bugfix Extensibility Technical debt

Comments

@mhsdesign
Copy link
Member

mhsdesign commented Apr 8, 2022

Description

when one registers a new plugin in the manifest and tries to call globalRegistry.get('frontendConfiguration') null is returned.

Steps to Reproduce

  1. Write a manifest like:
import manifest from '@neos-project/neos-ui-extensibility';
manifest('Fooo', {}, (globalRegistry) => {
    console.log(globalRegistry.get('frontendConfiguration'))
}

Expected behavior

to get the actual FrontendConfigurationSynchronousRegistry

Actual behavior

we log null

What actually happened

the FrontendConfigurationSynchronousRegistry is not initialized, when the bootstraps are called.

the manifests are booted here in line 76

.forEach(({bootstrap}) => bootstrap(globalRegistry, {store, frontendConfiguration, configuration, routes}));

but only in line 121

const frontendConfigurationRegistry = globalRegistry.get('frontendConfiguration');
Object.keys(frontendConfiguration).forEach(key => {
frontendConfigurationRegistry.set(key, {
...frontendConfiguration[key]
});
});

the raw yaml / php-array frontendConfiguration array is transferred to a SynchronousRegistry

... Sure we can get hold of the frontendConfiguration in another way:

  1. Write a manifest like:
manifest('Fooo', {}, (globalRegistry, { frontendConfiguration }) => {
    console.log(frontendConfiguration)
}

now it works, but note that this is the raw yaml / php-array and not a SynchronousRegistry so frontendConfiguration.get('My.Package')
doesnt work (one needs to use normal array access like frontendConfiguration['My.Package']) - but it does other places (when you actually have the FrontendConfigurationSynchronousRegistry)

Outcome

is there a reason, why the FrontendConfigurationSynchronousRegistry is not initialized before boot and passed?
im now used to this but i find this behavior odd - and would like to have at all places a FrontendConfigurationSynchronousRegistry available.

Affected Versions

UI: Since ever

@mhsdesign mhsdesign changed the title globalRegistry.get('frontendConfiguration') doesnt work in plugin bootstrap globalRegistry.get('frontendConfiguration') doesnt work in plugin/manifest bootstrap Apr 8, 2022
@mhsdesign
Copy link
Member Author

mhsdesign commented Nov 4, 2022

Same applies for i18n - the translations are not available at first. setTranslations will only be called, after the manifests are bootet.

A workaround is to register a saga which waits until the system initializes (when the frontent config and translations are loaded.)

import manifest from "@neos-project/neos-ui-extensibility";
import { take } from 'redux-saga/effects';
import { actionTypes } from '@neos-project/neos-ui-redux-store';

manifest("Mhs.Bar", {}, (globalRegistry) => {
    const i18n = globalRegistry.get("i18n")

    function* onSystemInit() {
        yield take(actionTypes.System.INIT)
        console.log(i18n.translate('Mhs.Bar:Main:nix'));
    }

    const sagasRegistry = globalRegistry.get('sagas');
    sagasRegistry.set('CodeQ.NeosUiTranslateRteStyleSelect/init', { saga: onSystemInit });
});

@mhsdesign
Copy link
Member Author

mhsdesign commented Nov 5, 2022

im wondering if the above described behavior for the config is intentional, as one could technically even mutate the second param of the bootstrap callback { frontendConfiguration } before its added to the global registry ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7.3 8.3 Bug Label to mark the change as bugfix Extensibility Technical debt
Projects
None yet
Development

No branches or pull requests

2 participants