Skip to content

Commit

Permalink
#9825: Add an config option to enable mapInfo highlight by default (#…
Browse files Browse the repository at this point in the history
…9829)

* #9825: Add option to enable mapInfo highlight by default
* Description:
- Adding an option called "identifyHighlight" to enable/disable mapInfo highlight by default in localConfig file
- implement intiate highlight value based on the added option and the default is false
- write unit tests based on change

* #9825: Add option to enable mapInfo highlight by default
* Description:
- fix FE test failure by editing a unit test in identifyContainer that test calling initiateOrResetHighlight on close identify

* #9825: Add option to enable mapInfo highlight by default
* Description:
- resolve review comments by using INIT_PLUGIN action instead of the new created one
- Remove the new created action ' INIT_IDENTIFY_HIGHLIGHT' and its dependent code
- Remove the added config from localConfig file
  • Loading branch information
mahmoudadel54 authored Jan 9, 2024
1 parent 8f743a4 commit c72e60f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
9 changes: 6 additions & 3 deletions web/client/components/data/identify/IdentifyContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export default props => {
formatCoord,
loaded,
validator = () => null,
toggleHighlightFeature = () => {},
disableCoordinatesRow,
disableInfoAlert
disableInfoAlert,
onInitPlugin = () => {},
pluginCfg
} = props;
const latlng = point && point.latlng || null;

Expand Down Expand Up @@ -122,7 +123,9 @@ export default props => {
draggable={draggable}
onClose={() => {
onClose();
toggleHighlightFeature(false);
onInitPlugin({
highlight: pluginCfg?.highlightEnabledFromTheStart || false
});
}}
dock={dock}
style={dockStyle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ describe("test IdentifyContainer", () => {
expect(glyphIcons.forEach(glyph => glyph.className) !== 'zoom-to').toBeTruthy();
});

it('test call toggleHighlightFeature on Close', () => {
it('test call onInitPlugin on Close', () => {
const requests = [{reqId: 1}, {reqId: 2}];
const callbacks = {
toggleHighlightFeature: () => {}
onInitPlugin: () => {}
};
const toggleHighlightFeatureSpy = expect.spyOn(callbacks, 'toggleHighlightFeature');
const onInitPluginSpy = expect.spyOn(callbacks, 'onInitPlugin');
const responses = [{layerMetadata: {title: "Layer 1"}}, {layerMetadata: {title: "Layer 2"}}];
const CMP = (<IdentifyContainer
enabled
Expand All @@ -272,7 +272,7 @@ describe("test IdentifyContainer", () => {
getFeatureButtons={getFeatureButtons}
point={{latlng: {lat: 1, lng: 1}}}
showCoordinateEditor={false}
toggleHighlightFeature={callbacks.toggleHighlightFeature}
onInitPlugin={callbacks.onInitPlugin}
/>);
ReactDOM.render(CMP, document.getElementById("container"));
const container = document.getElementById('container');
Expand All @@ -281,7 +281,7 @@ describe("test IdentifyContainer", () => {
TestUtils.act(() => {
ReactDOM.render(CMP, document.getElementById("container"));
});
expect(toggleHighlightFeatureSpy).toHaveBeenCalled();
expect(onInitPluginSpy).toHaveBeenCalled();
// Test since when the highlight feature is disabled the zoom Icon is not shown
const zoomIcon = document.querySelector('.glyphicon-zoom-to');
expect(zoomIcon).toNotExist();
Expand Down
7 changes: 4 additions & 3 deletions web/client/components/data/identify/enhancers/identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export const identifyLifecycle = compose(
onEnableCenterToMarker = () => {},
setShowInMapPopup = () => {},
checkIdentifyIsMounted = () => {},
onInitPlugin = () => {}
onInitPlugin = () => {},
pluginCfg = {}
} = this.props;

// Initialize plugin configuration
Expand All @@ -87,9 +88,9 @@ export const identifyLifecycle = compose(
configuration: {
maxItems
},
showAllResponses
showAllResponses,
highlight: pluginCfg?.highlightEnabledFromTheStart || false
});

if (enabled || showInMapPopup) {
changeMousePointer('pointer');
checkIdentifyIsMounted(true);
Expand Down
1 change: 1 addition & 0 deletions web/client/plugins/Identify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ const identifyDefaultProps = defaultProps({
* @prop cfg.dock {bool} true shows dock panel, false shows modal
* @prop cfg.draggable {boolean} draggable info window, when modal
* @prop cfg.showHighlightFeatureButton {boolean} show the highlight feature button if the interrogation returned valid features (openlayers only)
* @prop cfg.highlightEnabledFromTheStart {boolean} the highlight feature button will be activated by default if true
* @prop cfg.viewerOptions.container {expression} the container of the viewer, expression from the context
* @prop cfg.viewerOptions.header {expression} the header of the viewer, expression from the context{expression}
* @prop cfg.disableCenterToMarker {bool} disable zoom to marker action
Expand Down
10 changes: 10 additions & 0 deletions web/client/reducers/__tests__/mapInfo-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,14 @@ describe('Test the mapInfo reducer', () => {
expect(state.cfg1).toEqual("test");
expect(state.configuration).toEqual({maxItems: 3});
});
it('initiateOrResetHighlight via onInitPlugin if highlight default value equal true', () => {
const initialState = { configuration: {} };
const state = mapInfo(initialState, onInitPlugin({highlight: true}));
expect(state.highlight).toEqual(true);
});
it('initiateOrResetHighlight via onInitPlugin if highlight default value equal false', () => {
const initialState = { configuration: {} };
const state = mapInfo(initialState, onInitPlugin({highlight: false}));
expect(state.highlight).toEqual(false);
});
});

0 comments on commit c72e60f

Please sign in to comment.