From e9f6f5b097f7af1cfa7cc88fbad63ed3fc8c5de0 Mon Sep 17 00:00:00 2001 From: Jacky Li Date: Tue, 30 Jul 2024 17:46:33 -0700 Subject: [PATCH 01/21] bugfix: add report rule to allow edit on report state DEVSU-2408 --- app/context/ResourceContext/index.tsx | 12 ++++++++++++ .../ReportView/components/Settings/index.tsx | 16 ++++++++-------- app/views/ReportView/index.tsx | 16 ++++++++++------ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/app/context/ResourceContext/index.tsx b/app/context/ResourceContext/index.tsx index d423d09a7..e00f555ed 100644 --- a/app/context/ResourceContext/index.tsx +++ b/app/context/ResourceContext/index.tsx @@ -25,15 +25,27 @@ const REPORTS_BLOCK = []; const ADMIN_ACCESS = ['admin']; const ADMIN_BLOCK = [...ALL_ROLES, ...NO_GROUP_MATCH]; +/** + * Checks user permissions based on the groups they are assigned, nothing report-specific + */ const useResources = (): ResourceContextType => { const { userDetails: { groups } } = useSecurity(); const [germlineAccess, setGermlineAccess] = useState(false); const [reportsAccess, setReportsAccess] = useState(false); + /** + * Is the user allowed to edit the report + */ const [reportEditAccess, setReportEditAccess] = useState(false); + /** + * Is the user allowed to assign users to the report + */ const [reportAssignmentAccess, setReportAssignmentAccess] = useState(false); const [adminAccess, setAdminAccess] = useState(false); const [managerAccess, setManagerAccess] = useState(false); + /** + * Is the user allowed to see the settings page + */ const [reportSettingAccess, setReportSettingAccess] = useState(false); const [unreviewedAccess, setUnreviewedAccess] = useState(false); const [nonproductionAccess, setNonproductionAccess] = useState(false); diff --git a/app/views/ReportView/components/Settings/index.tsx b/app/views/ReportView/components/Settings/index.tsx index a5fb49a80..a0d4e51be 100644 --- a/app/views/ReportView/components/Settings/index.tsx +++ b/app/views/ReportView/components/Settings/index.tsx @@ -16,7 +16,6 @@ import { import api from '@/services/api'; import useReport from '@/hooks/useReport'; -import useResource from '@/hooks/useResource'; import DemoDescription from '@/components/DemoDescription'; import snackbar from '@/services/SnackbarUtils'; import withLoading, { WithLoadingInjectedProps } from '@/hoc/WithLoading'; @@ -37,12 +36,13 @@ const Settings = ({ isLoading, setIsLoading, }: SettingsProps): JSX.Element => { - /** - * Does not matter if they have report access, they need to be in admin or manager role to edit this section - */ const { report, setReport } = useReport(); - const { reportEditAccess } = useResource(); - let { canEdit } = useReport(); + const { canEdit: reportAllowEdit } = useReport(); + + /** + * If the report is completed, disable all fields except report state field on the front-end + */ + let canEdit = reportAllowEdit; if (report.state === 'completed') { canEdit = false; } @@ -210,7 +210,7 @@ const Settings = ({ Report State