Merge pull request #942 from chaotixkilla/fix-user-management-issues
Fix styling and URL creation issues in user management page
This commit is contained in:
commit
e830624e1e
3 changed files with 46 additions and 48 deletions
|
|
@ -53,6 +53,11 @@ const reducer = (_, action) => {
|
|||
}
|
||||
}
|
||||
|
||||
const roleMapper = {
|
||||
user: 'Regular',
|
||||
superuser: 'Superuser'
|
||||
}
|
||||
|
||||
const Users = () => {
|
||||
const classes = useStyles()
|
||||
const { userData } = useContext(AppContext)
|
||||
|
|
@ -65,63 +70,44 @@ const Users = () => {
|
|||
const elements = [
|
||||
{
|
||||
header: 'Login',
|
||||
width: 257,
|
||||
width: 307,
|
||||
textAlign: 'left',
|
||||
size: 'sm',
|
||||
view: u => {
|
||||
if (userData.id === u.id)
|
||||
return (
|
||||
<>
|
||||
{u.username}
|
||||
<div className={classes.loginWrapper}>
|
||||
<span className={classes.username}>{u.username}</span>
|
||||
<Chip size="small" label="You" className={classes.chip} />
|
||||
</>
|
||||
</div>
|
||||
)
|
||||
return u.username
|
||||
return <span className={classes.username}>{u.username}</span>
|
||||
}
|
||||
},
|
||||
{
|
||||
header: 'Role',
|
||||
width: 105,
|
||||
textAlign: 'center',
|
||||
size: 'sm',
|
||||
view: u => {
|
||||
switch (u.role) {
|
||||
case 'user':
|
||||
return 'Regular'
|
||||
case 'superuser':
|
||||
return 'Superuser'
|
||||
default:
|
||||
return u.role
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
header: '',
|
||||
width: 80,
|
||||
textAlign: 'center',
|
||||
width: 160,
|
||||
textAlign: 'left',
|
||||
size: 'sm',
|
||||
view: u => (
|
||||
<Switch
|
||||
disabled={userData.id === u.id}
|
||||
checked={u.role === 'superuser'}
|
||||
onClick={() => {
|
||||
setUserInfo(u)
|
||||
dispatch({
|
||||
type: 'open',
|
||||
payload: 'showRoleModal'
|
||||
})
|
||||
}}
|
||||
value={u.role === 'superuser'}
|
||||
/>
|
||||
<div className={classes.loginWrapper}>
|
||||
<span>{roleMapper[u.role]}</span>
|
||||
<Switch
|
||||
className={classes.roleSwitch}
|
||||
disabled={userData.id === u.id}
|
||||
checked={u.role === 'superuser'}
|
||||
onClick={() => {
|
||||
setUserInfo(u)
|
||||
dispatch({
|
||||
type: 'open',
|
||||
payload: 'showRoleModal'
|
||||
})
|
||||
}}
|
||||
value={u.role === 'superuser'}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
{
|
||||
header: '',
|
||||
width: 25,
|
||||
textAlign: 'center',
|
||||
size: 'sm',
|
||||
view: u => {}
|
||||
},
|
||||
{
|
||||
header: 'Actions',
|
||||
width: 565,
|
||||
|
|
|
|||
|
|
@ -50,13 +50,11 @@ const styles = {
|
|||
chip: {
|
||||
backgroundColor: subheaderColor,
|
||||
fontFamily: fontPrimary,
|
||||
marginLeft: 15,
|
||||
marginTop: -5
|
||||
marginLeft: 10
|
||||
},
|
||||
actionChip: {
|
||||
backgroundColor: subheaderColor,
|
||||
marginRight: 15,
|
||||
marginTop: -5
|
||||
marginRight: 15
|
||||
},
|
||||
info: {
|
||||
fontFamily: fontSecondary,
|
||||
|
|
@ -105,6 +103,21 @@ const styles = {
|
|||
height: '100%',
|
||||
overflow: 'hidden',
|
||||
position: 'relative'
|
||||
},
|
||||
loginWrapper: {
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between'
|
||||
},
|
||||
username: {
|
||||
overflow: 'hidden',
|
||||
whiteSpace: 'nowrap',
|
||||
textOverflow: 'ellipsis',
|
||||
width: '100%'
|
||||
},
|
||||
roleSwitch: {
|
||||
marginLeft: 15
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
const url =
|
||||
process.env.NODE_ENV === 'development' ? 'https://localhost:3001' : ''
|
||||
const url = `https://${window.location.hostname}`
|
||||
|
||||
const urlResolver = content => `${url}${content}`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue