Skip to content

Series and events permissions override enhancement #1295

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

Open
wants to merge 1 commit into
base: r/17.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
import { removeNotificationWizardForm } from "../../../../slices/notificationSlice";
import { useAppDispatch, useAppSelector } from "../../../../store";
import { ParseKeys } from "i18next";
import {
getOrgProperties,
} from "../../../../selectors/userInfoSelectors";

/**
* This component manages the access policy tab of the series details modal
Expand All @@ -29,6 +32,10 @@ const SeriesDetailsAccessTab = ({

const policies = useAppSelector(state => getSeriesDetailsAcl(state));

const orgProperties = useAppSelector(state => getOrgProperties(state));

const overrideEnabled = (orgProperties['admin.series.acl.event.update.mode'] || 'optional').toLowerCase() === 'optional';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't there supposed to be three modes, always, never and optional? Can that really be represented with a boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right!
in this place to check and offer the button if it is optional is correct.
what is missing is to make sure that never & always are also in the play!


useEffect(() => {
dispatch(removeNotificationWizardForm());
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand All @@ -46,7 +53,7 @@ const SeriesDetailsAccessTab = ({
editAccessRole={"ROLE_UI_SERIES_DETAILS_ACL_EDIT"}
policyChanged={policyChanged}
setPolicyChanged={setPolicyChanged}
withOverrideButton={true}
withOverrideButton={overrideEnabled}
/>
);
};
Expand Down
8 changes: 6 additions & 2 deletions src/components/shared/SaveEditFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type SaveEditFooterProps = {
reset: () => void;
submit: () => void;
isValid?: boolean;
customSaveButtonText?: ParseKeys;
additionalButton?: {
label: ParseKeys,
hint: ParseKeys,
Expand All @@ -20,10 +21,13 @@ export const SaveEditFooter: React.FC<SaveEditFooterProps> = ({
reset,
submit,
isValid,
additionalButton
customSaveButtonText,
additionalButton,
}) => {
const { t } = useTranslation();

const saveButtonText = customSaveButtonText || "SAVE";

return <footer style={{ padding: "0 15px" }}>
{active && isValid && (
<div className="pull-left">
Expand Down Expand Up @@ -56,7 +60,7 @@ export const SaveEditFooter: React.FC<SaveEditFooterProps> = ({
className={`save green ${
!isValid || !active ? "disabled" : ""
}`}
>{t("SAVE")}</BaseButton>
>{t(saveButtonText)}</BaseButton>
</div>
</footer>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ const ResourceDetailsAccessPolicyTab = ({
hint: "EVENTS.SERIES.DETAILS.ACCESS.ACCESS_POLICY.REPLACE_EVENT_ACLS_HINT",
onClick: () => saveAccess(formik.values, true)
} : undefined}
customSaveButtonText={withOverrideButton ? "EVENTS.SERIES.DETAILS.ACCESS.ACCESS_POLICY.SAVE_SERIES_ACL_ONLY" : undefined}
/>}
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,9 @@
"ACTION": "Actions",
"NEW": "New policy",
"DETAILS": "Details",
"REPLACE_EVENT_ACLS": "Update series permissions",
"REPLACE_EVENT_ACLS_HINT": "Ensure all events of this series have these permissions in effect",
"REPLACE_EVENT_ACLS": "Save series and overwrite event permissions",
"REPLACE_EVENT_ACLS_HINT": "Save the series permissions and overwrite the permissions for all events in this series.",
"SAVE_SERIES_ACL_ONLY": "Save series permission",
"LOAD_MORE_LIMIT": "policies shown.",
"LOAD_MORE_LINK": "Load more"
},
Expand Down