Skip to content

Commit

Permalink
#10281: Use Cache Options functionality extended to be applied on all…
Browse files Browse the repository at this point in the history
… the layers from a service (#10361)

* #10281: Use Cache Options functionality extended to be applied on all the layers from a service
Description:
- handle a missing case of showing a warning message in case of not able to fetch the grid sets
- add unit tests
  • Loading branch information
mahmoudadel54 authored May 27, 2024
1 parent 86e2eb7 commit 292da73
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ function WMSCacheOptions({
}) {

const [tileGridLoading, setTileGridLoading] = useState(false);
const [tileGridsResponseMsgId, setTileGridsResponseMsgId] = useState('');
const [tileGridsResponseMsgId, setTileGridsResponseMsgId] = useState(() => {
const noTileGrids = layer?.tileGridStrategy === 'custom' && layer?.tiled && layer?.tileGrids?.length === 0;
return noTileGrids ? "layerProperties.noConfiguredGridSets" : "";
});
const [tileGridsResponseMsgStyle, setTileGridsResponseMsgStyle] = useState('');
const [standardTileGridInfo, setStandardTileGridInfo] = useState({});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1045,5 +1045,30 @@ describe('WMSCacheOptions', () => {
.catch(done);

});
it('should display noConfiguredGridSets warning message if layer is configured from catalog to `Use Cache Options`, with no grid sets available', () => {
ReactDOM.render(<WMSCacheOptions layer={{
url: '/geoserver/wms',
name: 'topp:states',
tileGridStrategy: 'custom',
format: 'image/jpeg',
tileGridCacheSupport: {
formats: ['image/png']
},
tiled: true,
tileGrids: []
}} projection="EPSG:3857" />, document.getElementById('container'));
expect(document.querySelector('.ms-wms-cache-options')).toBeTruthy();
const inputs = document.querySelectorAll('input[type="checkbox"]');
expect(inputs.length).toBe(1);
const buttons = document.querySelectorAll('button');
expect(buttons.length).toBe(2);
expect([...buttons].map(button => button.querySelector('.glyphicon').getAttribute('class'))).toEqual([
'glyphicon glyphicon-refresh',
'glyphicon glyphicon-grid-custom'
]);

const alert = document.querySelector('.alert');
expect(alert.innerText).toBe('layerProperties.noConfiguredGridSets');
});
});

1 change: 1 addition & 0 deletions web/client/epics/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export default (API) => ({
if (tileGridData) {
const filteredTileGrids = tileGridData.tileGrids.filter(({ crs }) => isProjectionAvailable(CoordinatesUtils.normalizeSRS(crs)));
tileGridProperties = tileGridData !== undefined ? {
tiled: true,
tileGrids: tileGridData.tileGrids,
tileGridStrategy: 'custom',
tileGridCacheSupport: filteredTileGrids?.length > 0 ?
Expand Down

0 comments on commit 292da73

Please sign in to comment.