mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* refactor to multiple rows * added name for org user struct * added name getorgusers * added user name to tableview * made test pass * updated userMocks to user name field * added missing UsersTable snapshot * added name on teammembers page, be able to search query for name, login and email * added the updated snapshots * conform to same sorting as output form * conform to previous way of using it * sort first by login and after by email, as it was before
70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
import React, { FC } from 'react';
|
|
import { OrgUser } from 'app/types';
|
|
|
|
export interface Props {
|
|
users: OrgUser[];
|
|
onRoleChange: (role: string, user: OrgUser) => void;
|
|
onRemoveUser: (user: OrgUser) => void;
|
|
}
|
|
|
|
const UsersTable: FC<Props> = props => {
|
|
const { users, onRoleChange, onRemoveUser } = props;
|
|
|
|
return (
|
|
<table className="filter-table form-inline">
|
|
<thead>
|
|
<tr>
|
|
<th />
|
|
<th>Login</th>
|
|
<th>Email</th>
|
|
<th>Name</th>
|
|
<th>Seen</th>
|
|
<th>Role</th>
|
|
<th style={{ width: '34px' }} />
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{users.map((user, index) => {
|
|
return (
|
|
<tr key={`${user.userId}-${index}`}>
|
|
<td className="width-4 text-center">
|
|
<img className="filter-table__avatar" src={user.avatarUrl} />
|
|
</td>
|
|
<td>{user.login}</td>
|
|
<td>
|
|
<span className="ellipsis">{user.email}</span>
|
|
</td>
|
|
<td>{user.name}</td>
|
|
<td>{user.lastSeenAtAge}</td>
|
|
<td>
|
|
<div className="gf-form-select-wrapper width-12">
|
|
<select
|
|
value={user.role}
|
|
className="gf-form-input"
|
|
onChange={event => onRoleChange(event.target.value, user)}
|
|
>
|
|
{['Viewer', 'Editor', 'Admin'].map((option, index) => {
|
|
return (
|
|
<option value={option} key={`${option}-${index}`}>
|
|
{option}
|
|
</option>
|
|
);
|
|
})}
|
|
</select>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<div onClick={() => onRemoveUser(user)} className="btn btn-danger btn-small">
|
|
<i className="fa fa-remove" />
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
);
|
|
})}
|
|
</tbody>
|
|
</table>
|
|
);
|
|
};
|
|
|
|
export default UsersTable;
|