Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect config option for adding series ACL to new event #321

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Overwrite new event ACL with series ACL
Previously we were combining existing roles
with the series roles. But apparently the series
roles should just overwrite all other roles.
This changes it to that.
Arnei committed Apr 11, 2024
commit 0f225f798244d4a88132fce8882fddeac0521cb3
Original file line number Diff line number Diff line change
@@ -67,28 +67,18 @@ const NewAccessPage = ({
fetchData();
}, []);

// If we have to add series ACL, fetch it
// If we have to use series ACL, fetch it
useEffect(() => {
if (initEventAclWithSeriesAcl && formik.values.isPartOf) {
dispatch(fetchSeriesDetailsAcls(formik.values.isPartOf))
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [formik.values, initEventAclWithSeriesAcl]);

// If we have to add series ACL, add it
// If we have to use series ACL, overwrite existing rules
useEffect(() => {
if (initEventAclWithSeriesAcl && formik.values.isPartOf && seriesAcl) {
let rolesToAdd = []
for (const ace of seriesAcl) {
// @ts-expect-error TS(2345):
if (!formik.values.acls.some(acl => acl.role === ace.role)) {
rolesToAdd.push(ace)
}
}

if (rolesToAdd.length > 0) {
formik.setFieldValue("acls", [ ...formik.values.acls, ...rolesToAdd ])
}
formik.setFieldValue("acls", seriesAcl)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [initEventAclWithSeriesAcl, seriesAcl]);