diff --git a/src/components/SystemMessages/MessagesList/MessagesList.js b/src/components/SystemMessages/MessagesList/MessagesList.js index 3da9c56f3..df2478bbe 100644 --- a/src/components/SystemMessages/MessagesList/MessagesList.js +++ b/src/components/SystemMessages/MessagesList/MessagesList.js @@ -64,15 +64,11 @@ class MessagesList extends Component { className: 'valign-middle', }), - new SortableTableColumnDescriptor( - 'role', - , - { - comparator: ({ role: r1 }, { role: r2 }) => Number(rolePriorities[r2]) - Number(rolePriorities[r1]), - cellRenderer: role => role && roleLabels[role], - className: 'valign-middle', - } - ), + new SortableTableColumnDescriptor('role', , { + comparator: ({ role: r1 }, { role: r2 }) => Number(rolePriorities[r2]) - Number(rolePriorities[r1]), + cellRenderer: role => role && roleLabels[role], + className: 'valign-middle', + }), new SortableTableColumnDescriptor( 'type', diff --git a/src/components/Users/EffectiveRoleSwitching/EffectiveRoleSwitching.js b/src/components/Users/EffectiveRoleSwitching/EffectiveRoleSwitching.js new file mode 100644 index 000000000..7af59caf2 --- /dev/null +++ b/src/components/Users/EffectiveRoleSwitching/EffectiveRoleSwitching.js @@ -0,0 +1,47 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Table } from 'react-bootstrap'; +import classnames from 'classnames'; + +import { knownRoles, roleLabels, UserRoleIcon } from '../../helpers/usersRoles'; + +const EffectiveRoleSwitching = ({ effectiveRole, setEffectiveRole, updating = null }) => ( + + + {knownRoles.map(role => ( + { + ev.preventDefault(); + setEffectiveRole(role); + }}> + + + + + ))} + +
+ + + + {roleLabels[role]}
+); + +EffectiveRoleSwitching.propTypes = { + effectiveRole: PropTypes.string, + updating: PropTypes.string, + setEffectiveRole: PropTypes.func.isRequired, +}; + +export default EffectiveRoleSwitching; diff --git a/src/components/Users/EffectiveRoleSwitching/index.js b/src/components/Users/EffectiveRoleSwitching/index.js new file mode 100644 index 000000000..71b261ede --- /dev/null +++ b/src/components/Users/EffectiveRoleSwitching/index.js @@ -0,0 +1,2 @@ +import EffectiveRoleSwitching from './EffectiveRoleSwitching'; +export default EffectiveRoleSwitching; diff --git a/src/components/Users/UsersName/UsersName.js b/src/components/Users/UsersName/UsersName.js index e71b301ee..74b4942ed 100644 --- a/src/components/Users/UsersName/UsersName.js +++ b/src/components/Users/UsersName/UsersName.js @@ -23,16 +23,19 @@ const UsersName = ({ fullName, avatarUrl, name: { firstName }, - size = 20, + size = null, large = false, isVerified, - noLink, + noLink = false, privateData = null, showEmail = null, showExternalIdentifiers = false, links: { USER_URI_FACTORY }, currentUserId, }) => { + if (size === null) { + size = large ? 45 : 20; + } const email = privateData && privateData.email && showEmail && encodeURIComponent(privateData.email); const externalIds = privateData && privateData.externalIds; return ( diff --git a/src/components/forms/EditSystemMessageForm/EditSystemMessageForm.js b/src/components/forms/EditSystemMessageForm/EditSystemMessageForm.js index de91d1aec..4c45be9c7 100644 --- a/src/components/forms/EditSystemMessageForm/EditSystemMessageForm.js +++ b/src/components/forms/EditSystemMessageForm/EditSystemMessageForm.js @@ -39,7 +39,7 @@ const EditSystemMessageForm = ({ isOpen, onClose, createNew = false, - intl: { locale, formatMessage }, + intl: { formatMessage }, }) => ( diff --git a/src/components/layout/Sidebar/Sidebar.js b/src/components/layout/Sidebar/Sidebar.js index 2d9f9a994..594506333 100644 --- a/src/components/layout/Sidebar/Sidebar.js +++ b/src/components/layout/Sidebar/Sidebar.js @@ -16,7 +16,7 @@ import { getLocalizedResourceName } from '../../../helpers/localizedData'; import { isSupervisorRole, isEmpoweredSupervisorRole, isSuperadminRole } from '../../helpers/usersRoles'; import withLinks from '../../../helpers/withLinks'; import { getExternalIdForCAS } from '../../../helpers/cas'; -import { safeGet, EMPTY_OBJ } from '../../../helpers/common'; +import { EMPTY_OBJ } from '../../../helpers/common'; import styles from './sidebar.less'; @@ -24,6 +24,7 @@ const getUserData = defaultMemoize(user => getJsData(user)); const Sidebar = ({ loggedInUser, + effectiveRole = null, studentOf, supervisorOf, currentUrl, @@ -45,7 +46,6 @@ const Sidebar = ({ intl: { locale }, }) => { const user = getUserData(loggedInUser); - const role = safeGet(user, ['privateData', 'role']); const createLink = item => GROUP_DETAIL_URI_FACTORY(getId(item)); const studentOfItems = studentOf && @@ -124,7 +124,7 @@ const Sidebar = ({ /> )} - {isSupervisorRole(role) && supervisorOfItems && ( + {isSupervisorRole(effectiveRole) && supervisorOfItems && ( @@ -139,7 +139,7 @@ const Sidebar = ({ /> )} - {isSupervisorRole(role) && ( + {isSupervisorRole(effectiveRole) && ( } icon="puzzle-piece" @@ -148,7 +148,7 @@ const Sidebar = ({ /> )} - {isEmpoweredSupervisorRole(role) && ( + {isEmpoweredSupervisorRole(effectiveRole) && ( } icon="random" @@ -183,7 +183,7 @@ const Sidebar = ({ )} - {isSuperadminRole(role) && } + {isSuperadminRole(effectiveRole) && } ); @@ -195,6 +195,7 @@ Sidebar.propTypes = { search: PropTypes.string.isRequired, }).isRequired, loggedInUser: ImmutablePropTypes.map, + effectiveRole: PropTypes.string, studentOf: ImmutablePropTypes.map, supervisorOf: ImmutablePropTypes.map, currentUrl: PropTypes.string, diff --git a/src/components/widgets/Avatar/FakeAvatar.js b/src/components/widgets/Avatar/FakeAvatar.js index 2c843762f..c978a7ce2 100644 --- a/src/components/widgets/Avatar/FakeAvatar.js +++ b/src/components/widgets/Avatar/FakeAvatar.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -const getSize = (size, small) => (small ? size * (2 / 3) : size); +const getSize = (size, borderWidth, small) => (small ? size * (2 / 3) : size) - 2 * borderWidth; const FakeAvatar = ({ size = 45, borderWidth = 2, light = false, children, small = false, altClassName = '' }) => ( diff --git a/src/components/widgets/Badge/Badge.js b/src/components/widgets/Badge/Badge.js index be156a08a..1258c08d1 100644 --- a/src/components/widgets/Badge/Badge.js +++ b/src/components/widgets/Badge/Badge.js @@ -2,73 +2,137 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage, FormattedRelative } from 'react-intl'; import { Link } from 'react-router-dom'; -import { Tooltip, OverlayTrigger } from 'react-bootstrap'; +import { Tooltip, OverlayTrigger, Modal } from 'react-bootstrap'; +import UserName from '../../Users/UsersName'; +import EffectiveRoleSwitching from '../../Users/EffectiveRoleSwitching'; import withLinks from '../../../helpers/withLinks'; import Icon from '../../icons'; import AvatarContainer from '../../../containers/AvatarContainer/AvatarContainer'; +import { isSuperadminRole } from '../../helpers/usersRoles'; class Badge extends Component { + state = { effectiveRoleDialogOpened: false, effectiveRoleUpdating: null }; + + openEffectiveRoleDialog = () => { + this.setState({ effectiveRoleDialogOpened: true, effectiveRoleUpdating: null }); + }; + + closeEffectiveRoleDialog = () => { + this.setState({ effectiveRoleDialogOpened: false, effectiveRoleUpdating: null }); + }; + + setEffectiveRole = role => { + const { setEffectiveRole } = this.props; + this.setState({ effectiveRoleUpdating: role }); + setEffectiveRole(role).then(() => { + this.closeEffectiveRoleDialog(); + window.location.reload(); + }); + }; + render() { const { - id, - fullName, - name: { firstName }, - avatarUrl, + user, + effectiveRole, expiration, logout, - size = 45, - links: { USER_URI_FACTORY, EDIT_USER_URI_FACTORY }, + small = false, + links: { EDIT_USER_URI_FACTORY }, } = this.props; return ( -
-
- -
-
-

- {fullName} -

- - - - -   - - {' '} - - - }> - { - e.preventDefault(); - logout(); - }}> - -   - - - + +
+
+ {small ? ( + + ) : ( + + )} +
+ +
+ + + {!small && } + + + {small &&
} + + + {' '} + + + }> + { + e.preventDefault(); + logout(); + }}> + + {!small && } + + + + {small &&
} + + {isSuperadminRole(user.privateData.role) && ( + { + e.preventDefault(); + this.openEffectiveRoleDialog(); + }}> + + {!small && } + + )} +
-
+ + {isSuperadminRole(user.privateData.role) && ( + + + + + + + + + + + + )} + ); } } Badge.propTypes = { - id: PropTypes.string.isRequired, - fullName: PropTypes.string.isRequired, - name: PropTypes.shape({ firstName: PropTypes.string.isRequired }).isRequired, - avatarUrl: PropTypes.string, - expiration: PropTypes.number.isRequired, - privateData: PropTypes.shape({ settings: PropTypes.object.isRequired }).isRequired, + user: PropTypes.object.isRequired, + effectiveRole: PropTypes.string, + setEffectiveRole: PropTypes.func.isRequired, logout: PropTypes.func, - size: PropTypes.number, + expiration: PropTypes.number.isRequired, + small: PropTypes.bool, links: PropTypes.object, }; diff --git a/src/components/widgets/Header/Header.js b/src/components/widgets/Header/Header.js index 8f67ac23a..d5f13b13a 100644 --- a/src/components/widgets/Header/Header.js +++ b/src/components/widgets/Header/Header.js @@ -56,14 +56,14 @@ class Header extends Component {
- + - + ( +const BadgeContainer = ({ user, effectiveRole, restrictEffectiveRole, expiration, logout, small = false }) => ( } failed={} resource={user}> {user => ( - + )} @@ -26,8 +33,10 @@ const BadgeContainer = ({ user, expiration, logout, small = false }) => ( BadgeContainer.propTypes = { user: PropTypes.object, + effectiveRole: PropTypes.string, expiration: PropTypes.number.isRequired, logout: PropTypes.func.isRequired, + restrictEffectiveRole: PropTypes.func.isRequired, small: PropTypes.bool, links: PropTypes.object, }; @@ -35,7 +44,11 @@ BadgeContainer.propTypes = { export default connect( state => ({ user: loggedInUserSelector(state), + effectiveRole: getLoggedInUserEffectiveRole(state), expiration: accessTokenExpiration(state), }), - { logout } + dispatch => ({ + logout: () => dispatch(logout()), + restrictEffectiveRole: role => dispatch(restrictEffectiveRole(role)), + }) )(BadgeContainer); diff --git a/src/containers/SidebarContainer/SidebarContainer.js b/src/containers/SidebarContainer/SidebarContainer.js index 1cae7005a..07a3358d4 100644 --- a/src/containers/SidebarContainer/SidebarContainer.js +++ b/src/containers/SidebarContainer/SidebarContainer.js @@ -5,10 +5,11 @@ import { loggedInStudentOfSelector, loggedInSupervisorOfNonOrganizationalSelector, } from '../../redux/selectors/usersGroups'; -import { loggedInUserSelector, notificationsSelector } from '../../redux/selectors/users'; +import { loggedInUserSelector, notificationsSelector, getLoggedInUserEffectiveRole } from '../../redux/selectors/users'; export default connect(state => ({ loggedInUser: loggedInUserSelector(state), + effectiveRole: getLoggedInUserEffectiveRole(state), instances: loggedInUserMemberOfInstances(state), studentOf: loggedInStudentOfSelector(state), supervisorOf: loggedInSupervisorOfNonOrganizationalSelector(state), diff --git a/src/locales/cs.json b/src/locales/cs.json index fd6dd165f..cabc7db36 100644 --- a/src/locales/cs.json +++ b/src/locales/cs.json @@ -102,6 +102,7 @@ "app.attachmentFilesTable.description": "Přiložené soubory jsou soubory které mohou být použity v popisu úlohy pomocí odkazů poskytnutých pod tímto textem. Přiložené soubory mohou být prohlíženy a stahovány studenty.", "app.attachmentFilesTable.title": "Přiložené soubory", "app.attachmentFilesTable.url": "URL", + "app.badge.effectiveRoleDialog.title": "Změnit efektivní roli", "app.badge.failedLoading": "Nepodařilo se načíst data", "app.badge.failedLoadingInfo": "Prosim zkontrolujte si své připojení k Internetu.", "app.badge.sessionExpiration": "Expirace sezení:", @@ -868,7 +869,7 @@ "app.loginForm.validation.emailIsNotAnEmail": "E-mailová adresa není zadána správně.", "app.loginForm.validation.emptyEmail": "E-mailová adresa nemůže být prázdná.", "app.loginForm.validation.emptyPassword": "Heslo nemůže být prázdné.", - "app.logout": "Odhlásit se", + "app.logout": "Odhlásit", "app.markdownTextArea.canUseMarkdown": "V tomto poli je povoleno používat syntaxi markdown.", "app.markdownTextArea.empty": "Prázdné", "app.markdownTextArea.preview": "Náhled:", @@ -1238,7 +1239,6 @@ "app.systemMessages.titleLong": "Máte {totalMessagesCount, number} {totalMessagesCount, plural, one {aktivní zprávu} =2 {aktivní zprávy} =3 {aktivní zprávy} =4 {aktivní zprávy} other {aktivních zpráv}} (z toho {unreadCount, number} {unreadCount, plural, one {nepřečtenou} =2 {nepřečtené} =3 {nepřečtené} =4 {nepřečtené} other {nepřečtených}})", "app.systemMessages.unacceptActiveMessages": "Zobrazit všechny zprávy (označit jako nepřečtené)", "app.systemMessagesList.noMessages": "Nyní zde nejsou žádné systémové zprávy.", - "app.systemMessagesList.role": "Role", "app.systemMessagesList.showAll": "Zobrazit všechny zprávy (včetně expirovaných)", "app.systemMessagesList.text": "Text", "app.systemMessagesList.type": "Typ", @@ -1308,6 +1308,7 @@ "generic.refresh": "Občerstvit", "generic.reset": "Resetovat", "generic.results": "Výsledky", + "generic.role": "Role", "generic.runtimeShortest": "Prostředí", "generic.runtimesShort": "Prostředí/jazyky", "generic.save": "Uložit", diff --git a/src/locales/en.json b/src/locales/en.json index 9b7861bd1..dc4c5edff 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -102,6 +102,7 @@ "app.attachmentFilesTable.description": "Attached files are files which can be used within exercise description using links provided below. Attached files can be viewed or downloaded by students.", "app.attachmentFilesTable.title": "Attached files", "app.attachmentFilesTable.url": "URL", + "app.badge.effectiveRoleDialog.title": "Change Effective Role", "app.badge.failedLoading": "Failed to load the data", "app.badge.failedLoadingInfo": "Please check your Internet connection.", "app.badge.sessionExpiration": "Session expiration:", @@ -1238,7 +1239,6 @@ "app.systemMessages.titleLong": "You have {totalMessagesCount, number} active {totalMessagesCount, plural, one {message} two {messages} other {messages}} ({unreadCount, number} unread {unreadCount, plural, one {message} two {messages} other {messages}})", "app.systemMessages.unacceptActiveMessages": "Show all messages (mark them as unread)", "app.systemMessagesList.noMessages": "There are currently no system messages.", - "app.systemMessagesList.role": "Role", "app.systemMessagesList.showAll": "Show all messages (including expired)", "app.systemMessagesList.text": "Text", "app.systemMessagesList.type": "Type", @@ -1308,6 +1308,7 @@ "generic.refresh": "Refresh", "generic.reset": "Reset", "generic.results": "Results", + "generic.role": "Role", "generic.runtimeShortest": "Runtime", "generic.runtimesShort": "Runtimes/Languages", "generic.save": "Save", diff --git a/src/locales/whitelist_cs.json b/src/locales/whitelist_cs.json index eaba677f1..07eb529ea 100644 --- a/src/locales/whitelist_cs.json +++ b/src/locales/whitelist_cs.json @@ -115,7 +115,7 @@ "app.submissions.testResultsTable.statusOK", "app.failureList.headLink", "app.systemMessagesList.text", - "app.systemMessagesList.role", + "generic.role", "app.randomMessages.m1", "app.randomMessages.m2", "app.randomMessages.m3", diff --git a/src/locales/whitelist_en.json b/src/locales/whitelist_en.json index 65a649d0a..8fd93ffe6 100644 --- a/src/locales/whitelist_en.json +++ b/src/locales/whitelist_en.json @@ -102,6 +102,7 @@ "app.attachmentFilesTable.description", "app.attachmentFilesTable.title", "app.attachmentFilesTable.url", + "app.badge.effectiveRoleDialog.title", "app.badge.failedLoading", "app.badge.failedLoadingInfo", "app.badge.sessionExpiration", @@ -1238,7 +1239,6 @@ "app.systemMessages.titleLong", "app.systemMessages.unacceptActiveMessages", "app.systemMessagesList.noMessages", - "app.systemMessagesList.role", "app.systemMessagesList.showAll", "app.systemMessagesList.text", "app.systemMessagesList.type", @@ -1308,6 +1308,7 @@ "generic.refresh", "generic.reset", "generic.results", + "generic.role", "generic.runtimeShortest", "generic.runtimesShort", "generic.save", diff --git a/src/pages/EditExerciseConfig/EditExerciseConfig.js b/src/pages/EditExerciseConfig/EditExerciseConfig.js index 16418d131..d1ed28b7f 100644 --- a/src/pages/EditExerciseConfig/EditExerciseConfig.js +++ b/src/pages/EditExerciseConfig/EditExerciseConfig.js @@ -29,7 +29,7 @@ import { } from '../../redux/modules/exerciseConfigs'; import { getExercise } from '../../redux/selectors/exercises'; import { exerciseConfigSelector } from '../../redux/selectors/exerciseConfigs'; -import { loggedInUserSelector } from '../../redux/selectors/users'; +import { getLoggedInUserEffectiveRole } from '../../redux/selectors/users'; import { fetchRuntimeEnvironments } from '../../redux/modules/runtimeEnvironments'; import { runtimeEnvironmentsSelector } from '../../redux/selectors/runtimeEnvironments'; import { fetchExercisePipelinesVariables } from '../../redux/modules/exercisePipelinesVariables'; @@ -209,7 +209,7 @@ class EditExerciseConfig extends Component { params: { exerciseId }, }, exercise, - loggedUser, + effectiveRole, runtimeEnvironments, exerciseConfig, exerciseEnvironmentConfig, @@ -228,7 +228,7 @@ class EditExerciseConfig extends Component { return ( getLocalizedName(exercise, locale)} description={ - {(exercise, tests, loggedUser) => ( + {(exercise, tests) => (
{( @@ -288,7 +288,7 @@ class EditExerciseConfig extends Component { - {hasPermissions(exercise, 'update') && isEmpoweredSupervisorRole(loggedUser.privateData.role) && ( + {hasPermissions(exercise, 'update') && isEmpoweredSupervisorRole(effectiveRole) && ( @@ -632,7 +632,7 @@ class EditExerciseConfig extends Component { EditExerciseConfig.propTypes = { exercise: ImmutablePropTypes.map, - loggedUser: ImmutablePropTypes.map, + effectiveRole: PropTypes.string, runtimeEnvironments: PropTypes.object.isRequired, match: PropTypes.shape({ params: PropTypes.shape({ @@ -673,7 +673,7 @@ export default withLinks( ) => { return { exercise: getExercise(exerciseId)(state), - loggedUser: loggedInUserSelector(state), + effectiveRole: getLoggedInUserEffectiveRole(state), runtimeEnvironments: runtimeEnvironmentsSelector(state), exerciseConfig: exerciseConfigSelector(exerciseId)(state), exerciseEnvironmentConfig: exerciseEnvironmentConfigSelector(exerciseId)(state), diff --git a/src/pages/GroupDetail/GroupDetail.js b/src/pages/GroupDetail/GroupDetail.js index cfbc83f36..313f487d3 100644 --- a/src/pages/GroupDetail/GroupDetail.js +++ b/src/pages/GroupDetail/GroupDetail.js @@ -34,6 +34,7 @@ import { studentsOfGroupSelector, isStudentOf, loggedInUserSelector, + getLoggedInUserEffectiveRole, } from '../../redux/selectors/users'; import { groupSelector, @@ -152,6 +153,7 @@ class GroupDetail extends Component { group, students, loggedUser, + effectiveRole, assignments = EMPTY_LIST, shadowAssignments = EMPTY_LIST, assignmentEnvironmentsSelector, @@ -321,8 +323,8 @@ class GroupDetail extends Component { (isGroupSupervisor || isGroupAdmin) && !data.organizational && !data.archived && - isSupervisorRole(loggedUser.privateData.role) && - !isStudentRole(loggedUser.privateData.role) && ( + isSupervisorRole(effectiveRole) && + !isStudentRole(effectiveRole) && ( dispatch(fetchAllTerms()); componentDidMount() { - const { loadAsync, loggedInUser } = this.props; - const role = loggedInUser && loggedInUser.getIn(['data', 'privateData', 'role']); - isSuperadminRole(role) && loadAsync(); + const { loadAsync, effectiveRole } = this.props; + isSuperadminRole(effectiveRole) && loadAsync(); } componentDidUpdate(prevProps) { - const oldRole = prevProps.loggedInUser && prevProps.loggedInUser.getIn(['data', 'privateData', 'role']); - const newRole = this.props.loggedInUser && this.props.loggedInUser.getIn(['data', 'privateData', 'role']); - if (newRole !== oldRole && isSuperadminRole(newRole)) { + if (this.props.effectiveRole !== prevProps.effectiveRole && isSuperadminRole(this.props.effectiveRole)) { this.props.loadAsync(); } } @@ -55,6 +51,7 @@ class SisIntegration extends Component { render() { const { loggedInUser, + effectiveRole, fetchStatus, supervisorOfGroups, allGroups, @@ -81,7 +78,6 @@ class SisIntegration extends Component { }, ]}> {user => { - const role = safeGet(user, ['privateData', 'role']); const externalId = getExternalIdForCAS(user); return externalId ? ( @@ -95,7 +91,7 @@ class SisIntegration extends Component { /> - {isStudentRole(role) && ( + {isStudentRole(effectiveRole) && ( @@ -103,11 +99,11 @@ class SisIntegration extends Component { )} - {isSupervisorRole(role) && ( + {isSupervisorRole(effectiveRole) && ( {groups => } @@ -115,7 +111,7 @@ class SisIntegration extends Component { )} - {isSuperadminRole(role) && ( + {isSuperadminRole(effectiveRole) && ( @@ -192,6 +188,7 @@ class SisIntegration extends Component { SisIntegration.propTypes = { loggedInUser: ImmutablePropTypes.map, + effectiveRole: PropTypes.string, fetchStatus: PropTypes.string, sisTerms: PropTypes.array.isRequired, supervisorOfGroups: ImmutablePropTypes.map, @@ -205,6 +202,7 @@ SisIntegration.propTypes = { const mapStateToProps = state => { return { loggedInUser: loggedInUserSelector(state), + effectiveRole: getLoggedInUserEffectiveRole(state), fetchStatus: fetchManyStatus(state), sisTerms: readySisTermsSelector(state), supervisorOfGroups: loggedInSupervisorOfSelector(state), diff --git a/src/pages/Users/Users.js b/src/pages/Users/Users.js index eea551bd0..1f372e3cb 100644 --- a/src/pages/Users/Users.js +++ b/src/pages/Users/Users.js @@ -18,7 +18,7 @@ import UsersList from '../../components/Users/UsersList'; import PaginationContainer, { createSortingIcon, showRangeInfo } from '../../containers/PaginationContainer'; import FilterUsersListForm from '../../components/forms/FilterUsersListForm'; import CreateUserForm from '../../components/forms/CreateUserForm'; -import { loggedInUserSelector, isLoggedAsSuperAdmin } from '../../redux/selectors/users'; +import { loggedInUserSelector, isLoggedAsSuperAdmin, getLoggedInUserEffectiveRole } from '../../redux/selectors/users'; import { takeOver } from '../../redux/modules/auth'; import { selectedInstanceId } from '../../redux/selectors/auth'; import { createAccount } from '../../redux/modules/registration'; @@ -144,7 +144,7 @@ class Users extends Component { }; render() { - const { user } = this.props; + const { user, effectiveRole } = this.props; return ( {user => (
- {(!isSupervisorRole(user.privateData.role) || isStudentRole(user.privateData.role)) && ( + {(!isSupervisorRole(effectiveRole) || isStudentRole(effectiveRole)) && (

@@ -173,12 +173,12 @@ class Users extends Component { )} - {isSupervisorRole(user.privateData.role) && !isStudentRole(user.privateData.role) && ( + {isSupervisorRole(effectiveRole) && !isStudentRole(effectiveRole) && ( } unlimitedHeight footer={ - isSuperadminRole(user.privateData.role) ? ( + isSuperadminRole(effectiveRole) ? (