fix: learner tab is hidden from learners

This commit is contained in:
Mehak Nasir
2022-08-31 21:34:22 +05:00
committed by Mehak Nasir
parent b0737da689
commit 02202e2c07
6 changed files with 40 additions and 21 deletions

View File

@@ -15,11 +15,11 @@ import { selectTopics } from '../topics/data/selectors';
import { fetchCourseTopics } from '../topics/data/thunks';
import { discussionsPath, postMessageToParent } from '../utils';
import {
selectAreThreadsFiltered,
selectAreThreadsFiltered, selectLearnersTabEnabled,
selectModerationSettings,
selectPostThreadCount,
selectUserHasModerationPrivileges,
selectUserIsGroupTa,
selectUserIsGroupTa, selectUserIsStaff, selectUserRoles,
} from './selectors';
import { fetchCourseConfig } from './thunks';
@@ -167,3 +167,13 @@ export const useAlertBannerVisible = (content) => {
|| (content.abuseFlagged && canSeeReportedBanner)
);
};
export const useShowLearnersTab = () => {
const learnersTabEnabled = useSelector(selectLearnersTabEnabled);
const userRoles = useSelector(selectUserRoles);
const isAdmin = useSelector(selectUserIsStaff);
const IsGroupTA = useSelector(selectUserIsGroupTa);
const privileged = useSelector(selectUserHasModerationPrivileges);
const allowedUsers = isAdmin || IsGroupTA || privileged || (userRoles.includes('Student') && userRoles.length > 1);
return learnersTabEnabled && allowedUsers;
};

View File

@@ -16,6 +16,8 @@ export const selectconfigLoadingStatus = state => state.config.status;
export const selectLearnersTabEnabled = state => state.config.learnersTabEnabled;
export const selectUserRoles = state => state.config.userRoles;
export const selectDivisionSettings = state => state.config.settings;
export const selectBlackoutDate = state => state.config.blackouts;