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() { ...@@ -157,7 +157,14 @@ export default function DashboardCommittersAndContributors() {
} = useContext(PortalContext); } = useContext(PortalContext);
const open = Boolean(anchorEle); 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(() => { useEffect(() => {
if (!canViewCommiters) {
return;
}
if (!orgId || committers !== null) { if (!orgId || committers !== null) {
committers !== null && setIsFetchingCommitters(false); committers !== null && setIsFetchingCommitters(false);
return; return;
...@@ -188,9 +195,13 @@ export default function DashboardCommittersAndContributors() { ...@@ -188,9 +195,13 @@ export default function DashboardCommittersAndContributors() {
}; };
fetchWrapper(urlForCommitters, FETCH_METHOD.GET, saveCommittersData, '', () => setIsFetchingCommitters(false)); fetchWrapper(urlForCommitters, FETCH_METHOD.GET, saveCommittersData, '', () => setIsFetchingCommitters(false));
}, [orgId, committers, setCommitters]); }, [orgId, committers, setCommitters, canViewCommiters]);
useEffect(() => { useEffect(() => {
if (!canViewContributors) {
return;
}
if (!orgId || contributors !== null) { if (!orgId || contributors !== null) {
contributors !== null && setIsFetchingContributors(false); contributors !== null && setIsFetchingContributors(false);
return; return;
...@@ -224,7 +235,7 @@ export default function DashboardCommittersAndContributors() { ...@@ -224,7 +235,7 @@ export default function DashboardCommittersAndContributors() {
fetchWrapper(urlForContributors, FETCH_METHOD.GET, saveContributorsData, '', () => fetchWrapper(urlForContributors, FETCH_METHOD.GET, saveContributorsData, '', () =>
setIsFetchingContributors(false) setIsFetchingContributors(false)
); );
}, [orgId, contributors, setContributors]); }, [orgId, contributors, setContributors, canViewContributors]);
useEffect(() => { useEffect(() => {
if (!orgId || cbiData !== null) { if (!orgId || cbiData !== null) {
...@@ -252,9 +263,6 @@ export default function DashboardCommittersAndContributors() { ...@@ -252,9 +263,6 @@ export default function DashboardCommittersAndContributors() {
fetchWrapper(urlForCBIData, FETCH_METHOD.GET, saveCBIData, '', () => setIsFetchingCBI(false)); fetchWrapper(urlForCBIData, FETCH_METHOD.GET, saveCBIData, '', () => setIsFetchingCBI(false));
}, [orgId, cbiData, setCBIData]); }, [orgId, cbiData, setCBIData]);
const canViewCommiters = checkPermission(PERMISSIONS_BASED_ON_ROLES.viewCommitters, currentUserPortal?.relation);
const canViewContributors = checkPermission(PERMISSIONS_BASED_ON_ROLES.viewContributors, currentUserPortal?.relation);
return ( return (
<SectionCtn title="Committers and Contributors" id="committers-contributors"> <SectionCtn title="Committers and Contributors" id="committers-contributors">
<Grid container spacing={4}> <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