forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manage user groups in UserEdit (getredash#3450)
- Loading branch information
1 parent
905e50b
commit e11d479
Showing
12 changed files
with
194 additions
and
36 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,66 @@ | ||
import React from 'react'; | ||
import { includes } from 'lodash'; | ||
import Tag from 'antd/lib/tag'; | ||
import { Group } from '@/services/group'; | ||
import { UserProfile } from '../proptypes'; | ||
|
||
export default function UserShow({ user: { name, email, profileImageUrl } }) { | ||
return ( | ||
<div className="col-md-4 col-md-offset-4 profile__container"> | ||
<img | ||
alt="profile" | ||
src={profileImageUrl} | ||
className="profile__image" | ||
width="40" | ||
/> | ||
|
||
<h3 className="profile__h3">{name}</h3> | ||
|
||
<hr /> | ||
|
||
<dl className="profile__dl"> | ||
<dt>Name:</dt> | ||
<dd>{name}</dd> | ||
<dt>Email:</dt> | ||
<dd>{email}</dd> | ||
</dl> | ||
</div> | ||
); | ||
} | ||
export default class UserShow extends React.Component { | ||
static propTypes = { | ||
user: UserProfile.isRequired, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { groups: [], loadingGroups: true }; | ||
} | ||
|
||
componentDidMount() { | ||
Group.query((groups) => { | ||
this.setState({ groups, loadingGroups: false }); | ||
}); | ||
} | ||
|
||
renderUserGroups() { | ||
const { groupIds } = this.props.user; | ||
const { groups } = this.state; | ||
|
||
return ( | ||
<div> | ||
{groups.filter(group => includes(groupIds, group.id)).map((group => ( | ||
<Tag className="m-t-5 m-r-5" key={group.id}> | ||
<a href={`groups/${group.id}`}>{group.name}</a> | ||
</Tag> | ||
)))} | ||
</div> | ||
); | ||
} | ||
|
||
UserShow.propTypes = { | ||
user: UserProfile.isRequired, | ||
}; | ||
render() { | ||
const { name, email, profileImageUrl } = this.props.user; | ||
const { loadingGroups } = this.state; | ||
|
||
return ( | ||
<div className="col-md-4 col-md-offset-4 profile__container"> | ||
<img | ||
alt="profile" | ||
src={profileImageUrl} | ||
className="profile__image" | ||
width="40" | ||
/> | ||
|
||
<h3 className="profile__h3">{name}</h3> | ||
|
||
<hr /> | ||
|
||
<dl className="profile__dl"> | ||
<dt>Name:</dt> | ||
<dd>{name}</dd> | ||
<dt>Email:</dt> | ||
<dd>{email}</dd> | ||
<dt>Groups:</dt> | ||
<dd>{loadingGroups ? 'Loading...' : this.renderUserGroups()}</dd> | ||
</dl> | ||
</div> | ||
); | ||
} | ||
} |
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
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