diff --git a/web/client/plugins/TOC/components/StyleBasedWMSJsonLegend.jsx b/web/client/plugins/TOC/components/StyleBasedWMSJsonLegend.jsx index 2e5e62c338..0bac5e6f36 100644 --- a/web/client/plugins/TOC/components/StyleBasedWMSJsonLegend.jsx +++ b/web/client/plugins/TOC/components/StyleBasedWMSJsonLegend.jsx @@ -151,12 +151,13 @@ class StyleBasedWMSJsonLegend extends React.Component { } renderRules = (rules) => { - const interactiveLegendFilters = get(this.props, 'layer.layerFilter.filters', []).find(f => f.id === INTERACTIVE_LEGEND_ID); + const layerFilter = get(this.props, 'layer.layerFilter', {}); + const interactiveLegendFilters = get(layerFilter, 'filters', []).find(f => f.id === INTERACTIVE_LEGEND_ID); const legendFilters = get(interactiveLegendFilters, 'filters', []); - const isPreviousFilterValid = this.checkPreviousFiltersAreValid(rules, legendFilters); + const showResetWarning = !this.checkPreviousFiltersAreValid(rules, legendFilters) && !layerFilter.disabled; return ( <> - {!isPreviousFilterValid ? + {showResetWarning ?
{ filters: [{ id: 'filter1' }] - }] + }], + disabled: false } }; mockAxios.onGet(/geoserver2/).reply(() => { @@ -162,4 +163,42 @@ describe('test StyleBasedWMSJsonLegend module component', () => { const resetLegendFilter = domNode.querySelector('.wms-legend .alert-warning button'); expect(resetLegendFilter).toBeTruthy(); }); + it('tests hide warning when layer filter is disabled', async() => { + const l = { + name: 'layer00', + title: 'Layer', + visibility: true, + storeIndex: 9, + type: 'wms', + url: 'http://localhost:8080/geoserver3/wms', + layerFilter: { + filters: [{ + id: INTERACTIVE_LEGEND_ID, + filters: [{ + id: 'filter1' + }] + }], + disabled: true + } + }; + mockAxios.onGet(/geoserver3/).reply(() => { + return [200, { + "Legend": [{ + "layerName": "layer01", + "title": "Layer1", + rules + }] + }]; + }); + const comp = ReactDOM.render(, document.getElementById("container")); + await TestUtils.act(async() => comp); + + const domNode = ReactDOM.findDOMNode(comp); + expect(domNode).toBeTruthy(); + + const legendElem = document.querySelector('.wms-legend'); + expect(legendElem).toBeTruthy(); + const legendRuleElem = domNode.querySelector('.wms-legend .alert-warning'); + expect(legendRuleElem).toBeFalsy(); + }); }); diff --git a/web/client/themes/default/less/toc.less b/web/client/themes/default/less/toc.less index 191d1fd1af..74c2487c92 100644 --- a/web/client/themes/default/less/toc.less +++ b/web/client/themes/default/less/toc.less @@ -403,11 +403,6 @@ margin-right: 8px; } } - .reset-legend-filter { - display: flex; - font-size: @font-size-small; - margin-top: 2px; - } } // legend style