Skip to content

Commit

Permalink
#145: Add check for resource permission (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhweziDeo authored May 11, 2021
1 parent 2b6ec75 commit 205ffd0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions geonode_mapstore_client/client/js/apps/gn-geostory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { registerMediaAPI } from '@mapstore/framework/api/media';
import * as geoNodeMediaApi from '@js/observables/media/geonode';
import {
getEndpoints,
getConfiguration
getConfiguration,getAccountInfo
} from '@js/api/geonode/v2';
import {
setResourceType,
Expand Down Expand Up @@ -110,9 +110,10 @@ initializeApp();
document.addEventListener('DOMContentLoaded', function() {
Promise.all([
getConfiguration(),
getEndpoints()
getAccountInfo(),
getEndpoints(),
])
.then(([localConfig]) => {
.then(([localConfig, user]) => {
const {
securityState,
geoNodeConfiguration,
Expand All @@ -124,7 +125,7 @@ document.addEventListener('DOMContentLoaded', function() {
onStoreInit,
targetId = 'ms-container',
settings
} = setupConfiguration({ localConfig });
} = setupConfiguration({ localConfig, user });

const currentStory = geoNodePageConfig.isNewResource
// change id of new story sections and contents
Expand Down
1 change: 0 additions & 1 deletion geonode_mapstore_client/client/js/apps/gn-home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Promise.all([
getEndpoints()
])
.then(([localConfig, user, resourcesTotalCount]) => {

const {
securityState,
geoNodeConfiguration
Expand Down
6 changes: 3 additions & 3 deletions geonode_mapstore_client/client/js/apps/gn-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
standardEpics,
standardRootReducerFunc
} from '@mapstore/framework/stores/defaultOptions';

import timeline from '@mapstore/framework/reducers/timeline';
import dimension from '@mapstore/framework/reducers/dimension';
import playback from '@mapstore/framework/reducers/playback';
Expand All @@ -42,7 +41,7 @@ import MapView from '@js/routes/MapView';
import gnresource from '@js/reducers/gnresource';
import gnsettings from '@js/reducers/gnsettings';

import { getConfiguration } from '@js/api/geonode/v2';
import { getConfiguration, getAccountInfo } from '@js/api/geonode/v2';

import {
setupConfiguration,
Expand Down Expand Up @@ -91,7 +90,8 @@ initializeApp();


Promise.all([
getConfiguration()
getConfiguration(),
getAccountInfo()
])
.then(([localConfig, user]) => {
const {
Expand Down
5 changes: 3 additions & 2 deletions geonode_mapstore_client/client/js/plugins/SaveAs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ export default createPlugin('SaveAs', {
action: toggleControl.bind(null, 'saveAs', null),
selector: createSelector(
isLoggedIn,
(loggedIn) => ({
style: loggedIn ? {} : { display: 'none' }
(state) => state?.security?.user?.perms?.includes("add_resource"),
(loggedIn, canAddResource) => ({
style: (loggedIn && canAddResource) ? {} : { display: 'none' }
})
)
}
Expand Down

0 comments on commit 205ffd0

Please sign in to comment.