Skip to content

Commit

Permalink
#9434: Fix - Advanced map editing in geostory crashes the app (#9457) (
Browse files Browse the repository at this point in the history
…#9477)

(cherry picked from commit 4a9de8e)
(cherry picked from commit 301c533e7735499213328e85b2c23bfe8669b321)
  • Loading branch information
dsuren1 authored Sep 25, 2023
1 parent f64d0c4 commit 0088d71
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import ReactTestUtils from 'react-dom/test-utils';
import {createSink} from 'recompose';

import Toolbar from '../../../../misc/toolbar/Toolbar';
import {withLocalMapState, withMapEditingAndLocalMapState, withToolbar} from '../map';
import withMapEnhancer, { withLocalMapState, withMapEditingAndLocalMapState, withToolbar } from '../map';
import { Provider } from 'react-redux';

describe("geostory media map component enhancers", () => {
beforeEach((done) => {
Expand All @@ -25,6 +26,20 @@ describe("geostory media map component enhancers", () => {
document.body.innerHTML = '';
setTimeout(done);
});
it('withMapEnhancer generate correct props', (done) => {
const resources = [{id: "1", type: "map", data: {id: "2", layers: [], context: "1"}}];
const store = {
subscribe: () => {}, getState: () => ({geostory: {currentStory: {resources}}})
};
const resourceId = "1";
const Sink = withMapEnhancer(createSink( props => {
expect(props).toBeTruthy();
expect(props.map).toBeTruthy();
expect(props.map).toEqual({id: "2", layers: []});
done();
}));
ReactDOM.render(<Provider store={store}><Sink resourceId={resourceId} map={{}}/></Provider>, document.getElementById("container"));
});
it('withLocalMapState generate correct props', (done) => {
const Sink = withLocalMapState(createSink( props => {
expect(props).toExist();
Expand Down
4 changes: 2 additions & 2 deletions web/client/components/geostory/common/enhancers/map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/

import { find, isEqual } from 'lodash';
import { find, isEqual, omit } from 'lodash';
import React from 'react';
import {connect} from 'react-redux';
import {branch, compose, createEventHandler, mapPropsStream, withHandlers, withProps, withPropsOnChange, withStateHandlers} from 'recompose';
Expand Down Expand Up @@ -39,7 +39,7 @@ export default compose(
({ resources, resourceId, map = {}}) => {
const cleanedMap = {...map, layers: (map.layers || []).map(l => l ? l : undefined)};
const resource = find(resources, { id: resourceId }) || {};
return { map: createMapObject(resource.data, cleanedMap)};
return { map: createMapObject(omit(resource.data, ['context']), cleanedMap)};
}
));
/**
Expand Down

0 comments on commit 0088d71

Please sign in to comment.