Skip to content

Commit

Permalink
fix geosolutions-it#2807 back interaction from widget to feature grid
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 committed Apr 12, 2018
1 parent 4b1e103 commit 274cefd
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
27 changes: 24 additions & 3 deletions web/client/plugins/widgetbuilder/enhancers/withMapExitButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,37 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
const { compose, withProps } = require('recompose');
const { compose, withProps, withHandlers} = require('recompose');
const { connect } = require('react-redux');

const {setControlProperty} = require('../../../actions/controls');
const {openFeatureGrid} = require('../../../actions/featuregrid');
const { onEditorChange } = require('../../../actions/widgets');
const {featureGridSelector} = require('../../../selectors/controls');
/**
* Reset widgets
*/
module.exports = compose(
connect(() => ({}), {
backFromWizard: () => onEditorChange('widgetType', undefined)
connect(() => ({
returnToFeatureGrid: state => featureGridSelector(state)}),
{
backToWidgetList: () => onEditorChange('widgetType', undefined),
backToFeatureGrid: () => setControlProperty("widgetBuilder", "enabled", false, false),
openFeatureGridTable: () => openFeatureGrid()
}),
withHandlers({
backFromWizard: ({
backToWidgetList = () => {},
backToFeatureGrid = () => {},
openFeatureGridTable = () => {},
returnToFeatureGrid
}) => () => {
if (returnToFeatureGrid) {
backToFeatureGrid();
openFeatureGridTable();
}
backToWidgetList();
}
}),
withProps(({ backFromWizard = () => {} }) => ({
exitButton: {
Expand Down
36 changes: 34 additions & 2 deletions web/client/selectors/__tests__/controls-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
const expect = require('expect');
const {
queryPanelSelector,
wfsDownloadAvailable
wfsDownloadAvailable,
wfsDownloadSelector,
widgetBuilderAvailable,
widgetBuilderSelector,
featureGridSelector
} = require("../controls");

const state = {
Expand All @@ -18,7 +22,15 @@ const state = {
enabled: true
},
wfsdownload: {
available: true
available: true,
enabled: true
},
widgetBuilder: {
available: true,
enabled: true
},
featuregrid: {
enabled: true
}
}
};
Expand All @@ -34,5 +46,25 @@ describe('Test controls selectors', () => {
expect(retVal).toExist();
expect(retVal).toBe(true);
});
it('test wfsDownloadSelector', () => {
const retVal = wfsDownloadSelector(state);
expect(retVal).toExist();
expect(retVal).toBe(true);
});
it('test widgetBuilderAvailable', () => {
const retVal = widgetBuilderAvailable(state);
expect(retVal).toExist();
expect(retVal).toBe(true);
});
it('test widgetBuilderSelector', () => {
const retVal = widgetBuilderSelector(state);
expect(retVal).toExist();
expect(retVal).toBe(true);
});
it('test featureGridSelector', () => {
const retVal = featureGridSelector(state);
expect(retVal).toExist();
expect(retVal).toBe(true);
});

});
3 changes: 2 additions & 1 deletion web/client/selectors/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ module.exports = {
wfsDownloadAvailable: state => !!get(state, "controls.wfsdownload.available"),
wfsDownloadSelector: state => !!get(state, "controls.wfsdownload.enabled"),
widgetBuilderAvailable: state => get(state, "controls.widgetBuilder.available"),
widgetBuilderSelector: (state) => get(state, "controls.widgetBuilder.enabled")
widgetBuilderSelector: (state) => get(state, "controls.widgetBuilder.enabled"),
featureGridSelector: (state) => get(state, "controls.featuregrid.enabled")
};

0 comments on commit 274cefd

Please sign in to comment.