diff --git a/src/discussions/data/selectors.js b/src/discussions/data/selectors.js index 3fab39e9e..5e0474d53 100644 --- a/src/discussions/data/selectors.js +++ b/src/discussions/data/selectors.js @@ -31,6 +31,8 @@ export const selectEnableInContext = state => state.config.enableInContext; export const selectIsPostingEnabled = state => state.config.isPostingEnabled; +export const selectIsNotifyAllLearnersEnabled = state => state.config.isNotifyAllLearnersEnabled; + export const selectModerationSettings = state => ({ postCloseReasons: state.config.postCloseReasons, editReasons: state.config.editReasons, diff --git a/src/discussions/posts/data/api.js b/src/discussions/posts/data/api.js index 6b530adec..d0b927d7f 100644 --- a/src/discussions/posts/data/api.js +++ b/src/discussions/posts/data/api.js @@ -98,6 +98,7 @@ export const postThread = async ( cohort, anonymous, anonymousToPeers, + notifyAllLearners, } = {}, enableInContextSidebar = false, ) => { @@ -112,6 +113,7 @@ export const postThread = async ( anonymousToPeers, groupId: cohort, enableInContextSidebar, + notifyAllLearners, }); const { data } = await getAuthenticatedHttpClient() .post(getThreadsApiUrl(), postData); diff --git a/src/discussions/posts/data/thunks.js b/src/discussions/posts/data/thunks.js index 7276dd1d3..561f1485c 100644 --- a/src/discussions/posts/data/thunks.js +++ b/src/discussions/posts/data/thunks.js @@ -204,6 +204,7 @@ export function createNewThread({ anonymousToPeers, cohort, enableInContextSidebar, + notifyAllLearners, }) { return async (dispatch) => { try { @@ -217,12 +218,14 @@ export function createNewThread({ anonymous, anonymousToPeers, cohort, + notifyAllLearners, })); const data = await postThread(courseId, topicId, type, title, content, { cohort, following, anonymous, anonymousToPeers, + notifyAllLearners, }, enableInContextSidebar); dispatch(postThreadSuccess(camelCaseObject(data))); } catch (error) { diff --git a/src/discussions/posts/post-editor/PostEditor.jsx b/src/discussions/posts/post-editor/PostEditor.jsx index a2f57959c..f6713907e 100644 --- a/src/discussions/posts/post-editor/PostEditor.jsx +++ b/src/discussions/posts/post-editor/PostEditor.jsx @@ -29,6 +29,7 @@ import { selectAnonymousPostingConfig, selectDivisionSettings, selectEnableInContext, + selectIsNotifyAllLearnersEnabled, selectModerationSettings, selectUserHasModerationPrivileges, selectUserIsGroupTa, @@ -79,6 +80,7 @@ const PostEditor = ({ const userIsStaff = useSelector(selectUserIsStaff); const archivedTopics = useSelector(selectArchivedTopics); const postEditorId = `post-editor-${editExisting ? postId : 'new'}`; + const isNotifyAllLearnersEnabled = useSelector(selectIsNotifyAllLearnersEnabled); const canDisplayEditReason = (editExisting && (userHasModerationPrivileges || userIsGroupTa || userIsStaff) @@ -108,6 +110,7 @@ const PostEditor = ({ title: post?.title || '', comment: post?.rawBody || '', follow: isEmpty(post?.following) ? true : post?.following, + notifyAllLearners: false, anonymous: allowAnonymous ? false : undefined, anonymousToPeers: allowAnonymousToPeers ? false : undefined, cohort: post?.cohort || 'default', @@ -161,6 +164,7 @@ const PostEditor = ({ anonymousToPeers: allowAnonymousToPeers ? values.anonymousToPeers : undefined, cohort, enableInContextSidebar, + notifyAllLearners: values.notifyAllLearners, })); } /* istanbul ignore if: TinyMCE is mocked so this cannot be easily tested */ @@ -216,6 +220,8 @@ const PostEditor = ({ anonymousToPeers: Yup.bool() .default(false) .nullable(), + notifyAllLearners: Yup.bool() + .default(false), cohort: Yup.string() .nullable() .default(null), @@ -417,6 +423,21 @@ const PostEditor = ({