From 2d52cb910987cee32a7a1bb47cb9574868b7a3c0 Mon Sep 17 00:00:00 2001 From: tschumpr Date: Wed, 24 Jul 2024 14:24:25 +0200 Subject: [PATCH 1/4] Restrict import and adding --- src/client/src/ReduxStateInterfaces.ts | 6 ++++-- src/client/src/commons/menu/mainView/mainSideNav.tsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client/src/ReduxStateInterfaces.ts b/src/client/src/ReduxStateInterfaces.ts index ca048eb74..ee5995e6f 100644 --- a/src/client/src/ReduxStateInterfaces.ts +++ b/src/client/src/ReduxStateInterfaces.ts @@ -8,10 +8,12 @@ export interface User { data: UserData; } +export type Role = "PUBLIC" | "VIEW" | "VALID" | "EDIT" | "CONTROL"; + export interface UserData { // Incomplete type definition, add other properties as needed workgroups: Workgroup[]; - roles: string[]; + roles: Role[]; id: number; name: string; username: string; @@ -22,7 +24,7 @@ export interface Workgroup { disabled: null; id: number; workgroup: string; - roles: string[]; + roles: Role[]; } interface Workflow { diff --git a/src/client/src/commons/menu/mainView/mainSideNav.tsx b/src/client/src/commons/menu/mainView/mainSideNav.tsx index c3c11c29c..9314c0442 100644 --- a/src/client/src/commons/menu/mainView/mainSideNav.tsx +++ b/src/client/src/commons/menu/mainView/mainSideNav.tsx @@ -63,7 +63,7 @@ const MainSideNav = ({ }; useEffect(() => { - const wgs = user.data.workgroups.filter(w => w.disabled === null && !w.supplier); + const wgs = user.data.workgroups.filter(w => w.disabled === null && !w.supplier && w.roles.includes("EDIT")); setEnabledWorkgroups(wgs); setWorkgroup(wgs.length > 0 ? wgs[0].id : null); }, [setEnabledWorkgroups, setWorkgroup, user.data.workgroups]); From d44cccb890c49957f9b79c544bbcc542201dde38 Mon Sep 17 00:00:00 2001 From: tschumpr Date: Wed, 24 Jul 2024 14:24:37 +0200 Subject: [PATCH 2/4] Remove unused code --- src/client/src/pages/editor/editorComponent.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/client/src/pages/editor/editorComponent.jsx b/src/client/src/pages/editor/editorComponent.jsx index 4d210a6b6..ad1247b7a 100644 --- a/src/client/src/pages/editor/editorComponent.jsx +++ b/src/client/src/pages/editor/editorComponent.jsx @@ -64,7 +64,6 @@ const EditorComponent = props => { workgroup={workgroup} setWorkgroup={setWorkgroup} enabledWorkgroups={enabledWorkgroups} - setEnabledWorkgroups={setEnabledWorkgroups} /> ), customLayers: , From 964b835692a5678fde6b9b326f8cce7454f069b8 Mon Sep 17 00:00:00 2001 From: tschumpr Date: Wed, 24 Jul 2024 14:24:45 +0200 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7326a15c..6ad71cc6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Attribute `top_bedrock_weathered` could not be imported. - Badge with number of active filters on sidebar did not include polygon filter. +- Users can now only import or add new boreholes to workgroups where they have an editor role. ## v2.1.772 - 2024-06-27 From 57820135530bd843ca09a8a7e4679b961adc47af Mon Sep 17 00:00:00 2001 From: tschumpr Date: Wed, 24 Jul 2024 14:35:59 +0200 Subject: [PATCH 4/4] Set role type --- src/client/src/ReduxStateInterfaces.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/src/ReduxStateInterfaces.ts b/src/client/src/ReduxStateInterfaces.ts index ee5995e6f..1ce05e5e2 100644 --- a/src/client/src/ReduxStateInterfaces.ts +++ b/src/client/src/ReduxStateInterfaces.ts @@ -30,7 +30,7 @@ export interface Workgroup { interface Workflow { started: string; finished: string; - role: string; + role: Role; username: string; workflow: number; } @@ -43,7 +43,7 @@ export interface Borehole { workflow: Workflow; id: number; spatial_reference_system: number; - role: string; + role: Role; lock: { id: number; };