Skip to content

Commit e10495d

Browse files
Update the local config to disable the plugins for view access (#2302)
1 parent fd95710 commit e10495d

File tree

19 files changed

+71
-28
lines changed

19 files changed

+71
-28
lines changed

geonode_mapstore_client/client/js/actions/gnresource.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const SET_SELECTED_LAYER = 'GEONODE:SET_SELECTED_LAYER';
4545
export const UPDATE_LAYER_DATASET = 'GEONODE:UPDATE_LAYER_DATASET';
4646
export const SET_SELECTED_LAYER_DATASET = 'GEONODE:SET_SELECTED_LAYER_DATASET';
4747
export const REQUEST_RESOURCE = 'GEONODE:REQUEST_RESOURCE';
48+
export const SET_DATASET_EDIT_PERMISSIONS_ERROR = 'GEONODE:SET_DATASET_EDIT_PERMISSIONS_ERROR';
4849

4950
/**
5051
* Actions for GeoNode resource
@@ -417,3 +418,10 @@ export function requestResource(resource) {
417418
resource
418419
};
419420
}
421+
422+
export function setDatasetEditPermissionsError(datasetEditPermissionError) {
423+
return {
424+
type: SET_DATASET_EDIT_PERMISSIONS_ERROR,
425+
datasetEditPermissionError
426+
};
427+
}

geonode_mapstore_client/client/js/epics/gnresource.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ import {
7070
resourceError,
7171
setSelectedLayer,
7272
UPDATE_RESOURCE_EXTENT,
73-
updateResourceExtentLoading
73+
updateResourceExtentLoading,
74+
setDatasetEditPermissionsError
7475
} from '@js/actions/gnresource';
7576

7677
import {
@@ -177,6 +178,7 @@ const resourceTypes = {
177178
const [mapConfig, gnLayer, newLayer] = response;
178179
const {minx, miny, maxx, maxy } = newLayer?.bbox?.bounds || {};
179180
const extent = newLayer?.bbox?.bounds && [minx, miny, maxx, maxy ];
181+
const hasDownloadPermission = gnLayer?.perms?.includes('download_resourcebase');
180182
return Observable.of(
181183
configureMap({
182184
...mapConfig,
@@ -204,7 +206,8 @@ const resourceTypes = {
204206
setResourceId(pk),
205207
...(page === 'dataset_edit_data_viewer'
206208
? [
207-
browseData(newLayer)
209+
browseData(newLayer),
210+
...(hasDownloadPermission ? [] : [setDatasetEditPermissionsError('gnviewer.noEditPermissions')])
208211
]
209212
: []),
210213
...(page === 'dataset_edit_layer_settings'

geonode_mapstore_client/client/js/reducers/gnresource.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ import {
3838
SET_SELECTED_LAYER,
3939
UPDATE_LAYER_DATASET,
4040
SET_SELECTED_LAYER_DATASET,
41-
UPDATE_RESOURCE_EXTENT_LOADING
41+
UPDATE_RESOURCE_EXTENT_LOADING,
42+
SET_DATASET_EDIT_PERMISSIONS_ERROR
4243
} from '@js/actions/gnresource';
4344
import {
4445
cleanCompactPermissions,
@@ -49,7 +50,8 @@ import {
4950
const defaultState = {
5051
selectedLayerPermissions: [],
5152
data: {},
52-
permissions: []
53+
permissions: [],
54+
datasetEditPermissionError: null
5355
};
5456

5557
function gnresource(state = defaultState, action) {
@@ -294,6 +296,11 @@ function gnresource(state = defaultState, action) {
294296
})
295297
}
296298
};
299+
case SET_DATASET_EDIT_PERMISSIONS_ERROR:
300+
return {
301+
...state,
302+
datasetEditPermissionError: action.datasetEditPermissionError
303+
};
297304
default:
298305
return state;
299306
}

geonode_mapstore_client/client/js/routes/Viewer.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ function ViewerRoute({
6969
resourceType,
7070
loadingConfig,
7171
configError,
72-
loaderStyle
72+
loaderStyle,
73+
datasetEditPermissionError
7374
}) {
7475

7576
const { pk } = match.params || {};
@@ -133,7 +134,7 @@ function ViewerRoute({
133134
params={params}
134135
/>
135136
{loading && Loader && <Loader style={loaderStyle}/>}
136-
{configError && <MainEventView msgId={configError}/>}
137+
{(configError || datasetEditPermissionError) && <MainEventView msgId={configError || datasetEditPermissionError}/>}
137138
</>
138139
);
139140
}
@@ -147,12 +148,14 @@ const ConnectedViewerRoute = connect(
147148
state => state?.gnresource?.data,
148149
state => state?.gnsettings?.siteName || 'GeoNode',
149150
state => state?.gnresource?.loadingResourceConfig,
150-
state => state?.gnresource?.configError
151-
], (resource, siteName, loadingConfig, configError) => ({
151+
state => state?.gnresource?.configError,
152+
state => state?.gnresource?.datasetEditPermissionError
153+
], (resource, siteName, loadingConfig, configError, datasetEditPermissionError) => ({
152154
resource,
153155
siteName,
154156
loadingConfig,
155-
configError
157+
configError,
158+
datasetEditPermissionError
156159
})),
157160
{
158161
onUpdate: requestResourceConfig,

geonode_mapstore_client/static/mapstore/configs/localConfig.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@
580580
"type": "link",
581581
"href": "{'#/dataset/' + (state('gnResourceData') || {}).pk + '/edit/data'}",
582582
"labelId": "gnviewer.viewData",
583-
"disableIf": "{state('gnResourceData') && ['raster', '3dtiles'].includes(state('gnResourceData').subtype)}"
583+
"disableIf": "{(state('gnResourceData') && ['raster', '3dtiles'].includes(state('gnResourceData').subtype)) || !state('selectedLayerPermissions').includes('download_resourcebase')}"
584584
}
585585
]
586586
},
@@ -658,7 +658,8 @@
658658
},
659659
{
660660
"type": "plugin",
661-
"name": "FilterLayer"
661+
"name": "FilterLayer",
662+
"disableIf": "{!state('selectedLayerPermissions').includes('download_resourcebase')}"
662663
},
663664
{
664665
"type": "link",
@@ -1007,7 +1008,10 @@
10071008
"name": "AddLayer"
10081009
},
10091010
{
1010-
"name": "FilterLayer"
1011+
"name": "FilterLayer",
1012+
"cfg": {
1013+
"disablePluginIf": "{!state('selectedLayerPermissions').includes('download_resourcebase')}"
1014+
}
10111015
},
10121016
{
10131017
"name": "ScaleBox"
@@ -1917,15 +1921,19 @@
19171921
"name": "AddLayer"
19181922
},
19191923
{
1920-
"name": "FilterLayer"
1924+
"name": "FilterLayer",
1925+
"cfg": {
1926+
"disablePluginIf": "{!state('selectedLayerPermissions').includes('download_resourcebase')}"
1927+
}
19211928
},
19221929
{
19231930
"name": "ScaleBox"
19241931
},
19251932
{
19261933
"name": "FeatureEditor",
19271934
"cfg": {
1928-
"primaryKeyAttributes": ["fid"]
1935+
"primaryKeyAttributes": ["fid"],
1936+
"disablePluginIf": "{!state('selectedLayerPermissions').includes('download_resourcebase')}"
19291937
}
19301938
},
19311939
{

geonode_mapstore_client/static/mapstore/gn-translations/data.de-DE.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@
550550
"noAssets": "Keine Assets gefunden",
551551
"updateBoundingBox": "Begrenzungsrahmen aktualisieren",
552552
"updateBoundingBoxSuccess": "Begrenzungsrahmen erfolgreich aktualisiert",
553-
"updateBoundingBoxError": "Fehler beim Aktualisieren des Begrenzungsrahmens"
553+
"updateBoundingBoxError": "Fehler beim Aktualisieren des Begrenzungsrahmens",
554+
"noEditPermissions": "Sie haben keine Berechtigung, diese Ressource zu bearbeiten."
554555
},
555556
"resourcesCatalog": {
556557
"anonymous": "Jeder",

geonode_mapstore_client/static/mapstore/gn-translations/data.en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@
550550
"noAssets": "No assets found",
551551
"updateBoundingBox": "Update bounding box",
552552
"updateBoundingBoxSuccess": "Bounding box updated successfully",
553-
"updateBoundingBoxError": "Error updating bounding box"
553+
"updateBoundingBoxError": "Error updating bounding box",
554+
"noEditPermissions": "You don't have permission to edit this resource."
554555
},
555556
"resourcesCatalog": {
556557
"anonymous": "Anyone",

geonode_mapstore_client/static/mapstore/gn-translations/data.es-ES.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@
549549
"noAssets": "No se encontraron assets",
550550
"updateBoundingBox": "Actualizar caja delimitadora",
551551
"updateBoundingBoxSuccess": "Caja delimitadora actualizada con éxito",
552-
"updateBoundingBoxError": "Error al actualizar la caja delimitadora"
552+
"updateBoundingBoxError": "Error al actualizar la caja delimitadora",
553+
"noEditPermissions": "No tienes permiso para editar este recurso."
553554
},
554555
"resourcesCatalog": {
555556
"anonymous": "Cualquiera",

geonode_mapstore_client/static/mapstore/gn-translations/data.fi-FI.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,8 @@
520520
"noAssets": "No assets found",
521521
"updateBoundingBox": "Update bounding box",
522522
"updateBoundingBoxSuccess": "Bounding box updated successfully",
523-
"updateBoundingBoxError": "Error updating bounding box"
523+
"updateBoundingBoxError": "Error updating bounding box",
524+
"noEditPermissions": "You don't have permission to edit this resource."
524525
},
525526
"resourcesCatalog": {
526527
"anonymous": "Anyone",

geonode_mapstore_client/static/mapstore/gn-translations/data.fr-FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@
550550
"noAssets": "Aucun asset trouvé",
551551
"updateBoundingBox": "Mettre à jour la boîte englobante",
552552
"updateBoundingBoxSuccess": "Boîte englobante mise à jour avec succès",
553-
"updateBoundingBoxError": "Erreur lors de la mise à jour de la boîte englobante"
553+
"updateBoundingBoxError": "Erreur lors de la mise à jour de la boîte englobante",
554+
"noEditPermissions": "Vous n’avez pas l’autorisation de modifier cette ressource."
554555
},
555556
"resourcesCatalog": {
556557
"anonymous": "N'importe qui",

0 commit comments

Comments
 (0)