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 all 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
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);
});
});
Loading