diff --git a/web/client/components/data/identify/IdentifyContainer.jsx b/web/client/components/data/identify/IdentifyContainer.jsx index 93ade34308..6bd5f18bfa 100644 --- a/web/client/components/data/identify/IdentifyContainer.jsx +++ b/web/client/components/data/identify/IdentifyContainer.jsx @@ -71,9 +71,10 @@ export default props => { formatCoord, loaded, validator = () => null, - toggleHighlightFeature = () => {}, disableCoordinatesRow, - disableInfoAlert + disableInfoAlert, + onInitPlugin = () => {}, + pluginCfg } = props; const latlng = point && point.latlng || null; @@ -122,7 +123,9 @@ export default props => { draggable={draggable} onClose={() => { onClose(); - toggleHighlightFeature(false); + onInitPlugin({ + highlight: pluginCfg?.highlightEnabledFromTheStart || false + }); }} dock={dock} style={dockStyle} diff --git a/web/client/components/data/identify/__tests__/IdentifyContainer-test.jsx b/web/client/components/data/identify/__tests__/IdentifyContainer-test.jsx index 00a17ba303..ad9c39f433 100644 --- a/web/client/components/data/identify/__tests__/IdentifyContainer-test.jsx +++ b/web/client/components/data/identify/__tests__/IdentifyContainer-test.jsx @@ -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 = ( { 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'); @@ -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(); diff --git a/web/client/components/data/identify/enhancers/identify.js b/web/client/components/data/identify/enhancers/identify.js index 283c686a56..03724ec45e 100644 --- a/web/client/components/data/identify/enhancers/identify.js +++ b/web/client/components/data/identify/enhancers/identify.js @@ -78,7 +78,8 @@ export const identifyLifecycle = compose( onEnableCenterToMarker = () => {}, setShowInMapPopup = () => {}, checkIdentifyIsMounted = () => {}, - onInitPlugin = () => {} + onInitPlugin = () => {}, + pluginCfg = {} } = this.props; // Initialize plugin configuration @@ -87,9 +88,9 @@ export const identifyLifecycle = compose( configuration: { maxItems }, - showAllResponses + showAllResponses, + highlight: pluginCfg?.highlightEnabledFromTheStart || false }); - if (enabled || showInMapPopup) { changeMousePointer('pointer'); checkIdentifyIsMounted(true); diff --git a/web/client/plugins/Identify.jsx b/web/client/plugins/Identify.jsx index 52f8a4669b..30479ae208 100644 --- a/web/client/plugins/Identify.jsx +++ b/web/client/plugins/Identify.jsx @@ -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 diff --git a/web/client/reducers/__tests__/mapInfo-test.js b/web/client/reducers/__tests__/mapInfo-test.js index 5951d2cacb..837ae71da2 100644 --- a/web/client/reducers/__tests__/mapInfo-test.js +++ b/web/client/reducers/__tests__/mapInfo-test.js @@ -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); + }); });