Commit 4de017a2 authored by Martin Lowe's avatar Martin Lowe 🇨🇦
Browse files

Merge branch 'zhoufang/dev/483' into 'dev'

#483 Added permission check for committers and contributors API calls

See merge request !560
parents 311eec48 a77632f0
Pipeline #3092 passed with stage
in 0 seconds
......@@ -157,7 +157,14 @@ export default function DashboardCommittersAndContributors() {
} = useContext(PortalContext);
const open = Boolean(anchorEle);
const canViewCommiters = checkPermission(PERMISSIONS_BASED_ON_ROLES.viewCommitters, currentUserPortal?.relation);
const canViewContributors = checkPermission(PERMISSIONS_BASED_ON_ROLES.viewContributors, currentUserPortal?.relation);
useEffect(() => {
if (!canViewCommiters) {
return;
}
if (!orgId || committers !== null) {
committers !== null && setIsFetchingCommitters(false);
return;
......@@ -188,9 +195,13 @@ export default function DashboardCommittersAndContributors() {
};
fetchWrapper(urlForCommitters, FETCH_METHOD.GET, saveCommittersData, '', () => setIsFetchingCommitters(false));
}, [orgId, committers, setCommitters]);
}, [orgId, committers, setCommitters, canViewCommiters]);
useEffect(() => {
if (!canViewContributors) {
return;
}
if (!orgId || contributors !== null) {
contributors !== null && setIsFetchingContributors(false);
return;
......@@ -224,7 +235,7 @@ export default function DashboardCommittersAndContributors() {
fetchWrapper(urlForContributors, FETCH_METHOD.GET, saveContributorsData, '', () =>
setIsFetchingContributors(false)
);
}, [orgId, contributors, setContributors]);
}, [orgId, contributors, setContributors, canViewContributors]);
useEffect(() => {
if (!orgId || cbiData !== null) {
......@@ -252,9 +263,6 @@ export default function DashboardCommittersAndContributors() {
fetchWrapper(urlForCBIData, FETCH_METHOD.GET, saveCBIData, '', () => setIsFetchingCBI(false));
}, [orgId, cbiData, setCBIData]);
const canViewCommiters = checkPermission(PERMISSIONS_BASED_ON_ROLES.viewCommitters, currentUserPortal?.relation);
const canViewContributors = checkPermission(PERMISSIONS_BASED_ON_ROLES.viewContributors, currentUserPortal?.relation);
return (
<SectionCtn title="Committers and Contributors" id="committers-contributors">
<Grid container spacing={4}>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment