Skip to content

Commit 70e11b4

Browse files
authored
Merge pull request #6 from PRGfx/bugfix/neos-91-compatibility
2 parents fa456a4 + db04218 commit 70e11b4

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

Resources/Private/JavaScript/AxeCoreView/src/manifest.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,25 @@ manifest('Prgfx.Neos.AxeCore:AxeCoreView', {}, (globalRegistry, { frontendConfig
1111
component: AxeCoreView,
1212
});
1313

14-
const previewModes = frontendConfiguration.editPreviewModes;
15-
Object.entries(previewModes).forEach(([ key, value ]) => {
16-
if (value.hidden) {
17-
delete previewModes[key];
18-
}
19-
});
14+
// omit "hidden" preview modes
15+
let previewModes = null;
16+
// Neos 9.1 deprecated the frontendConfiguration and editPreviewModes is no longer available
17+
// We don't require a neos version that has the import, so we do try the manual way
18+
const getConfiguration = window['@Neos:HostPluginAPI']?.['@NeosProjectPackages']()['NeosUiConfiguration']?.getConfiguration;
19+
if (typeof getConfiguration === 'function') {
20+
// the intended way would be using the function with a selector callback, but we want the original object to modify it
21+
const frontendConfiguration = getConfiguration();
22+
previewModes = frontendConfiguration.editPreviewModes;
23+
} else if (frontendConfiguration && 'editPreviewModes' in frontendConfiguration) {
24+
previewModes = frontendConfiguration.editPreviewModes;
25+
}
26+
if (previewModes) {
27+
Object.entries(previewModes).forEach(([ key, value ]) => {
28+
if (value.hidden) {
29+
delete previewModes[key];
30+
}
31+
});
32+
}
2033

2134
const sagasRegistry = globalRegistry.get('sagas');
2235
sagasRegistry.set('Prgfx.Neos.AxeCore/analyze', { saga: handleAnalyzerRequest });

Resources/Public/JavaScript/AxeCoreView/Plugin.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,12 +1764,21 @@
17641764
viewsRegistry.set("Prgfx.Neos.AxeCore/Inspector/Views/AxeCoreView", {
17651765
component: AxeCoreView
17661766
});
1767-
const previewModes = frontendConfiguration.editPreviewModes;
1768-
Object.entries(previewModes).forEach(([key, value]) => {
1769-
if (value.hidden) {
1770-
delete previewModes[key];
1771-
}
1772-
});
1767+
let previewModes = null;
1768+
const getConfiguration = window["@Neos:HostPluginAPI"]?.["@NeosProjectPackages"]()["NeosUiConfiguration"]?.getConfiguration;
1769+
if (typeof getConfiguration === "function") {
1770+
const frontendConfiguration2 = getConfiguration();
1771+
previewModes = frontendConfiguration2.editPreviewModes;
1772+
} else if (frontendConfiguration && "editPreviewModes" in frontendConfiguration) {
1773+
previewModes = frontendConfiguration.editPreviewModes;
1774+
}
1775+
if (previewModes) {
1776+
Object.entries(previewModes).forEach(([key, value]) => {
1777+
if (value.hidden) {
1778+
delete previewModes[key];
1779+
}
1780+
});
1781+
}
17731782
const sagasRegistry = globalRegistry.get("sagas");
17741783
sagasRegistry.set("Prgfx.Neos.AxeCore/analyze", { saga: handleAnalyzerRequest });
17751784
const reducersRegistry = globalRegistry.get("reducers");

0 commit comments

Comments
 (0)