d5192acabf
* stub invite endpoint
* feat: First pass invite UI
* feat: allow removing invite rows
* First pass: sending logic
* fix: label accessibility
* fix: add button submits
incorrect permissions
middleware flow error
* 💚
* Error handling, email filtering, tests
* Flow
* Add Invite to people page
Remove old Tip
* Add copy link to subdomain
108 lines
2.8 KiB
JavaScript
108 lines
2.8 KiB
JavaScript
// @flow
|
||
import * as React from 'react';
|
||
import invariant from 'invariant';
|
||
import { observable } from 'mobx';
|
||
import { observer, inject } from 'mobx-react';
|
||
|
||
import AuthStore from 'stores/AuthStore';
|
||
import UsersStore from 'stores/UsersStore';
|
||
import Modal from 'components/Modal';
|
||
import Button from 'components/Button';
|
||
import Invite from 'scenes/Invite';
|
||
import CenteredContent from 'components/CenteredContent';
|
||
import PageTitle from 'components/PageTitle';
|
||
import HelpText from 'components/HelpText';
|
||
import UserListItem from './components/UserListItem';
|
||
import List from 'components/List';
|
||
import Tabs from 'components/Tabs';
|
||
import Tab from 'components/Tab';
|
||
|
||
type Props = {
|
||
auth: AuthStore,
|
||
users: UsersStore,
|
||
match: Object,
|
||
};
|
||
|
||
@observer
|
||
class People extends React.Component<Props> {
|
||
@observable inviteModalOpen: boolean = false;
|
||
|
||
componentDidMount() {
|
||
this.props.users.fetchPage({ limit: 100 });
|
||
}
|
||
|
||
handleInviteModalOpen = () => {
|
||
this.inviteModalOpen = true;
|
||
};
|
||
|
||
handleInviteModalClose = () => {
|
||
this.inviteModalOpen = false;
|
||
};
|
||
|
||
render() {
|
||
const { auth, match } = this.props;
|
||
const { filter } = match.params;
|
||
const currentUser = auth.user;
|
||
invariant(currentUser, 'User should exist');
|
||
|
||
let users = this.props.users.active;
|
||
if (filter === 'all') {
|
||
users = this.props.users.orderedData;
|
||
} else if (filter === 'admins') {
|
||
users = this.props.users.admins;
|
||
}
|
||
|
||
return (
|
||
<CenteredContent>
|
||
<PageTitle title="People" />
|
||
<h1>People</h1>
|
||
<HelpText>
|
||
Everyone that has signed into Outline appears here. It’s possible that
|
||
there are other users who have access through Single Sign-On but
|
||
haven’t signed into Outline yet.
|
||
</HelpText>
|
||
<Button
|
||
type="button"
|
||
data-on="click"
|
||
data-event-category="invite"
|
||
data-event-action="peoplePage"
|
||
onClick={this.handleInviteModalOpen}
|
||
neutral
|
||
>
|
||
Invite people…
|
||
</Button>
|
||
|
||
<Tabs>
|
||
<Tab to="/settings/people" exact>
|
||
Active
|
||
</Tab>
|
||
<Tab to="/settings/people/admins" exact>
|
||
Admins
|
||
</Tab>
|
||
<Tab to="/settings/people/all" exact>
|
||
Everyone
|
||
</Tab>
|
||
</Tabs>
|
||
<List>
|
||
{users.map(user => (
|
||
<UserListItem
|
||
key={user.id}
|
||
user={user}
|
||
showMenu={!!currentUser.isAdmin && currentUser.id !== user.id}
|
||
/>
|
||
))}
|
||
</List>
|
||
<Modal
|
||
title="Invite people"
|
||
onRequestClose={this.handleInviteModalClose}
|
||
isOpen={this.inviteModalOpen}
|
||
>
|
||
<Invite onSubmit={this.handleInviteModalClose} />
|
||
</Modal>
|
||
</CenteredContent>
|
||
);
|
||
}
|
||
}
|
||
|
||
export default inject('auth', 'users')(People);
|