Tidied people list, now displaying joined at date
This commit is contained in:
Tom Moor
2018-06-20 22:10:03 -07:00
parent b9e0668d7d
commit fa4453a476
9 changed files with 35 additions and 17 deletions

View File

@ -32,9 +32,8 @@ class People extends React.Component<Props> {
<PageTitle title="People" /> <PageTitle title="People" />
<h1>People</h1> <h1>People</h1>
<HelpText> <HelpText>
Everyone that has signed in to your Outline appears here. It's Everyone that has signed in to your Outline appear here. Its possible
possible that there are other people who have access but haven't that there are other people who have access but havent signed in yet.
signed in yet.
</HelpText> </HelpText>
<List> <List>
@ -42,7 +41,7 @@ class People extends React.Component<Props> {
<UserListItem <UserListItem
key={user.id} key={user.id}
user={user} user={user}
isCurrentUser={currentUser.id === user.id} showMenu={!!currentUser.isAdmin && currentUser.id !== user.id}
/> />
))} ))}
</List> </List>

View File

@ -1,5 +1,6 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
import styled from 'styled-components'; import styled from 'styled-components';
import UserMenu from 'menus/UserMenu'; import UserMenu from 'menus/UserMenu';
@ -9,10 +10,10 @@ import type { User } from '../../../types';
type Props = { type Props = {
user: User, user: User,
isCurrentUser: boolean, showMenu: boolean,
}; };
const UserListItem = ({ user, isCurrentUser }: Props) => { const UserListItem = ({ user, showMenu }: Props) => {
return ( return (
<ListItem <ListItem
key={user.id} key={user.id}
@ -20,12 +21,13 @@ const UserListItem = ({ user, isCurrentUser }: Props) => {
image={<Avatar src={user.avatarUrl} size={40} />} image={<Avatar src={user.avatarUrl} size={40} />}
subtitle={ subtitle={
<React.Fragment> <React.Fragment>
{user.username ? user.username : user.email} {user.email ? `${user.email} · ` : undefined}
{`Joined ${distanceInWordsToNow(user.createdAt)} ago`}
{user.isAdmin && <Badge admin={user.isAdmin}>Admin</Badge>} {user.isAdmin && <Badge admin={user.isAdmin}>Admin</Badge>}
{user.isSuspended && <Badge>Suspended</Badge>} {user.isSuspended && <Badge>Suspended</Badge>}
</React.Fragment> </React.Fragment>
} }
actions={isCurrentUser ? undefined : <UserMenu user={user} />} actions={showMenu ? <UserMenu user={user} /> : undefined}
/> />
); );
}; };

View File

@ -7,6 +7,7 @@ export type User = {
username: string, username: string,
isAdmin?: boolean, isAdmin?: boolean,
isSuspended?: boolean, isSuspended?: boolean,
createdAt: string,
}; };
export type Toast = { export type Toast = {

View File

@ -5,12 +5,14 @@ Object {
"data": Array [ "data": Array [
Object { Object {
"avatarUrl": "http://example.com/avatar.png", "avatarUrl": "http://example.com/avatar.png",
"createdAt": "2018-01-01T00:00:00.000Z",
"id": "fa952cff-fa64-4d42-a6ea-6955c9689046", "id": "fa952cff-fa64-4d42-a6ea-6955c9689046",
"name": "Admin User", "name": "Admin User",
"username": "admin", "username": "admin",
}, },
Object { Object {
"avatarUrl": "http://example.com/avatar.png", "avatarUrl": "http://example.com/avatar.png",
"createdAt": "2018-01-01T00:00:00.000Z",
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61", "id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
"name": "User 1", "name": "User 1",
"username": "user1", "username": "user1",
@ -31,15 +33,7 @@ Object {
"data": Array [ "data": Array [
Object { Object {
"avatarUrl": "http://example.com/avatar.png", "avatarUrl": "http://example.com/avatar.png",
"email": "admin@example.com", "createdAt": "2018-01-01T00:00:00.000Z",
"id": "fa952cff-fa64-4d42-a6ea-6955c9689046",
"isAdmin": true,
"isSuspended": false,
"name": "Admin User",
"username": "admin",
},
Object {
"avatarUrl": "http://example.com/avatar.png",
"email": "user1@example.com", "email": "user1@example.com",
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61", "id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
"isAdmin": false, "isAdmin": false,
@ -47,6 +41,16 @@ Object {
"name": "User 1", "name": "User 1",
"username": "user1", "username": "user1",
}, },
Object {
"avatarUrl": "http://example.com/avatar.png",
"createdAt": "2018-01-01T00:00:00.000Z",
"email": "admin@example.com",
"id": "fa952cff-fa64-4d42-a6ea-6955c9689046",
"isAdmin": true,
"isSuspended": false,
"name": "Admin User",
"username": "admin",
},
], ],
"ok": true, "ok": true,
"pagination": Object { "pagination": Object {

View File

@ -4,6 +4,7 @@ exports[`#user.activate should activate a suspended user 1`] = `
Object { Object {
"data": Object { "data": Object {
"avatarUrl": "http://example.com/avatar.png", "avatarUrl": "http://example.com/avatar.png",
"createdAt": "2018-01-01T00:00:00.000Z",
"email": "user1@example.com", "email": "user1@example.com",
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61", "id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
"isAdmin": false, "isAdmin": false,
@ -29,6 +30,7 @@ exports[`#user.demote should demote an admin 1`] = `
Object { Object {
"data": Object { "data": Object {
"avatarUrl": "http://example.com/avatar.png", "avatarUrl": "http://example.com/avatar.png",
"createdAt": "2018-01-01T00:00:00.000Z",
"email": "user1@example.com", "email": "user1@example.com",
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61", "id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
"isAdmin": false, "isAdmin": false,
@ -72,6 +74,7 @@ exports[`#user.info should return known user 1`] = `
Object { Object {
"data": Object { "data": Object {
"avatarUrl": "http://example.com/avatar.png", "avatarUrl": "http://example.com/avatar.png",
"createdAt": "2018-01-01T00:00:00.000Z",
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61", "id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
"name": "User 1", "name": "User 1",
"username": "user1", "username": "user1",
@ -85,6 +88,7 @@ exports[`#user.promote should promote a new admin 1`] = `
Object { Object {
"data": Object { "data": Object {
"avatarUrl": "http://example.com/avatar.png", "avatarUrl": "http://example.com/avatar.png",
"createdAt": "2018-01-01T00:00:00.000Z",
"email": "user1@example.com", "email": "user1@example.com",
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61", "id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
"isAdmin": true, "isAdmin": true,
@ -119,6 +123,7 @@ exports[`#user.suspend should suspend an user 1`] = `
Object { Object {
"data": Object { "data": Object {
"avatarUrl": "http://example.com/avatar.png", "avatarUrl": "http://example.com/avatar.png",
"createdAt": "2018-01-01T00:00:00.000Z",
"email": "user1@example.com", "email": "user1@example.com",
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61", "id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
"isAdmin": false, "isAdmin": false,
@ -153,6 +158,7 @@ exports[`#user.update should update user profile information 1`] = `
Object { Object {
"data": Object { "data": Object {
"avatarUrl": "http://example.com/avatar.png", "avatarUrl": "http://example.com/avatar.png",
"createdAt": "2018-01-01T00:00:00.000Z",
"email": "user1@example.com", "email": "user1@example.com",
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61", "id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
"isAdmin": false, "isAdmin": false,

View File

@ -3,6 +3,7 @@
exports[`presents a user 1`] = ` exports[`presents a user 1`] = `
Object { Object {
"avatarUrl": "http://example.com/avatar.png", "avatarUrl": "http://example.com/avatar.png",
"createdAt": undefined,
"id": "123", "id": "123",
"name": "Test User", "name": "Test User",
"username": "testuser", "username": "testuser",
@ -12,6 +13,7 @@ Object {
exports[`presents a user without slack data 1`] = ` exports[`presents a user without slack data 1`] = `
Object { Object {
"avatarUrl": null, "avatarUrl": null,
"createdAt": undefined,
"id": "123", "id": "123",
"name": "Test User", "name": "Test User",
"username": "testuser", "username": "testuser",

View File

@ -21,6 +21,7 @@ export default (
): UserPresentation => { ): UserPresentation => {
const userData = {}; const userData = {};
userData.id = user.id; userData.id = user.id;
userData.createdAt = user.createdAt;
userData.username = user.username; userData.username = user.username;
userData.name = user.name; userData.name = user.name;
userData.avatarUrl = userData.avatarUrl =

View File

@ -42,6 +42,7 @@ export async function buildUser(overrides: Object = {}) {
password: 'test123!', password: 'test123!',
service: 'slack', service: 'slack',
serviceId: uuid.v4(), serviceId: uuid.v4(),
createdAt: new Date('2018-01-01T00:00:00.000Z'),
...overrides, ...overrides,
}); });
} }

View File

@ -36,6 +36,7 @@ const seed = async () => {
id: 'U2399UF2P', id: 'U2399UF2P',
image_192: 'http://example.com/avatar.png', image_192: 'http://example.com/avatar.png',
}, },
createdAt: new Date('2018-01-01T00:00:00.000Z'),
}); });
const admin = await User.create({ const admin = await User.create({
@ -52,6 +53,7 @@ const seed = async () => {
id: 'U2399UF1P', id: 'U2399UF1P',
image_192: 'http://example.com/avatar.png', image_192: 'http://example.com/avatar.png',
}, },
createdAt: new Date('2018-01-01T00:00:00.000Z'),
}); });
const collection = await Collection.create({ const collection = await Collection.create({