This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/app/scenes/Settings/People.js
Tom Moor d5192acabf
feat: invites (#967)
* 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
2019-06-24 22:14:59 -07:00

108 lines
2.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// @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. Its possible that
there are other users who have access through Single Sign-On but
havent 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);