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

[Backport 2.1.x] #191: /style_edit#/ subpath doesn't trigger the opening of the style editor #194

Merged
merged 2 commits into from
May 24, 2021
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
4 changes: 2 additions & 2 deletions geonode_mapstore_client/client/js/apps/gn-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { updateGeoNodeSettings } from '@js/actions/gnsettings';
import {
updateMapLayoutEpic,
gnCheckSelectedLayerPermissions,
setLayersPermissions
gnSetLayersPermissions
} from '@js/epics';
import maplayout from '@mapstore/framework/reducers/maplayout';
import 'react-widgets/dist/css/react-widgets.css';
Expand Down Expand Up @@ -175,7 +175,7 @@ Promise.all([
...configEpics,
updateMapLayoutEpic,
gnCheckSelectedLayerPermissions,
setLayersPermissions,
gnSetLayersPermissions,
...pluginsDefinition.epics
},
geoNodeConfiguration,
Expand Down
12 changes: 6 additions & 6 deletions geonode_mapstore_client/client/js/epics/__tests__/gnsave-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
gnUpdateResource,
gnSaveDirectContent
} from '@js/epics/gnsave';
import {gnCheckSelectedLayerPermissions, setLayersPermissions} from '@js/epics';
import {gnCheckSelectedLayerPermissions, gnSetLayersPermissions} from '@js/epics';
import { SET_PERMISSION } from '@mapstore/framework/actions/featuregrid';
import { SET_EDIT_PERMISSION } from '@mapstore/framework/actions/styleeditor';
import { configureMap } from '@mapstore/framework/actions/config';
Expand Down Expand Up @@ -186,7 +186,7 @@ describe('gnsave epics', () => {
testEpic(gnCheckSelectedLayerPermissions,
NUM_ACTIONS, selectNode(1, "layer"), (actions) => {
try {
expect(actions.map(({type}) => type)).toEqual([SET_PERMISSION, SET_SELECTED_LAYER_PERMISSIONS, SET_EDIT_PERMISSION]);
expect(actions.map(({type}) => type)).toEqual([SET_PERMISSION, SET_EDIT_PERMISSION, SET_SELECTED_LAYER_PERMISSIONS]);
done();
} catch (error) {
done(error);
Expand All @@ -195,11 +195,11 @@ describe('gnsave epics', () => {

});

it('test setLayersPermissions trigger updateNode for MAP_CONFIG_LOADED', (done) => {
it('test gnSetLayersPermissions trigger updateNode for MAP_CONFIG_LOADED', (done) => {
mockAxios.onGet().reply(() => [200,
{layers: [{perms: ['change_layer_style', 'change_layer_data'], alternate: "testLayer"}]}]);
const NUM_ACTIONS = 1;
testEpic(setLayersPermissions, NUM_ACTIONS, configureMap({map: {layers: [{name: "testLayer", id: "test_id"}]}}), (actions) => {
testEpic(gnSetLayersPermissions, NUM_ACTIONS, configureMap({map: {layers: [{name: "testLayer", id: "test_id"}]}}), (actions) => {
try {
expect(actions.map(({type}) => type)).toEqual(["UPDATE_NODE"]);
done();
Expand All @@ -210,11 +210,11 @@ describe('gnsave epics', () => {
{layers: {flat: [{name: "testLayer", id: "test_id", perms: ['download_resourcebase']}], selected: ["test_id"]}});
});

it('test setLayersPermissions trigger updateNode for ADD_LAYER', (done) => {
it('test gnSetLayersPermissions trigger updateNode for ADD_LAYER', (done) => {
mockAxios.onGet().reply(() => [200,
{layers: [{perms: ['change_layer_style', 'change_layer_data'], alternate: "testLayer"}]}]);
const NUM_ACTIONS = 1;
testEpic(setLayersPermissions, NUM_ACTIONS, addLayer({name: "testLayer"}), (actions) => {
testEpic(gnSetLayersPermissions, NUM_ACTIONS, addLayer({name: "testLayer"}), (actions) => {
try {
expect(actions.map(({type}) => type)).toEqual(["UPDATE_NODE"]);
done();
Expand Down
10 changes: 6 additions & 4 deletions geonode_mapstore_client/client/js/epics/gnsave.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ export const gnSaveContent = (action$, store) =>
saveError(error.data || error.message),
action.showNotifications && errorNotification({title: "map.mapError.errorTitle", message: "map.mapError.errorDefault"})
);
});
})
.startWith(savingResource());

}).startWith(savingResource());
});

export const gnSaveDirectContent = (action$, store) =>
action$.ofType(SAVE_DIRECT_CONTENT)
Expand All @@ -179,8 +180,9 @@ export const gnSaveDirectContent = (action$, store) =>
saveError(error.data || error.message),
errorNotification({title: "map.mapError.errorTitle", message: error.data || error.message || "map.mapError.errorDefault"})
);
});
}).startWith(savingResource());
})
.startWith(savingResource());
});

export const gnUpdateResource = (action$, store) =>
action$.ofType(UPDATE_RESOURCE_BEFORE_SAVE)
Expand Down
22 changes: 13 additions & 9 deletions geonode_mapstore_client/client/js/epics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,25 @@ export const gnCheckSelectedLayerPermissions = (action$, { getState } = {}) =>
const permissions = layer?.perms || [];
const canEditStyles = permissions.includes("change_layer_style");
const canEdit = permissions.includes("change_layer_data");
return layer ? Rx.Observable.of(
setPermission({canEdit}),
setEditPermissionStyleEditor(canEditStyles),
setSelectedLayerPermissions(permissions)
)
.startWith(setPermission({canEdit: false}), setSelectedLayerPermissions([]), setEditPermissionStyleEditor(false))
.catch(() => {Rx.Observable.empty();}) : Rx.Observable.of(setPermission({canEdit: false}), setEditPermissionStyleEditor(false), setSelectedLayerPermissions([]));
return layer
? Rx.Observable.of(
setPermission({canEdit}),
setEditPermissionStyleEditor(canEditStyles),
setSelectedLayerPermissions(permissions)
)
: Rx.Observable.of(
setPermission({canEdit: false}),
setEditPermissionStyleEditor(false),
setSelectedLayerPermissions([])
);
});


/**
* Checks the permissions for layers when a map is loaded and when a new layer is added
* to a map
*/
export const setLayersPermissions = (actions$, { getState = () => {}} = {}) =>
export const gnSetLayersPermissions = (actions$, { getState = () => {}} = {}) =>
actions$.ofType(MAP_CONFIG_LOADED, ADD_LAYER)
.switchMap((action) => {
if (action.type === MAP_CONFIG_LOADED) {
Expand Down Expand Up @@ -153,5 +157,5 @@ export const updateMapLayoutEpic = (action$, store) =>
export default {
gnCheckSelectedLayerPermissions,
updateMapLayoutEpic,
setLayersPermissions
gnSetLayersPermissions
};
2 changes: 1 addition & 1 deletion geonode_mapstore_client/client/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
geonode-mapstore-client-v2.0.9-9988cf081102b899fabbf847d7b512e154e3a9c9
geonode-mapstore-client-v2.0.9-c805a06c2cb578645542fe5a1b984d5e8ebfec8e

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading