2019-01-05 21:37:33 +00:00
|
|
|
// @flow
|
2020-06-20 20:59:15 +00:00
|
|
|
import * as React from "react";
|
|
|
|
import { PlusIcon } from "outline-icons";
|
2020-07-10 05:33:07 +00:00
|
|
|
import Time from "components/Time";
|
2020-06-20 20:59:15 +00:00
|
|
|
import Avatar from "components/Avatar";
|
|
|
|
import Button from "components/Button";
|
|
|
|
import Badge from "components/Badge";
|
|
|
|
import ListItem from "components/List/Item";
|
|
|
|
import User from "models/User";
|
2019-01-05 21:37:33 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
user: User,
|
2019-10-06 01:42:03 +00:00
|
|
|
canEdit: boolean,
|
2019-08-09 06:09:09 +00:00
|
|
|
onAdd: () => void,
|
2019-01-05 21:37:33 +00:00
|
|
|
};
|
|
|
|
|
2019-10-06 01:42:03 +00:00
|
|
|
const UserListItem = ({ user, onAdd, canEdit }: Props) => {
|
2019-01-05 21:37:33 +00:00
|
|
|
return (
|
|
|
|
<ListItem
|
|
|
|
title={user.name}
|
2020-03-15 03:48:32 +00:00
|
|
|
image={<Avatar src={user.avatarUrl} size={40} />}
|
2019-12-22 22:54:12 +00:00
|
|
|
subtitle={
|
|
|
|
<React.Fragment>
|
|
|
|
{user.lastActiveAt ? (
|
|
|
|
<React.Fragment>
|
|
|
|
Active <Time dateTime={user.lastActiveAt} /> ago
|
|
|
|
</React.Fragment>
|
|
|
|
) : (
|
2020-06-20 20:59:15 +00:00
|
|
|
"Never signed in"
|
2019-12-22 22:54:12 +00:00
|
|
|
)}
|
|
|
|
{!user.lastActiveAt && <Badge>Invited</Badge>}
|
2020-08-08 22:18:37 +00:00
|
|
|
{user.isAdmin && <Badge primary={user.isAdmin}>Admin</Badge>}
|
2019-12-22 22:54:12 +00:00
|
|
|
</React.Fragment>
|
|
|
|
}
|
2019-01-05 21:37:33 +00:00
|
|
|
actions={
|
2019-10-06 01:42:03 +00:00
|
|
|
canEdit ? (
|
|
|
|
<Button type="button" onClick={onAdd} icon={<PlusIcon />} neutral>
|
|
|
|
Add
|
2019-01-05 21:37:33 +00:00
|
|
|
</Button>
|
2020-08-09 01:53:11 +00:00
|
|
|
) : undefined
|
2019-01-05 21:37:33 +00:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default UserListItem;
|