* WIP: Archive * WIP * Finishing up archive endpoints * WIP * Update docs * Flow * Stash * Add toast message confirmations * Redirect handling, fixed publishhing info for archived docs * Redirect to collection instead of home, remove unused pub info * Account for deleted parent * Trash -> Archive Allow reading of archived docs * Dont overload deletedAt * Fixes * 💚 * ParentDocumentId wipe for unarchived sub docs * Fix: CMD+S exits editing Fix: Duplicate user name on published but unedited docs * Improve jank on paginated lists * Prevent editing when archived * 💚 Separate lint / flow steps
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
// @flow
|
|
import * as React from 'react';
|
|
import { Redirect } from 'react-router-dom';
|
|
import { observable } from 'mobx';
|
|
import { observer } from 'mobx-react';
|
|
import { MoreIcon } from 'outline-icons';
|
|
|
|
import { newDocumentUrl } from 'utils/routeHelpers';
|
|
import Document from 'models/Document';
|
|
import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
|
|
|
type Props = {
|
|
label?: React.Node,
|
|
document: Document,
|
|
};
|
|
|
|
@observer
|
|
class NewChildDocumentMenu extends React.Component<Props> {
|
|
@observable redirectTo: ?string;
|
|
|
|
componentDidUpdate() {
|
|
this.redirectTo = undefined;
|
|
}
|
|
|
|
handleNewDocument = () => {
|
|
this.redirectTo = newDocumentUrl(this.props.document.collection);
|
|
};
|
|
|
|
handleNewChild = () => {
|
|
const { document } = this.props;
|
|
this.redirectTo = `${document.collection.url}/new?parentDocument=${
|
|
document.id
|
|
}`;
|
|
};
|
|
|
|
render() {
|
|
if (this.redirectTo) return <Redirect to={this.redirectTo} push />;
|
|
|
|
const { label, document, ...rest } = this.props;
|
|
const { collection } = document;
|
|
|
|
return (
|
|
<DropdownMenu label={label || <MoreIcon />} {...rest}>
|
|
<DropdownMenuItem onClick={this.handleNewDocument}>
|
|
<span>
|
|
New document in <strong>{collection.name}</strong>
|
|
</span>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem onClick={this.handleNewChild}>
|
|
New child document
|
|
</DropdownMenuItem>
|
|
</DropdownMenu>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default NewChildDocumentMenu;
|