fix: learner tab is hidden from learners
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user