Skip to content

Commit 8cac622

Browse files
authored
Merge pull request #561 from bcgsc/release/v6.31.1
Release/v6.31.1
2 parents 5f4315b + cb909b1 commit 8cac622

File tree

8 files changed

+282
-181
lines changed

8 files changed

+282
-181
lines changed

app/components/SignatureCard/index.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,44 @@ const SignatureCard = ({
4545
const { userDetails } = useSecurity();
4646

4747
const [userSignature, setUserSignature] = useState<UserType>();
48-
const [role, setRole] = useState('');
48+
const [role, setRole] = useState<string>();
4949

5050
useEffect(() => {
51+
if (type) { // need to do these separately because signatures may be null
52+
if (type === 'author') {
53+
setRole('author');
54+
} else if (type === 'reviewer') {
55+
setRole('reviewer');
56+
} else if (type === 'creator') {
57+
setRole('creator');
58+
}
59+
}
5160
if (signatures && type) {
5261
if (type === 'author') {
5362
setUserSignature(signatures.authorSignature);
54-
setRole('author');
5563
} else if (type === 'reviewer') {
5664
setUserSignature(signatures.reviewerSignature);
57-
setRole('reviewer');
5865
} else if (type === 'creator') {
5966
setUserSignature(signatures.creatorSignature);
60-
setRole('bioinformatician');
6167
}
6268
}
6369
}, [signatures, type, setRole]);
6470

6571
const handleSign = useCallback(async () => {
6672
let newReport = null;
6773

74+
let reportRole = role;
6875
// Assign user
6976
try {
77+
if (role === 'creator') {
78+
reportRole = 'bioinformatician';
79+
} else if (role === 'author') {
80+
// Hardcode analyst role here because report does not accept 'author'
81+
reportRole = 'analyst';
82+
}
7083
newReport = await api.post(
7184
`/reports/${report.ident}/user`,
72-
// Hardcode analyst role here because report does not accept 'author'
73-
{ user: userDetails.ident, role: 'analyst' },
85+
{ user: userDetails.ident, role: reportRole },
7486
{},
7587
).request();
7688
} catch (e) {
@@ -79,7 +91,6 @@ const SignatureCard = ({
7991
snackbar.error('Error assigning user to report: ', e.message);
8092
}
8193
}
82-
8394
// Do signature
8495
try {
8596
const newSignature = await api.put(
@@ -198,9 +209,9 @@ const SignatureCard = ({
198209
Date
199210
</Typography>
200211
{renderDate ?? (
201-
<Typography>
202-
{NON_BREAKING_SPACE}
203-
</Typography>
212+
<Typography>
213+
{NON_BREAKING_SPACE}
214+
</Typography>
204215
)}
205216
</div>
206217
{userSignature?.ident && canEdit && (

app/context/ResourceContext/index.tsx

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const useResources = (): ResourceContextType => {
4242
*/
4343
const [reportAssignmentAccess, setReportAssignmentAccess] = useState(false);
4444
const [adminAccess, setAdminAccess] = useState(false);
45+
const [allProjectsAccess, setAllProjectsAccess] = useState(false);
4546
const [managerAccess, setManagerAccess] = useState(false);
4647
/**
4748
* Is the user allowed to see the settings page
@@ -67,6 +68,10 @@ const useResources = (): ResourceContextType => {
6768
setAdminAccess(true);
6869
}
6970

71+
if (checkAccess(groups, [...ADMIN_ACCESS, 'all projects access'], ADMIN_BLOCK)) {
72+
setAllProjectsAccess(true);
73+
}
74+
7075
if (checkAccess(groups, [...ADMIN_ACCESS, 'manager'], ADMIN_BLOCK)) {
7176
setManagerAccess(true);
7277
}
@@ -99,38 +104,40 @@ const useResources = (): ResourceContextType => {
99104
}, [groups]);
100105

101106
return {
102-
germlineAccess,
103-
reportsAccess,
104107
adminAccess,
108+
allProjectsAccess,
109+
allStates: ALL_STATES,
110+
appendixEditAccess,
111+
germlineAccess,
105112
managerAccess,
106-
reportSettingAccess,
107-
reportEditAccess,
108-
reportAssignmentAccess,
109-
unreviewedAccess,
110113
nonproductionAccess,
114+
nonproductionStates: NONPRODUCTION_STATES,
115+
reportAssignmentAccess,
116+
reportEditAccess,
117+
reportSettingAccess,
118+
reportsAccess,
111119
templateEditAccess,
112-
appendixEditAccess,
113-
allStates: ALL_STATES,
120+
unreviewedAccess,
114121
unreviewedStates: UNREVIEWED_STATES,
115-
nonproductionStates: NONPRODUCTION_STATES,
116122
};
117123
};
118124

119125
const ResourceContext = createContext<ResourceContextType>({
120-
germlineAccess: false,
121-
reportsAccess: false,
122126
adminAccess: false,
127+
allProjectsAccess: false,
128+
allStates: ALL_STATES,
129+
appendixEditAccess: false,
130+
germlineAccess: false,
123131
managerAccess: false,
124-
reportSettingAccess: false,
125-
reportEditAccess: false,
126-
reportAssignmentAccess: false,
127-
unreviewedAccess: false,
128132
nonproductionAccess: false,
133+
nonproductionStates: NONPRODUCTION_STATES,
134+
reportAssignmentAccess: false,
135+
reportEditAccess: false,
136+
reportSettingAccess: false,
137+
reportsAccess: false,
129138
templateEditAccess: false,
130-
appendixEditAccess: false,
131-
allStates: ALL_STATES,
139+
unreviewedAccess: false,
132140
unreviewedStates: UNREVIEWED_STATES,
133-
nonproductionStates: NONPRODUCTION_STATES,
134141
});
135142

136143
type ResourceContextProviderProps = {
@@ -139,44 +146,55 @@ type ResourceContextProviderProps = {
139146

140147
const ResourceContextProvider = ({ children }: ResourceContextProviderProps): JSX.Element => {
141148
const {
142-
germlineAccess, reportsAccess, adminAccess, managerAccess, reportSettingAccess, reportEditAccess, reportAssignmentAccess, unreviewedAccess, nonproductionAccess,
143-
templateEditAccess,
144-
appendixEditAccess,
149+
adminAccess,
150+
allProjectsAccess,
145151
allStates,
146-
unreviewedStates,
152+
appendixEditAccess,
153+
germlineAccess,
154+
managerAccess,
155+
nonproductionAccess,
147156
nonproductionStates,
157+
reportAssignmentAccess,
158+
reportEditAccess,
159+
reportSettingAccess,
160+
reportsAccess,
161+
templateEditAccess,
162+
unreviewedAccess,
163+
unreviewedStates,
148164
} = useResources();
149165

150166
const providerValue = useMemo(() => ({
151-
germlineAccess,
152-
reportsAccess,
153167
adminAccess,
168+
allProjectsAccess,
169+
allStates,
170+
appendixEditAccess,
171+
germlineAccess,
154172
managerAccess,
155-
reportSettingAccess,
156-
reportEditAccess,
157-
reportAssignmentAccess,
158-
unreviewedAccess,
159173
nonproductionAccess,
174+
nonproductionStates,
175+
reportAssignmentAccess,
176+
reportEditAccess,
177+
reportSettingAccess,
178+
reportsAccess,
160179
templateEditAccess,
161-
appendixEditAccess,
162-
allStates,
180+
unreviewedAccess,
163181
unreviewedStates,
164-
nonproductionStates,
165182
}), [
166-
germlineAccess,
167-
reportsAccess,
168183
adminAccess,
184+
allProjectsAccess,
185+
allStates,
186+
appendixEditAccess,
187+
germlineAccess,
169188
managerAccess,
170-
reportSettingAccess,
171-
reportEditAccess,
172-
reportAssignmentAccess,
173-
unreviewedAccess,
174189
nonproductionAccess,
190+
nonproductionStates,
191+
reportAssignmentAccess,
192+
reportEditAccess,
193+
reportSettingAccess,
194+
reportsAccess,
175195
templateEditAccess,
176-
appendixEditAccess,
177-
allStates,
196+
unreviewedAccess,
178197
unreviewedStates,
179-
nonproductionStates,
180198
]);
181199

182200
return (
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
type ResourceContextType = {
2-
germlineAccess: boolean;
3-
reportsAccess: boolean;
42
adminAccess: boolean;
5-
managerAccess: boolean;
6-
templateEditAccess: boolean;
3+
allStates: string[];
4+
allProjectsAccess: boolean;
75
appendixEditAccess: boolean;
8-
reportSettingAccess: boolean;
9-
reportEditAccess: boolean;
6+
germlineAccess: boolean;
7+
managerAccess: boolean;
8+
nonproductionAccess: boolean;
9+
nonproductionStates: string[];
1010
reportAssignmentAccess: boolean;
11+
reportEditAccess: boolean;
12+
reportSettingAccess: boolean;
13+
reportsAccess: boolean;
14+
templateEditAccess: boolean;
1115
unreviewedAccess: boolean;
12-
nonproductionAccess: boolean;
13-
allStates: string[];
1416
unreviewedStates: string[];
15-
nonproductionStates: string[];
1617
};
1718

1819
export default ResourceContextType;

0 commit comments

Comments
 (0)