From d2e6630f0dc5169c9bc1fb0908c589aaafaef167 Mon Sep 17 00:00:00 2001 From: Matteo V Date: Fri, 14 Oct 2016 09:29:58 +0200 Subject: [PATCH] fixed #1141 : saveAs plugin is displayed with user allowedRoles (#1142) --- web/client/plugins/SaveAs.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/client/plugins/SaveAs.jsx b/web/client/plugins/SaveAs.jsx index 3a0ef844fb..0776219574 100644 --- a/web/client/plugins/SaveAs.jsx +++ b/web/client/plugins/SaveAs.jsx @@ -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) => ({ @@ -157,6 +158,7 @@ const SaveAs = React.createClass({ } }); + module.exports = { SaveAsPlugin: connect(selector, { @@ -176,7 +178,12 @@ module.exports = { text: , icon: , 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"} }; + } } })) };