diff --git a/web/client/components/widgets/builder/wizard/map/enhancers/__tests__/nodeEditor-test.jsx b/web/client/components/widgets/builder/wizard/map/enhancers/__tests__/nodeEditor-test.jsx index 04a154c8b2..8ebfda951a 100644 --- a/web/client/components/widgets/builder/wizard/map/enhancers/__tests__/nodeEditor-test.jsx +++ b/web/client/components/widgets/builder/wizard/map/enhancers/__tests__/nodeEditor-test.jsx @@ -70,5 +70,25 @@ describe('nodeEditor enhancer', () => { map={{ groups: [{ id: 'GROUP' }], layers: [{ id: "LAYER", group: "GROUP", options: {} }] }} />, document.getElementById("container")); expect(spyonChange).toHaveBeenCalledWith("map.layers[0].something", "newValue"); }); + it('should return only the visible tabs based on node type', () => { + const defaultMap = { groups: [{ id: 'GROUP' }], layers: [{ id: "LAYER:WMS", type: 'wms', group: "GROUP", options: {} }, { id: "LAYER", group: "GROUP", options: {} }] }; + + const TestComponent = nodeEditor(({ tabs }) => { + return (); + }); + + ReactDOM.render(, document.getElementById("container")); + + expect([...document.querySelectorAll('li')].map(node => node.innerHTML)).toEqual(['general']); + + ReactDOM.render(, document.getElementById("container")); + + expect([...document.querySelectorAll('li')].map(node => node.innerHTML)).toEqual(['general', 'display']); + + ReactDOM.render(, document.getElementById("container")); + + expect([...document.querySelectorAll('li')].map(node => node.innerHTML)).toEqual(['general', 'display', 'style']); + + }); }); diff --git a/web/client/components/widgets/builder/wizard/map/enhancers/nodeEditor.js b/web/client/components/widgets/builder/wizard/map/enhancers/nodeEditor.js index 9e4b44ac31..29e682fa63 100644 --- a/web/client/components/widgets/builder/wizard/map/enhancers/nodeEditor.js +++ b/web/client/components/widgets/builder/wizard/map/enhancers/nodeEditor.js @@ -24,7 +24,7 @@ import withSelectedNode from './withSelectedNode'; const WMSStyle = withCapabilitiesRetrieval(WMSStyleComp); const withDefaultTabs = withProps((props) => ({ - tabs: props.tabs || [{ + tabs: (props.tabs || [{ id: 'general', titleId: 'layerProperties.general', tooltipId: 'layerProperties.general', @@ -47,7 +47,7 @@ const withDefaultTabs = withProps((props) => ({ glyph: 'dropper', visible: props.settings && props.settings.nodeType === 'layers' && props.element && props.element.type === "wms", Component: WMSStyle - }] + }]).filter(({ visible }) => !!visible) })); /**