Skip to content

Commit 5b5356c

Browse files
authored
Merge pull request #1295 from ferishili/issue-1290
Series and events permissions override enhancement
2 parents e0beee5 + bacdfec commit 5b5356c

5 files changed

Lines changed: 29 additions & 6 deletions

File tree

src/components/events/partials/ModalTabsAndPages/SeriesDetailsAccessTab.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {
88
import { removeNotificationWizardForm } from "../../../../slices/notificationSlice";
99
import { useAppDispatch, useAppSelector } from "../../../../store";
1010
import { ParseKeys } from "i18next";
11+
import {
12+
getOrgProperties,
13+
} from "../../../../selectors/userInfoSelectors";
1114

1215
/**
1316
* This component manages the access policy tab of the series details modal
@@ -28,6 +31,9 @@ const SeriesDetailsAccessTab = ({
2831
const policies = useAppSelector(state => getSeriesDetailsAcl(state));
2932
const policyTemplateId = useAppSelector(state => getPolicyTemplateId(state));
3033

34+
const orgProperties = useAppSelector(state => getOrgProperties(state));
35+
const overrideEnabled = (orgProperties["admin.series.acl.event.update.mode"] || "optional").toLowerCase() === "optional";
36+
3137
useEffect(() => {
3238
dispatch(removeNotificationWizardForm());
3339
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -54,7 +60,7 @@ const SeriesDetailsAccessTab = ({
5460
viewNonUsersAccessRole={"ROLE_UI_SERIES_DETAILS_ACL_NONUSER_ROLES_VIEW"}
5561
policyChanged={policyChanged}
5662
setPolicyChanged={setPolicyChanged}
57-
withOverrideButton={true}
63+
withOverrideButton={overrideEnabled}
5864
/>
5965
);
6066
};

src/components/shared/SaveEditFooter.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type SaveEditFooterProps = {
88
reset: () => void;
99
submit: () => void;
1010
isValid?: boolean;
11+
customSaveButtonText?: ParseKeys;
1112
additionalButton?: {
1213
label: ParseKeys,
1314
hint: ParseKeys,
@@ -20,10 +21,13 @@ export const SaveEditFooter: React.FC<SaveEditFooterProps> = ({
2021
reset,
2122
submit,
2223
isValid,
24+
customSaveButtonText,
2325
additionalButton,
2426
}) => {
2527
const { t } = useTranslation();
2628

29+
const saveButtonText = customSaveButtonText || "SAVE";
30+
2731
return <footer style={{ padding: "0 15px" }}>
2832
{active && isValid && (
2933
<div className="pull-left">
@@ -56,7 +60,7 @@ export const SaveEditFooter: React.FC<SaveEditFooterProps> = ({
5660
className={`save green ${
5761
!isValid || !active ? "disabled" : ""
5862
}`}
59-
>{t("SAVE")}</BaseButton>
63+
>{t(saveButtonText)}</BaseButton>
6064
</div>
6165
</footer>;
6266
};

src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ const ResourceDetailsAccessPolicyTab = ({
376376
hint: "EVENTS.SERIES.DETAILS.ACCESS.ACCESS_POLICY.REPLACE_EVENT_ACLS_HINT",
377377
onClick: () => saveAccess(formik.values, true),
378378
} : undefined}
379+
customSaveButtonText={withOverrideButton ? "EVENTS.SERIES.DETAILS.ACCESS.ACCESS_POLICY.SAVE_SERIES_ACL_ONLY" : undefined}
379380
/>}
380381
</div>
381382
)}

src/i18n/org/opencastproject/adminui/languages/lang-en_US.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,12 +1225,14 @@
12251225
"ADDITIONAL_ACTIONS": "Additional Actions",
12261226
"ACTION": "Actions",
12271227
"NEW": "New policy",
1228+
"DETAILS": "Details",
1229+
"REPLACE_EVENT_ACLS": "Save series and overwrite event permissions",
1230+
"REPLACE_EVENT_ACLS_HINT": "Save the series permissions and overwrite the permissions for all events in this series.",
1231+
"SAVE_SERIES_ACL_ONLY": "Save series permission",
12281232
"NON_USER_ROLES": "Roles and Groups authorized for the series",
12291233
"USER": "User",
12301234
"USERS": "Users who are authorized for the series",
12311235
"NEW_USER": "New user",
1232-
"REPLACE_EVENT_ACLS": "Update series permissions",
1233-
"REPLACE_EVENT_ACLS_HINT": "Ensure all events of this series have these permissions in effect",
12341236
"LOAD_MORE_LIMIT": "policies shown.",
12351237
"LOAD_MORE_LINK": "Load more"
12361238
},

src/slices/seriesDetailsSlice.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {
55
getSeriesDetailsExtendedMetadata,
66
getStatistics,
77
} from "../selectors/seriesDetailsSelectors";
8+
import {
9+
getOrgProperties,
10+
} from "../selectors/userInfoSelectors";
811
import { addNotification } from "./notificationSlice";
912
import {
1013
transformMetadataCollection,
@@ -258,12 +261,19 @@ export const updateSeriesAccess = createAppAsyncThunk("seriesDetails/updateSerie
258261
id: Series["id"],
259262
policies: { acl: Acl },
260263
override?: boolean
261-
}, { dispatch }) => {
264+
}, { dispatch, getState }) => {
262265
const { id, policies, override } = params;
263266

264267
const data = new URLSearchParams();
265268

266-
const overrideString = override ? String(true) : String(false);
269+
// Here we should check for the "always" option as well, so that we can force override!
270+
const orgProperties = getOrgProperties(getState());
271+
const alwaysOverride = (orgProperties["admin.series.acl.event.update.mode"] || "optional").toLowerCase() === "always";
272+
273+
let overrideString = override ? String(true) : String(false);
274+
if (alwaysOverride) {
275+
overrideString = String(true);
276+
}
267277

268278
data.append("acl", JSON.stringify(policies));
269279
data.append("override", overrideString);

0 commit comments

Comments
 (0)