Skip to content

Commit

Permalink
Surface super user statuson user views. (#238)
Browse files Browse the repository at this point in the history
* Surface super user statuson user views.
  • Loading branch information
newswangerd authored Nov 11, 2020
1 parent 084aea4 commit d135913
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/api/response-types/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class UserType {
date_joined?: string;
password?: string;
model_permissions?: Permissions;
is_superuser?: boolean;
}

export class MeType {
Expand Down
26 changes: 26 additions & 0 deletions src/components/user-form/user-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import {
TextInput,
ActionGroup,
Button,
Tooltip,
Checkbox,
} from '@patternfly/react-core';

import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons';

import { APISearchTypeAhead } from '../../components';

import { UserType, GroupAPI } from '../../api';
Expand Down Expand Up @@ -147,6 +151,28 @@ export class UserForm extends React.Component<IProps, IState> {
/>
</FormGroup>

<FormGroup
fieldId='is_superuser'
label='Super user'
labelIcon={
<Tooltip
content={
'Super users have all system permissions regardless of' +
' their group. Adding new super users is not permitted.'
}
>
<OutlinedQuestionCircleIcon size='sm' />
</Tooltip>
}
>
<Checkbox
id='is_superuser'
isDisabled
isChecked={user.is_superuser}
label='Is super user'
/>
</FormGroup>

{!isReadonly && (
<ActionGroup>
<Button
Expand Down
2 changes: 1 addition & 1 deletion src/containers/settings/user-profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class UserProfile extends React.Component<RouteComponentProps, IState> {
//redirect to login page when password is changed
if (user.password) {
this.props.history.push(Paths.login);
};
}
})
.catch(err => {
this.setState({ errorMessages: mapErrorMessages(err) });
Expand Down
22 changes: 21 additions & 1 deletion src/containers/user-management/user-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import {
Title,
EmptyStateBody,
EmptyStateVariant,
Label,
Tooltip,
} from '@patternfly/react-core';

import { WarningTriangleIcon } from '@patternfly/react-icons';
import { WarningTriangleIcon, UserPlusIcon } from '@patternfly/react-icons';

import { UserAPI, UserType } from '../../api';
import { ParamHelper } from '../../utilities';
Expand Down Expand Up @@ -246,6 +248,11 @@ class UserList extends React.Component<RouteComponentProps, IState> {
type: 'alpha',
id: 'first_name',
},
{
id: 'groups',
title: 'Groups',
type: 'none',
},
{
title: 'Created',
type: 'numeric',
Expand Down Expand Up @@ -308,10 +315,23 @@ class UserList extends React.Component<RouteComponentProps, IState> {
<Link to={formatPath(Paths.userDetail, { userID: user.id })}>
{user.username}
</Link>

{user.is_superuser && (
<Tooltip content='Super users have all system permissions regardless of what groups they are in.'>
<Label icon={<UserPlusIcon />} color='orange'>
Super user
</Label>
</Tooltip>
)}
</td>
<td>{user.email}</td>
<td>{user.last_name}</td>
<td>{user.first_name}</td>
<td>
{user.groups.map(g => (
<Label>{g.name}</Label>
))}
</td>
<td>{moment(user.date_joined).fromNow()}</td>
<td>
{dropdownItems.length > 0 ? (
Expand Down

0 comments on commit d135913

Please sign in to comment.