Skip to content

Commit ee61d1c

Browse files
authored
chore: removed enable_learners_tab_in_discussions_mfe flag dependency (#637)
1 parent 9e95458 commit ee61d1c

File tree

12 files changed

+21
-57
lines changed

12 files changed

+21
-57
lines changed

src/discussions/common/AuthorLabel.jsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { Icon, OverlayTrigger, Tooltip } from '@edx/paragon';
1010
import { Institution, School } from '@edx/paragon/icons';
1111

1212
import { Routes } from '../../data/constants';
13-
import { useShowLearnersTab } from '../data/hooks';
1413
import messages from '../messages';
1514
import { DiscussionContext } from './context';
1615
import timeLocale from './time-locale';
@@ -45,8 +44,7 @@ const AuthorLabel = ({
4544
const showTextPrimary = !authorLabelMessage && !isRetiredUser && !alert;
4645
const className = classNames('d-flex align-items-center', { 'mb-0.5': !postOrComment }, labelColor);
4746

48-
const showUserNameAsLink = useShowLearnersTab()
49-
&& linkToProfile && author && author !== intl.formatMessage(messages.anonymous);
47+
const showUserNameAsLink = linkToProfile && author && author !== intl.formatMessage(messages.anonymous);
5048

5149
const authorName = useMemo(() => (
5250
<span

src/discussions/common/AuthorLabel.test.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ describe('Author label', () => {
5353
store = initializeStore();
5454
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
5555
axiosMock.onGet(`${courseConfigApiUrl}${courseId}/`).reply(200, {
56-
learners_tab_enabled: true,
5756
has_moderation_privileges: true,
5857
});
5958
axiosMock.onGet(`${courseConfigApiUrl}${courseId}/settings`).reply(200, {});

src/discussions/data/hooks.js

-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
selectIsCourseAdmin,
3232
selectIsCourseStaff,
3333
selectIsPostingEnabled,
34-
selectLearnersTabEnabled,
3534
selectPostThreadCount,
3635
selectUserHasModerationPrivileges,
3736
selectUserIsGroupTa,
@@ -171,8 +170,6 @@ export const useAlertBannerVisible = (
171170
);
172171
};
173172

174-
export const useShowLearnersTab = () => useSelector(selectLearnersTabEnabled);
175-
176173
/**
177174
* React hook that gets the current topic ID from the current topic or category.
178175
* The topicId in the DiscussionContext only return the direct topicId from the URL.

src/discussions/data/selectors.js

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ export const selectUserIsGroupTa = state => state.config.isGroupTa;
1414

1515
export const selectConfigLoadingStatus = state => state.config.status;
1616

17-
export const selectLearnersTabEnabled = state => state.config.learnersTabEnabled;
18-
1917
export const selectUserRoles = state => state.config.userRoles;
2018

2119
export const selectDivisionSettings = state => state.config.settings;

src/discussions/data/slices.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const configSlice = createSlice({
1616
isCourseAdmin: false,
1717
isCourseStaff: false,
1818
isUserAdmin: false,
19-
learnersTabEnabled: false,
2019
isPostingEnabled: false,
2120
settings: {
2221
divisionScheme: 'none',

src/discussions/discussions-home/DiscussionSidebar.jsx

+4-9
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import { useWindowSize } from '@edx/paragon';
1414
import Spinner from '../../components/Spinner';
1515
import { RequestStatus, Routes as ROUTES } from '../../data/constants';
1616
import { DiscussionContext } from '../common/context';
17-
import {
18-
useContainerSize, useIsOnDesktop, useIsOnXLDesktop, useShowLearnersTab,
19-
} from '../data/hooks';
17+
import { useContainerSize, useIsOnDesktop, useIsOnXLDesktop } from '../data/hooks';
2018
import { selectConfigLoadingStatus, selectEnableInContext } from '../data/selectors';
2119

2220
const TopicPostsView = lazy(() => import('../in-context-topics/TopicPostsView'));
@@ -32,7 +30,6 @@ const DiscussionSidebar = ({ displaySidebar, postActionBarRef }) => {
3230
const { enableInContextSidebar } = useContext(DiscussionContext);
3331
const enableInContext = useSelector(selectEnableInContext);
3432
const configStatus = useSelector(selectConfigLoadingStatus);
35-
const redirectToLearnersTab = useShowLearnersTab();
3633
const sidebarRef = useRef(null);
3734
const postActionBarHeight = useContainerSize(postActionBarRef);
3835
const { height: windowHeight } = useWindowSize();
@@ -103,14 +100,12 @@ const DiscussionSidebar = ({ displaySidebar, postActionBarRef }) => {
103100
{ROUTES.TOPICS.PATH.map(path => (
104101
<Route key={path} path={path} element={<LegacyTopicsView />} />
105102
))}
106-
{redirectToLearnersTab && (
103+
{
107104
[ROUTES.LEARNERS.POSTS, ROUTES.LEARNERS.POSTS_EDIT].map((route) => (
108105
<Route key={route} path={route} element={<LearnerPostsView />} />
109106
))
110-
)}
111-
{redirectToLearnersTab && (
112-
<Route path={ROUTES.LEARNERS.PATH} element={<LearnersView />} />
113-
)}
107+
}
108+
<Route path={ROUTES.LEARNERS.PATH} element={<LearnersView />} />
114109
{configStatus === RequestStatus.SUCCESSFUL && (
115110
<Route path={`${ROUTES.DISCUSSIONS.PATH}/*`} element={<Navigate to="posts" />} />
116111
)}

src/discussions/discussions-home/DiscussionsHome.jsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { selectCourseTabs } from '../../components/NavigationBar/data/selectors'
1414
import { ALL_ROUTES, DiscussionProvider, Routes as ROUTES } from '../../data/constants';
1515
import { DiscussionContext } from '../common/context';
1616
import {
17-
useCourseDiscussionData, useIsOnDesktop, useRedirectToThread, useShowLearnersTab, useSidebarVisible,
17+
useCourseDiscussionData, useIsOnDesktop, useRedirectToThread, useSidebarVisible,
1818
} from '../data/hooks';
1919
import { selectDiscussionProvider, selectEnableInContext } from '../data/selectors';
2020
import { EmptyLearners, EmptyPosts, EmptyTopics } from '../empty-posts';
@@ -44,7 +44,6 @@ const DiscussionsHome = () => {
4444
const page = pageParams?.page || null;
4545
const matchPattern = ALL_ROUTES.find((route) => matchPath({ path: route }, location.pathname));
4646
const { params } = useMatch(matchPattern);
47-
const isRedirectToLearners = useShowLearnersTab();
4847
const isOnDesktop = useIsOnDesktop();
4948
let displaySidebar = useSidebarVisible();
5049
const enableInContextSidebar = Boolean(new URLSearchParams(location.search).get('inContextSidebar') !== null);
@@ -146,7 +145,7 @@ const DiscussionsHome = () => {
146145
element={<EmptyPosts subTitleMessage={messages.emptyAllPosts} />}
147146
/>
148147
))}
149-
{isRedirectToLearners && <Route path={ROUTES.LEARNERS.PATH} element={<EmptyLearners />} />}
148+
<Route path={ROUTES.LEARNERS.PATH} element={<EmptyLearners />} />
150149
</>
151150
</Routes>
152151
)}

src/discussions/discussions-home/DiscussionsHome.test.jsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,7 @@ describe('DiscussionsHome', () => {
198198
);
199199

200200
it('should display empty page message for empty learners list', async () => {
201-
axiosMock.onGet(getDiscussionsConfigUrl(courseId)).reply(200, {
202-
learners_tab_enabled: true,
203-
});
201+
axiosMock.onGet(getDiscussionsConfigUrl(courseId)).reply(200, {});
204202
await executeThunk(fetchCourseConfig(courseId), store.dispatch, store.getState);
205203
await renderComponent(`/${courseId}/learners`);
206204

src/discussions/learners/LearnersView.jsx

+8-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Button, Spinner } from '@edx/paragon';
88

99
import SearchInfo from '../../components/SearchInfo';
1010
import { RequestStatus } from '../../data/constants';
11-
import { selectConfigLoadingStatus, selectLearnersTabEnabled } from '../data/selectors';
11+
import { selectConfigLoadingStatus } from '../data/selectors';
1212
import NoResults from '../posts/NoResults';
1313
import {
1414
learnersLoadingStatus,
@@ -31,18 +31,15 @@ const LearnersView = () => {
3131
const loadingStatus = useSelector(learnersLoadingStatus());
3232
const usernameSearch = useSelector(selectUsernameSearch());
3333
const courseConfigLoadingStatus = useSelector(selectConfigLoadingStatus);
34-
const learnersTabEnabled = useSelector(selectLearnersTabEnabled);
3534
const learners = useSelector(selectAllLearners);
3635

3736
useEffect(() => {
38-
if (learnersTabEnabled) {
39-
if (usernameSearch) {
40-
dispatch(fetchLearners(courseId, { orderBy, usernameSearch }));
41-
} else {
42-
dispatch(fetchLearners(courseId, { orderBy }));
43-
}
37+
if (usernameSearch) {
38+
dispatch(fetchLearners(courseId, { orderBy, usernameSearch }));
39+
} else {
40+
dispatch(fetchLearners(courseId, { orderBy }));
4441
}
45-
}, [courseId, orderBy, learnersTabEnabled, usernameSearch]);
42+
}, [courseId, orderBy, usernameSearch]);
4643

4744
const loadPage = useCallback(async () => {
4845
if (nextPage) {
@@ -60,12 +57,12 @@ const LearnersView = () => {
6057

6158
const renderLearnersList = useMemo(() => (
6259
(
63-
courseConfigLoadingStatus === RequestStatus.SUCCESSFUL && learnersTabEnabled && learners.map((learner) => (
60+
courseConfigLoadingStatus === RequestStatus.SUCCESSFUL && learners.map((learner) => (
6461
<LearnerCard learner={learner} key={learner.username} />
6562
))
6663
// eslint-disable-next-line react/jsx-no-useless-fragment
6764
) || <></>
68-
), [courseConfigLoadingStatus, learnersTabEnabled, learners]);
65+
), [courseConfigLoadingStatus, learners]);
6966

7067
return (
7168
<div className="d-flex flex-column border-right border-light-400">

src/discussions/learners/LearnersView.test.jsx

-9
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ describe('LearnersView', () => {
6969
username: 'test_user',
7070
administrator: true,
7171
roles: [],
72-
learnersTabEnabled: false,
7372
},
7473
});
7574
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
@@ -106,21 +105,13 @@ describe('LearnersView', () => {
106105

107106
async function assignPrivilages(hasModerationPrivileges = false) {
108107
axiosMock.onGet(getDiscussionsConfigUrl(courseId)).reply(200, {
109-
learners_tab_enabled: true,
110108
user_is_privileged: true,
111109
hasModerationPrivileges,
112110
});
113111

114112
await executeThunk(fetchCourseConfig(courseId), store.dispatch, store.getState);
115113
}
116114

117-
test('Learners tab is disabled by default', async () => {
118-
await setUpLearnerMockResponse();
119-
await renderComponent();
120-
121-
expect(screen.queryByText('learner-1')).not.toBeInTheDocument();
122-
});
123-
124115
test('Learners tab is enabled', async () => {
125116
await setUpLearnerMockResponse();
126117
await assignPrivilages();

src/discussions/navigation/navigation-bar/NavigationBar.jsx

+5-11
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ import { Nav } from '@edx/paragon';
77

88
import { Routes } from '../../../data/constants';
99
import { DiscussionContext } from '../../common/context';
10-
import { useShowLearnersTab } from '../../data/hooks';
1110
import { discussionsPath } from '../../utils';
1211
import messages from './messages';
1312

1413
const NavigationBar = () => {
1514
const intl = useIntl();
1615
const { courseId } = useContext(DiscussionContext);
17-
const showLearnersTab = useShowLearnersTab();
1816
const location = useLocation();
1917
const isTopicsNavActive = Boolean(matchPath({ path: `${Routes.TOPICS.CATEGORY}/*` }, location.pathname));
2018

@@ -31,16 +29,12 @@ const NavigationBar = () => {
3129
route: Routes.TOPICS.ALL,
3230
labelMessage: messages.allTopics,
3331
},
34-
]), []);
32+
{
33+
route: Routes.LEARNERS.PATH,
34+
labelMessage: messages.learners,
35+
},
3536

36-
useMemo(() => {
37-
if (showLearnersTab) {
38-
navLinks.push({
39-
route: Routes.LEARNERS.PATH,
40-
labelMessage: messages.learners,
41-
});
42-
}
43-
}, [showLearnersTab]);
37+
]), []);
4438

4539
return (
4640
<Nav variant="pills" className="py-2 nav-button-group">

src/discussions/posts/post/PostLink.test.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const mockThread = async (id, abuseFlagged) => {
3434
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
3535
axiosMock.onGet(`${courseConfigApiUrl}${courseId}/settings`).reply(200, {});
3636
axiosMock.onGet(`${courseConfigApiUrl}${courseId}/`).reply(200, {
37-
learners_tab_enabled: true,
3837
has_moderation_privileges: true,
3938
});
4039
axiosMock.onGet(`${threadsApiUrl}${id}/`).reply(200, Factory.build('thread', {

0 commit comments

Comments
 (0)