Skip to content

Commit

Permalink
Update filter show warning case
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 committed Dec 18, 2024
1 parent e0cbee5 commit b487aa9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
7 changes: 4 additions & 3 deletions web/client/plugins/TOC/components/StyleBasedWMSJsonLegend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? <Alert bsStyle="warning">
{showResetWarning ? <Alert bsStyle="warning">
<div><Message msgId={"layerProperties.interactiveLegend.incompatibleFilterWarning"} /></div>
<ButtonWithTooltip
bsStyle="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ describe('test StyleBasedWMSJsonLegend module component', () => {
filters: [{
id: 'filter1'
}]
}]
}],
disabled: false
}
};
mockAxios.onGet(/geoserver2/).reply(() => {
Expand All @@ -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(<StyleBasedWMSJsonLegend legendHeight={50} legendWidth={50} layer={l} />, 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();
});
});
5 changes: 0 additions & 5 deletions web/client/themes/default/less/toc.less
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,6 @@
margin-right: 8px;
}
}
.reset-legend-filter {
display: flex;
font-size: @font-size-small;
margin-top: 2px;
}
}

// legend style
Expand Down

0 comments on commit b487aa9

Please sign in to comment.