Skip to content

Commit

Permalink
fixed #1141 : saveAs plugin is displayed with user allowedRoles (#1142)
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 authored and offtherailz committed Oct 14, 2016
1 parent 4bde244 commit d2e6630
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion web/client/plugins/SaveAs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {editMap, updateCurrentMap, errorCurrentMap, resetCurrentMap} = require('.
const {mapSelector} = require('../selectors/map');
const stateSelector = state => state;
const {layersSelector} = require('../selectors/layers');
const {indexOf} = require('lodash');


const selector = createSelector(mapSelector, stateSelector, layersSelector, (map, state, layers) => ({
Expand Down Expand Up @@ -157,6 +158,7 @@ const SaveAs = React.createClass({
}
});


module.exports = {
SaveAsPlugin: connect(selector,
{
Expand All @@ -176,7 +178,12 @@ module.exports = {
text: <Message msgId="saveAs"/>,
icon: <Glyphicon glyph="floppy-open"/>,
action: editMap.bind(null, {}),
selector: (state) => (state && state.security && state.security.user ? {} : { style: {display: "none"} })
selector: (state) => {
if (state && state.controls && state.controls.saveAs && state.controls.saveAs.allowedRoles) {
return indexOf(state.controls.saveAs.allowedRoles, state && state.security && state.security.user && state.security.user.role) !== -1 ? {} : { style: {display: "none"} };
}
return state && state.security && state.security.user ? {} : { style: {display: "none"} };
}
}
}))
};

0 comments on commit d2e6630

Please sign in to comment.