feat: [FC-0044] Unit page - Manage access modal (unit & xblocks) (#901)
* feat: [FC-0044] Unit page - Manage access modal (unit & xblocks) * fix: add message description
This commit is contained in:
@@ -88,14 +88,16 @@ export async function createCourseXblock({
|
||||
* @param {string} unitId - The ID of the course unit.
|
||||
* @param {string} type - The action type (e.g., PUBLISH_TYPES.discardChanges).
|
||||
* @param {boolean} isVisible - The visibility status for students.
|
||||
* @param {boolean} groupAccess - Access group key set.
|
||||
* @returns {Promise<any>} A promise that resolves with the response data.
|
||||
*/
|
||||
export async function handleCourseUnitVisibilityAndData(unitId, type, isVisible) {
|
||||
export async function handleCourseUnitVisibilityAndData(unitId, type, isVisible, groupAccess) {
|
||||
const body = {
|
||||
publish: type,
|
||||
publish: groupAccess ? null : type,
|
||||
...(type === PUBLISH_TYPES.republish ? {
|
||||
metadata: {
|
||||
visible_to_staff_only: isVisible,
|
||||
visible_to_staff_only: isVisible ? true : null,
|
||||
group_access: groupAccess || null,
|
||||
},
|
||||
} : {}),
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ const slice = createSlice({
|
||||
},
|
||||
unit: {},
|
||||
courseSectionVertical: {},
|
||||
courseVerticalChildren: [],
|
||||
courseVerticalChildren: {},
|
||||
},
|
||||
reducers: {
|
||||
fetchCourseItemSuccess: (state, { payload }) => {
|
||||
|
||||
@@ -111,19 +111,19 @@ export function editCourseItemQuery(itemId, displayName, sequenceId) {
|
||||
};
|
||||
}
|
||||
|
||||
export function editCourseUnitVisibilityAndData(itemId, type, isVisible) {
|
||||
export function editCourseUnitVisibilityAndData(itemId, type, isVisible, groupAccess, isModalView, blockId = itemId) {
|
||||
return async (dispatch) => {
|
||||
dispatch(updateSavingStatus({ status: RequestStatus.PENDING }));
|
||||
dispatch(updateQueryPendingStatus(true));
|
||||
const notificationMessage = getNotificationMessage(type, isVisible);
|
||||
dispatch(showProcessingNotification(notificationMessage));
|
||||
const notification = getNotificationMessage(type, isVisible, isModalView);
|
||||
dispatch(showProcessingNotification(notification));
|
||||
|
||||
try {
|
||||
await handleCourseUnitVisibilityAndData(itemId, type, isVisible).then(async (result) => {
|
||||
await handleCourseUnitVisibilityAndData(itemId, type, isVisible, groupAccess).then(async (result) => {
|
||||
if (result) {
|
||||
const courseUnit = await getCourseUnitData(itemId);
|
||||
const courseUnit = await getCourseUnitData(blockId);
|
||||
dispatch(fetchCourseItemSuccess(courseUnit));
|
||||
const courseVerticalChildrenData = await getCourseVerticalChildren(itemId);
|
||||
const courseVerticalChildrenData = await getCourseVerticalChildren(blockId);
|
||||
dispatch(updateCourseVerticalChildren(courseVerticalChildrenData));
|
||||
dispatch(hideProcessingNotification());
|
||||
dispatch(updateSavingStatus({ status: RequestStatus.SUCCESSFUL }));
|
||||
|
||||
@@ -30,15 +30,18 @@ export function normalizeCourseSectionVerticalData(metadata) {
|
||||
* Get the notification message based on the publishing type and visibility.
|
||||
* @param {string} type - The publishing type.
|
||||
* @param {boolean} isVisible - The visibility status.
|
||||
* @param {boolean} isModalView - The modal view status.
|
||||
* @returns {string} The corresponding notification message.
|
||||
*/
|
||||
export const getNotificationMessage = (type, isVisible) => {
|
||||
export const getNotificationMessage = (type, isVisible, isModalView) => {
|
||||
let notificationMessage;
|
||||
|
||||
if (type === PUBLISH_TYPES.discardChanges) {
|
||||
notificationMessage = NOTIFICATION_MESSAGES.discardChanges;
|
||||
} else if (type === PUBLISH_TYPES.makePublic) {
|
||||
notificationMessage = NOTIFICATION_MESSAGES.publishing;
|
||||
} else if (type === PUBLISH_TYPES.republish && isModalView) {
|
||||
notificationMessage = NOTIFICATION_MESSAGES.saving;
|
||||
} else if (type === PUBLISH_TYPES.republish && !isVisible) {
|
||||
notificationMessage = NOTIFICATION_MESSAGES.makingVisibleToStudents;
|
||||
} else if (type === PUBLISH_TYPES.republish && isVisible) {
|
||||
|
||||
Reference in New Issue
Block a user