Skip to content

#1977: Move group setting to management panel #2024

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

Merged
merged 6 commits into from
Jun 19, 2025
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
2 changes: 1 addition & 1 deletion geonode_mapstore_client/client/MapStore2
Submodule MapStore2 updated 187 files
4 changes: 4 additions & 0 deletions geonode_mapstore_client/client/js/api/geonode/v2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,13 @@ export const getUsers = ({
q,
page = 1,
pageSize = 20,
config,
...params
} = {}) => {
return axios.get(
getEndpointUrl(USERS),
{
...config,
params: {
...params,
...(q && {
Expand All @@ -411,11 +413,13 @@ export const getGroups = ({
q,
page = 1,
pageSize = 20,
config,
...params
} = {}) => {
return axios.get(
getEndpointUrl(GROUPS),
{
...config,
params: {
...params,
...(q && {
Expand Down
101 changes: 99 additions & 2 deletions geonode_mapstore_client/client/js/epics/__tests__/gnsave-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { SET_EDIT_PERMISSION } from '@mapstore/framework/actions/styleeditor';
import { configureMap } from '@mapstore/framework/actions/config';

import { selectNode, addLayer } from '@mapstore/framework/actions/layers';
import { START_ASYNC_PROCESS } from '@js/actions/resourceservice';


let mockAxios;
Expand All @@ -49,13 +50,101 @@ describe('gnsave epics', () => {
setTimeout(done);
});
it('should create new map with success (gnSaveContent)', (done) => {
const NUM_ACTIONS = 5;
const metadata = {
title: 'Title',
description: 'Description',
thumbnail: 'thumbnail.jpeg'
};
mockAxios.onPost().reply(() => [200, { map: {} }]);
mockAxios.onPut().reply(() => [200, { output: {} }]);
testEpic(
gnSaveContent,
NUM_ACTIONS,
saveContent(undefined, metadata, false),
(actions) => {
try {
expect(actions.map(({ type }) => type))
.toEqual([
SAVING_RESOURCE,
SAVE_SUCCESS,
SET_RESOURCE,
UPDATE_SINGLE_RESOURCE,
START_ASYNC_PROCESS
]);
} catch (e) {
done(e);
}
done();
},
{
gnresource: {
data: {
resource_type: "map"
},
isCompactPermissionsChanged: true,
compactPermissions: {
users: [],
organizations: [],
groups: []
}
}
}
);
});
it('should update existing map with success (gnSaveContent)', (done) => {
const NUM_ACTIONS = 5;
const id = 1;
const metadata = {
title: 'Title',
description: 'Description',
thumbnail: 'thumbnail.jpeg'
};
mockAxios.onPatch().reply(() => [200, {}]);
mockAxios.onPut().reply(() => [200, { output: {} }]);
testEpic(
gnSaveContent,
NUM_ACTIONS,
saveContent(id, metadata, false, false),
(actions) => {
try {
expect(actions.map(({ type }) => type))
.toEqual([
SAVING_RESOURCE,
SAVE_SUCCESS,
SET_RESOURCE,
UPDATE_SINGLE_RESOURCE,
START_ASYNC_PROCESS
]);
} catch (e) {
done(e);
}
done();
},
{
gnresource: {
data: {
resource_type: "map"
},
isCompactPermissionsChanged: true,
compactPermissions: {
users: [],
organizations: [],
groups: []
}
}
}
);
});
it('should skip permission update when permission is unchanged', (done) => {
const NUM_ACTIONS = 4;
const metadata = {
title: 'Title',
description: 'Description',
thumbnail: 'thumbnail.jpeg'
};
mockAxios.onPost().reply(() => [200, { map: {} }]);
mockAxios.onPut().reply(() => [200, { output: {} }]);
testEpic(
gnSaveContent,
NUM_ACTIONS,
Expand Down Expand Up @@ -110,7 +199,15 @@ describe('gnsave epics', () => {
},
{
gnresource: {
type: "map"
data: {
resource_type: "map"
},
isCompactPermissionsChanged: false,
compactPermissions: {
users: [],
organizations: [],
groups: []
}
}
}
);
Expand Down Expand Up @@ -170,7 +267,7 @@ describe('gnsave epics', () => {
'thumbnail_url': 'thumbnail.jpeg'
};
mockAxios.onGet(new RegExp(`resources/${pk}`))
.reply(200, resource);
.reply(200, {resource});
testEpic(
gnSaveDirectContent,
NUM_ACTIONS,
Expand Down
7 changes: 5 additions & 2 deletions geonode_mapstore_client/client/js/epics/gnsave.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ export const gnSaveContent = (action$, store) =>
const extent = getExtentPayload(state, contentType);
const body = {
'title': action.metadata.name,
...(RESOURCE_MANAGEMENT_PROPERTIES_KEYS.reduce((acc, key) => {
...([...RESOURCE_MANAGEMENT_PROPERTIES_KEYS, 'group'].reduce((acc, key) => {
if (currentResource?.[key] !== undefined) {
acc[key] = !!currentResource[key];
const value = typeof currentResource[key] === 'boolean' ? !!currentResource[key] : currentResource[key];
acc[key] = value;
}
return acc;
}, {})),
Expand Down Expand Up @@ -312,6 +313,8 @@ export const gnSaveDirectContent = (action$, store) =>
const resourceId = mapInfo?.id || getResourceId(state);
const { geoLimits } = getPermissionsPayload(state);

// resource information should be saved in a synchronous manner
// i.e update resource data followed by permissions
return Observable.defer(() => axios.all([
getResourceByPk(resourceId),
...(geoLimits
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React, { forwardRef } from 'react';
import { Checkbox } from 'react-bootstrap';
import { Checkbox, FormGroup, ControlLabel } from 'react-bootstrap';

import Message from '@mapstore/framework/components/I18N/Message';
import tooltip from '@mapstore/framework/components/misc/enhancers/tooltip';
import { canAccessPermissions, canManageResourceSettings, RESOURCE_MANAGEMENT_PROPERTIES } from '@js/utils/ResourceUtils';
import FlexBox from '@mapstore/framework/components/layout/FlexBox';
import Text from '@mapstore/framework/components/layout/Text';
import SelectInfiniteScroll from '@mapstore/framework/plugins/ResourcesCatalog/components/SelectInfiniteScroll';
import { getGroups } from '@js/api/geonode/v2';
import { canAccessPermissions, canManageResourceSettings, RESOURCE_MANAGEMENT_PROPERTIES } from '@js/utils/ResourceUtils';
import DetailsPermissions from '@js/plugins/ResourceDetails/containers/Permissions';

const MessageTooltip = tooltip(forwardRef(({children, msgId, ...props}, ref) => {
Expand All @@ -20,6 +23,30 @@ const MessageTooltip = tooltip(forwardRef(({children, msgId, ...props}, ref) =>
function DetailsSettings({ resource, onChange }) {
return (
<FlexBox column gap="md" className="gn-details-settings _padding-tb-md">
<FlexBox.Fill gap="xs" className="_padding-b-xs">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need specific permission to visualize this dropdown?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I can remember of and not specifically asked in the requirement too. Only that it needs to be disabled when permission is missing change_resourcebase

<FormGroup>
<ControlLabel><Message msgId={"gnviewer.group"} /></ControlLabel>
<SelectInfiniteScroll
clearable
disabled={!(resource?.perms || []).includes('change_resourcebase')}
value={{ label: resource?.group?.name, value: resource?.group }}
placeholder={"gnviewer.groupPlaceholder"}
onChange={(selected) => onChange({ group: selected?.value ?? null})}
loadOptions={({ q, ...params }) => getGroups({q, ...params})
.then((response) => {
return {
...response,
results: (response?.groups ?? [])
.map((item) => ({...item, selectOption: {
value: item.group,
label: item.group.name
}}))
};
})
}
/>
</FormGroup>
</FlexBox.Fill>
{canAccessPermissions(resource) && <DetailsPermissions resource={resource} />}
{canManageResourceSettings(resource) && (
<FlexBox column gap="xs">
Expand Down
2 changes: 1 addition & 1 deletion geonode_mapstore_client/client/js/selectors/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export const getResourceDirtyState = (state) => {
return null;
}
const resourceType = state?.gnresource?.type;
let metadataKeys = ['title', 'abstract', 'data', 'extent', ...RESOURCE_MANAGEMENT_PROPERTIES_KEYS];
let metadataKeys = ['title', 'abstract', 'data', 'extent', 'group', ...RESOURCE_MANAGEMENT_PROPERTIES_KEYS];
if (resourceType === ResourceTypes.DATASET) {
metadataKeys = metadataKeys.concat('timeseries');
}
Expand Down
10 changes: 5 additions & 5 deletions geonode_mapstore_client/client/js/utils/ResourceUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

import uuid from 'uuid';
import url from 'url';
import isEmpty from 'lodash/isEmpty';
import omit from 'lodash/omit';
import { isEmpty, uniqBy, omit, orderBy, isString, isObject } from 'lodash';

import { isImageServerUrl } from '@mapstore/framework/utils/ArcGISUtils';
import { getConfigProp, convertFromLegacy, normalizeConfig } from '@mapstore/framework/utils/ConfigUtils';
import { excludeGoogleBackground, extractTileMatrixFromSources, ServerTypes } from '@mapstore/framework/utils/LayersUtils';

import { getGeoNodeLocalConfig, parseDevHostname } from '@js/utils/APIUtils';
import { ProcessTypes, ProcessStatus } from '@js/utils/ResourceServiceUtils';
import { uniqBy, orderBy, isString, isObject } from 'lodash';
import { excludeGoogleBackground, extractTileMatrixFromSources, ServerTypes } from '@mapstore/framework/utils/LayersUtils';
import { determineResourceType } from '@js/utils/FileUtils';
import { isImageServerUrl } from '@mapstore/framework/utils/ArcGISUtils';

/**
* @module utils/ResourceUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@
"filterBy": "Filtern...",
"addPermissionsEntry": "Benutzer / Gruppen hinzufügen",
"groups": "Gruppen",
"group": "Gruppe",
"groupPlaceholder": "Gruppe auswählen",
"users": "Benutzer",
"nonePermission": "Keiner",
"viewPermission": "Ansicht",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@
"data": "Data",
"filterBy": "Filter...",
"addPermissionsEntry": "Add Users / Groups",
"group": "Group",
"groupPlaceholder": "Select group",
"groups": "Groups",
"users": "Users",
"nonePermission": "None",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@
"filterBy": "Filtro ...",
"addPermissionsEntry": "Agregar usuarios / grupos",
"groups": "Grupos",
"group": "Grupo",
"groupPlaceholder": "Seleccionar grupo",
"users": "Usuarios",
"nonePermission": "Ninguno",
"viewPermission": "Ver",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
"filterBy": "Filter...",
"addPermissionsEntry": "Add Users / Groups",
"groups": "Groups",
"group": "Group",
"groupPlaceholder": "Select group",
"users": "Users",
"nonePermission": "None",
"viewPermission": "View",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@
"filterBy": "Filtrer...",
"addPermissionsEntry": "Ajouter des utilisateurs/groupes",
"groups": "Groupes",
"group": "Groupe",
"groupPlaceholder": "Sélectionner un groupe",
"users": "Utilisateurs",
"nonePermission": "Rien",
"viewPermission": "View",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
"filterBy": "Filter...",
"addPermissionsEntry": "Add Users / Groups",
"groups": "Groups",
"group": "Group",
"groupPlaceholder": "Select group",
"users": "Users",
"nonePermission": "None",
"viewPermission": "View",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@
"filterBy": "Filtra...",
"addPermissionsEntry": "Aggiungi utenti/gruppi",
"groups": "Gruppi",
"group": "Gruppo",
"groupPlaceholder": "Seleziona gruppo",
"users": "Utenti",
"nonePermission": "Nessuno",
"viewPermission": "Visualizza",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
"filterBy": "Filter...",
"addPermissionsEntry": "Add Users / Groups",
"groups": "Groups",
"group": "Group",
"groupPlaceholder": "Select group",
"users": "Users",
"nonePermission": "None",
"viewPermission": "View",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
"filterBy": "Filter...",
"addPermissionsEntry": "Add Users / Groups",
"groups": "Groups",
"group": "Group",
"groupPlaceholder": "Select group",
"users": "Users",
"nonePermission": "None",
"viewPermission": "View",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
"filterBy": "Filter...",
"addPermissionsEntry": "Add Users / Groups",
"groups": "Groups",
"group": "Group",
"groupPlaceholder": "Select group",
"users": "Users",
"nonePermission": "None",
"viewPermission": "View",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@
"filterBy": "Filter...",
"addPermissionsEntry": "Add Users / Groups",
"groups": "Groups",
"group": "Group",
"groupPlaceholder": "Select group",
"users": "Users",
"nonePermission": "None",
"viewPermission": "View",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
"filterBy": "Filter...",
"addPermissionsEntry": "Add Users / Groups",
"groups": "Groups",
"group": "Group",
"groupPlaceholder": "Select group",
"users": "Users",
"nonePermission": "None",
"viewPermission": "View",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
"filterBy": "Filter...",
"addPermissionsEntry": "Add Users / Groups",
"groups": "Groups",
"group": "Group",
"groupPlaceholder": "Select group",
"users": "Users",
"nonePermission": "None",
"viewPermission": "View",
Expand Down