-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing effective roles and their switching for superadmins. Red…
…esigning logged in user badge whilst at it.
- Loading branch information
Martin Krulis
committed
Sep 18, 2019
1 parent
0da7e86
commit 1474a04
Showing
21 changed files
with
269 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/components/Users/EffectiveRoleSwitching/EffectiveRoleSwitching.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }) => ( | ||
<Table hover className="no-margin"> | ||
<tbody> | ||
{knownRoles.map(role => ( | ||
<tr | ||
key={role} | ||
className={classnames({ | ||
'bg-info': role === (updating || effectiveRole), | ||
})} | ||
onClick={ev => { | ||
ev.preventDefault(); | ||
setEffectiveRole(role); | ||
}}> | ||
<td className="shrink-col"> | ||
<input | ||
type="radio" | ||
name="effectiveRole" | ||
value={role} | ||
checked={role === (updating || effectiveRole)} | ||
disabled={Boolean(updating)} | ||
readOnly | ||
/> | ||
</td> | ||
<td className="shrink-col"> | ||
<UserRoleIcon role={role}></UserRoleIcon> | ||
</td> | ||
<td>{roleLabels[role]}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</Table> | ||
); | ||
|
||
EffectiveRoleSwitching.propTypes = { | ||
effectiveRole: PropTypes.string, | ||
updating: PropTypes.string, | ||
setEffectiveRole: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default EffectiveRoleSwitching; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import EffectiveRoleSwitching from './EffectiveRoleSwitching'; | ||
export default EffectiveRoleSwitching; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.