Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#9825: Add an config option to enable mapInfo highlight by default #9829

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion web/client/actions/__tests__/mapInfo-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ import {
checkIdentifyIsMounted,
IDENTIFY_IS_MOUNTED,
onInitPlugin,
INIT_PLUGIN
INIT_PLUGIN,
INIT_IDENTIFY_HIGHLIGHT,
initiateOrResetHighlight
} from '../mapInfo';

describe('Test correctness of the map actions', () => {
Expand Down Expand Up @@ -166,4 +168,10 @@ describe('Test correctness of the map actions', () => {
it('onInitPlugin', () => {
expect(onInitPlugin({cfg1: false})).toEqual({type: INIT_PLUGIN, cfg: {cfg1: false} });
});
it('initiateOrResetHighlight if highlight default value equal true', () => {
expect(initiateOrResetHighlight(true)).toEqual({type: INIT_IDENTIFY_HIGHLIGHT, identifyHighlight: true });
});
it('initiateOrResetHighlight if highlight default value equal false', () => {
expect(initiateOrResetHighlight(false)).toEqual({type: INIT_IDENTIFY_HIGHLIGHT, identifyHighlight: false });
});
});
7 changes: 7 additions & 0 deletions web/client/actions/mapInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const TOGGLE_EMPTY_MESSAGE_GFI = "IDENTIFY:TOGGLE_EMPTY_MESSAGE_GFI";
export const SET_SHOW_IN_MAP_POPUP = "IDENTIFY:SET_SHOW_IN_MAP_POPUP";
export const IDENTIFY_IS_MOUNTED = "IDENTIFY:IDENTIFY_IS_MOUNTED";
export const INIT_PLUGIN = 'IDENTIFY:INIT_PLUGIN';
export const INIT_IDENTIFY_HIGHLIGHT = 'IDENTIFY:INIT_IDENTIFY_HIGHLIGHT';

export const toggleEmptyMessageGFI = () => ({type: TOGGLE_EMPTY_MESSAGE_GFI});

Expand Down Expand Up @@ -288,3 +289,9 @@ export const checkIdentifyIsMounted = (isMounted)=> ({
});

export const onInitPlugin = (cfg) => ({type: INIT_PLUGIN, cfg});
/**
* Action performed when the identify component opened to initiate the default value of highight
* @param {boolean} highlight
* @returns {{type: string, identifyHighlight: boolean}}
*/
export const initiateOrResetHighlight = (highlight) => ({type: INIT_IDENTIFY_HIGHLIGHT, identifyHighlight: highlight});
7 changes: 4 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,
initiateOrResetHighlight,
pluginCfg
} = props;
const latlng = point && point.latlng || null;

Expand Down Expand Up @@ -122,7 +123,7 @@ export default props => {
draggable={draggable}
onClose={() => {
onClose();
toggleHighlightFeature(false);
initiateOrResetHighlight(pluginCfg?.identifyHighlight || 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 initiateOrResetHighlight on Close', () => {
const requests = [{reqId: 1}, {reqId: 2}];
const callbacks = {
toggleHighlightFeature: () => {}
initiateOrResetHighlight: () => {}
};
const toggleHighlightFeatureSpy = expect.spyOn(callbacks, 'toggleHighlightFeature');
const initiateOrResetHighlightSpy = expect.spyOn(callbacks, 'initiateOrResetHighlight');
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}
initiateOrResetHighlight={callbacks.initiateOrResetHighlight}
/>);
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(initiateOrResetHighlightSpy).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
5 changes: 3 additions & 2 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 = () => {},
initiateOrResetHighlight = () => {}
} = this.props;

// Initialize plugin configuration
Expand All @@ -89,7 +90,7 @@ export const identifyLifecycle = compose(
},
showAllResponses
});

initiateOrResetHighlight(this.props?.pluginCfg?.identifyHighlight || false);
if (enabled || showInMapPopup) {
changeMousePointer('pointer');
checkIdentifyIsMounted(true);
Expand Down
1 change: 1 addition & 0 deletions web/client/configs/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@
"name": "Identify",
"cfg": {
"showHighlightFeatureButton": true,
"identifyHighlight":false,
mahmoudadel54 marked this conversation as resolved.
Show resolved Hide resolved
"viewerOptions": {
"container": "{context.ReactSwipe}"
},
Expand Down
5 changes: 4 additions & 1 deletion web/client/plugins/Identify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import {
updateCenterToMarker,
updateFeatureInfoClickPoint,
checkIdentifyIsMounted,
onInitPlugin
onInitPlugin,
initiateOrResetHighlight
} from '../actions/mapInfo';
import DefaultViewerComp from '../components/data/identify/DefaultViewer';
import { defaultViewerDefaultProps, defaultViewerHandlers } from '../components/data/identify/enhancers/defaultViewer';
Expand Down Expand Up @@ -196,6 +197,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.identifyHighlight {boolean} the highlight feature button will be activated by default if true
mahmoudadel54 marked this conversation as resolved.
Show resolved Hide resolved
* @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 Expand Up @@ -225,6 +227,7 @@ const identifyDefaultProps = defaultProps({
const IdentifyPlugin = compose(
connect(selector, {
onInitPlugin,
initiateOrResetHighlight,
mahmoudadel54 marked this conversation as resolved.
Show resolved Hide resolved
purgeResults: purgeMapInfoResults,
closeIdentify,
onSubmitClickPoint: updateFeatureInfoClickPoint,
Expand Down
13 changes: 12 additions & 1 deletion web/client/reducers/__tests__/mapInfo-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
toggleHighlightFeature,
setMapTrigger,
setShowInMapPopup,
onInitPlugin
onInitPlugin,
initiateOrResetHighlight
} from '../../actions/mapInfo';
import {changeVisualizationMode} from '../../actions/maptype';
import { MAP_CONFIG_LOADED } from '../../actions/config';
Expand Down Expand Up @@ -449,4 +450,14 @@ describe('Test the mapInfo reducer', () => {
expect(state.cfg1).toEqual("test");
expect(state.configuration).toEqual({maxItems: 3});
});
it('initiateOrResetHighlight if highlight default value equal true', () => {
const initialState = { configuration: {} };
const state = mapInfo(initialState, initiateOrResetHighlight(true));
expect(state.highlight).toEqual(true);
});
it('initiateOrResetHighlight if highlight default value equal false', () => {
const initialState = { configuration: {} };
const state = mapInfo(initialState, initiateOrResetHighlight(false));
expect(state.highlight).toEqual(false);
});
});
9 changes: 8 additions & 1 deletion web/client/reducers/mapInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import {
SET_CURRENT_EDIT_FEATURE_QUERY,
SET_MAP_TRIGGER,
SET_SHOW_IN_MAP_POPUP,
INIT_PLUGIN
INIT_PLUGIN,
INIT_IDENTIFY_HIGHLIGHT
} from '../actions/mapInfo';
import { VISUALIZATION_MODE_CHANGED } from '../actions/maptype';

Expand Down Expand Up @@ -410,6 +411,12 @@ function mapInfo(state = initState, action) {
}
};
}
case INIT_IDENTIFY_HIGHLIGHT: {
return {
...state,
highlight: action.identifyHighlight
};
}
default:
return state;
}
Expand Down
Loading