Skip to content

Commit 6875165

Browse files
fix: now content unavailable ui is only for learner (#672)
Co-authored-by: Awais Ansari <[email protected]>
1 parent 8fc6665 commit 6875165

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

src/components/NavigationBar/data/slice.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const slice = createSlice({
1313
tabs: [],
1414
courseTitle: null,
1515
courseNumber: null,
16+
isEnrolled: false,
1617
org: null,
1718
},
1819
reducers: {

src/discussions/data/selectors.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { createSelector } from '@reduxjs/toolkit';
2+
13
import { PostsStatusFilter, ThreadType } from '../../data/constants';
24

35
export const selectAnonymousPostingConfig = state => ({
@@ -60,3 +62,24 @@ export function selectTopicThreadCount(topicId) {
6062
export function selectPostThreadCount(state) {
6163
return state.threads.totalThreads;
6264
}
65+
66+
export const selectIsUserLearner = createSelector(
67+
selectUserHasModerationPrivileges,
68+
selectUserIsGroupTa,
69+
selectUserIsStaff,
70+
selectIsCourseAdmin,
71+
selectIsCourseStaff,
72+
(
73+
userHasModerationPrivileges,
74+
userIsGroupTa,
75+
userIsStaff,
76+
userIsCourseAdmin,
77+
userIsCourseStaff,
78+
) => (
79+
!userHasModerationPrivileges
80+
&& !userIsGroupTa
81+
&& !userIsStaff
82+
&& !userIsCourseAdmin
83+
&& !userIsCourseStaff
84+
),
85+
);

src/discussions/discussions-home/DiscussionsHome.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import { LearningHeader as Header } from '@edx/frontend-component-header';
1212

1313
import { Spinner } from '../../components';
1414
import selectCourseTabs from '../../components/NavigationBar/data/selectors';
15-
import { LOADED } from '../../components/NavigationBar/data/slice';
15+
import { LOADING } from '../../components/NavigationBar/data/slice';
1616
import { ALL_ROUTES, DiscussionProvider, Routes as ROUTES } from '../../data/constants';
1717
import DiscussionContext from '../common/context';
1818
import ContentUnavailable from '../course-content-unavailable/CourseContentUnavailable';
1919
import {
2020
useCourseDiscussionData, useIsOnDesktop, useRedirectToThread, useSidebarVisible,
2121
} from '../data/hooks';
22-
import { selectDiscussionProvider, selectEnableInContext } from '../data/selectors';
22+
import { selectDiscussionProvider, selectEnableInContext, selectIsUserLearner } from '../data/selectors';
2323
import { EmptyLearners, EmptyTopics } from '../empty-posts';
2424
import EmptyPosts from '../empty-posts/EmptyPosts';
2525
import { EmptyTopic as InContextEmptyTopics } from '../in-context-topics/components';
@@ -46,6 +46,7 @@ const DiscussionsHome = () => {
4646
const {
4747
courseNumber, courseTitle, org, courseStatus, isEnrolled,
4848
} = useSelector(selectCourseTabs);
49+
const isUserLearner = useSelector(selectIsUserLearner);
4950
const pageParams = useMatch(ROUTES.COMMENTS.PAGE)?.params;
5051
const page = pageParams?.page || null;
5152
const matchPattern = ALL_ROUTES.find((route) => matchPath({ path: route }, location.pathname));
@@ -84,7 +85,7 @@ const DiscussionsHome = () => {
8485
)}
8586
<main className="container-fluid d-flex flex-column p-0 w-100" id="main" tabIndex="-1">
8687
{!enableInContextSidebar && <CourseTabsNavigation activeTab="discussion" courseId={courseId} />}
87-
{(isEnrolled || enableInContextSidebar) && (
88+
{(isEnrolled || !isUserLearner || enableInContextSidebar) && (
8889
<div
8990
className={classNames('header-action-bar bg-white position-sticky', {
9091
'shadow-none border-light-300 border-bottom': enableInContextSidebar,
@@ -125,9 +126,9 @@ const DiscussionsHome = () => {
125126
</Routes>
126127
</Suspense>
127128
)}
128-
{(courseStatus === LOADED || enableInContextSidebar) && (
129+
{(courseStatus !== LOADING || enableInContextSidebar) && (
129130
<div>
130-
{ isEnrolled === false ? (
131+
{ isEnrolled === false && isUserLearner ? (
131132
<Suspense fallback={(<Spinner />)}>
132133
<Routes>
133134
{ALL_ROUTES.map((route) => (

0 commit comments

Comments
 (0)