8cbcb77486
* Big upgrades * WIP: Stash * Stash, 30 flow errors left * Downgrade mobx * WIP * When I understand the difference between class and instance methods * 💚 * Fixes: File import Model saving edge cases pinning and starring docs Collection editing Upgrade mobx devtools * Notification settings saving works * Disabled settings * Document mailer * Working notifications * Colletion created notification Ensure not notified for own actions * Tidy up * Document updated event only for document creation Add indexes Notification setting on user creation * Commentary * Fixed: Notification setting on signup * Fix document move / duplicate stale data Add BaseModel.refresh method * Fixes: Title in sidebar not updated after editing document * 💚 * Improve / restore error handling Better handle offline errors * 👕
83 lines
2.1 KiB
JavaScript
83 lines
2.1 KiB
JavaScript
// @flow
|
|
import * as React from 'react';
|
|
import { observable } from 'mobx';
|
|
import { observer, inject } from 'mobx-react';
|
|
import ApiKeysStore from 'stores/ApiKeysStore';
|
|
|
|
import Button from 'components/Button';
|
|
import Input from 'components/Input';
|
|
import CenteredContent from 'components/CenteredContent';
|
|
import PageTitle from 'components/PageTitle';
|
|
import HelpText from 'components/HelpText';
|
|
import List from 'components/List';
|
|
import TokenListItem from './components/TokenListItem';
|
|
|
|
type Props = {
|
|
apiKeys: ApiKeysStore,
|
|
};
|
|
|
|
@observer
|
|
class Tokens extends React.Component<Props> {
|
|
@observable name: string = '';
|
|
|
|
componentDidMount() {
|
|
this.props.apiKeys.fetchPage({ limit: 100 });
|
|
}
|
|
|
|
handleUpdate = (ev: SyntheticInputEvent<*>) => {
|
|
this.name = ev.target.value;
|
|
};
|
|
|
|
handleSubmit = async (ev: SyntheticEvent<*>) => {
|
|
ev.preventDefault();
|
|
await this.props.apiKeys.create({ name: this.name });
|
|
this.name = '';
|
|
};
|
|
|
|
render() {
|
|
const { apiKeys } = this.props;
|
|
const hasApiKeys = apiKeys.orderedData.length > 0;
|
|
|
|
return (
|
|
<CenteredContent>
|
|
<PageTitle title="API Tokens" />
|
|
<h1>API Tokens</h1>
|
|
|
|
<HelpText>
|
|
You can create an unlimited amount of personal API tokens to hack on
|
|
Outline. For more details about the API take a look at the{' '}
|
|
<a href="/developers">developer documentation</a>.
|
|
</HelpText>
|
|
|
|
{hasApiKeys && (
|
|
<List>
|
|
{apiKeys.orderedData.map(token => (
|
|
<TokenListItem
|
|
key={token.id}
|
|
token={token}
|
|
onDelete={token.delete}
|
|
/>
|
|
))}
|
|
</List>
|
|
)}
|
|
|
|
<form onSubmit={this.handleSubmit}>
|
|
<Input
|
|
onChange={this.handleUpdate}
|
|
placeholder="Token label (eg. development)"
|
|
value={this.name}
|
|
required
|
|
/>
|
|
<Button
|
|
type="submit"
|
|
value="Create Token"
|
|
disabled={apiKeys.isSaving}
|
|
/>
|
|
</form>
|
|
</CenteredContent>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default inject('apiKeys')(Tokens);
|