fix: hide discussions sidebar and trigger icon when unit does not exist or enableInContext is false. (#1039)
* fix: removed nonCourseWare topics from topics * fix: hide discussions sidebar and trigger icon when enableInContext is false
This commit is contained in:
@@ -16,10 +16,12 @@ function DiscussionsSidebar({ intl }) {
|
||||
courseId,
|
||||
} = useContext(SidebarContext);
|
||||
const topic = useModel('discussionTopics', unitId);
|
||||
if (!topic?.id) {
|
||||
const discussionsUrl = `${getConfig().DISCUSSIONS_MFE_BASE_URL}/${courseId}/category/${unitId}`;
|
||||
|
||||
if (!topic?.id || !topic?.enabledInContext) {
|
||||
return null;
|
||||
}
|
||||
const discussionsUrl = `${getConfig().DISCUSSIONS_MFE_BASE_URL}/${courseId}/category/${unitId}`;
|
||||
|
||||
return (
|
||||
<SidebarBase
|
||||
title={intl.formatMessage(messages.discussionsTitle)}
|
||||
|
||||
@@ -32,9 +32,11 @@ function DiscussionsTrigger({
|
||||
dispatch(getCourseDiscussionTopics(courseId));
|
||||
}
|
||||
}, [courseId, baseUrl]);
|
||||
if (!topic.id) {
|
||||
|
||||
if (!topic?.id || !topic?.enabledInContext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<SidebarTriggerBase onClick={onClick} ariaLabel={intl.formatMessage(messages.openDiscussionsTrigger)}>
|
||||
<Icon src={QuestionAnswer} className="m-0 m-auto" />
|
||||
|
||||
@@ -242,7 +242,7 @@ export function getCourseDiscussionTopics(courseId) {
|
||||
const topics = await getCourseTopics(courseId);
|
||||
dispatch(updateModels({
|
||||
modelType: 'discussionTopics',
|
||||
models: topics,
|
||||
models: topics.filter(topic => topic.usageKey),
|
||||
idField: 'usageKey',
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user