diff --git a/CHANGELOG.md b/CHANGELOG.md index 76691474e..ba0dd985f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Location precision filter caused an internal error. - Base maps were loaded beyond their maximum zoom level. - `layer_depth_to` was displayed in filter even though it was not selected in the filter settings. +- Users can now only import or add new boreholes to workgroups where they have an editor role. ## v2.1.772 - 2024-06-27 diff --git a/src/client/src/ReduxStateInterfaces.ts b/src/client/src/ReduxStateInterfaces.ts index ca048eb74..1ce05e5e2 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,13 +24,13 @@ export interface Workgroup { disabled: null; id: number; workgroup: string; - roles: string[]; + roles: Role[]; } interface Workflow { started: string; finished: string; - role: string; + role: Role; username: string; workflow: number; } @@ -41,7 +43,7 @@ export interface Borehole { workflow: Workflow; id: number; spatial_reference_system: number; - role: string; + role: Role; lock: { id: number; }; diff --git a/src/client/src/commons/menu/mainView/mainSideNav.tsx b/src/client/src/commons/menu/mainView/mainSideNav.tsx index 225d47fd4..c6d67a979 100644 --- a/src/client/src/commons/menu/mainView/mainSideNav.tsx +++ b/src/client/src/commons/menu/mainView/mainSideNav.tsx @@ -50,7 +50,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]); 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: ,