Document Archive (#921)
* 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
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
// @flow
|
||||
import * as React from 'react';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import { observable } from 'mobx';
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import { MoonIcon } from 'outline-icons';
|
||||
import styled, { withTheme } from 'styled-components';
|
||||
@@ -15,6 +13,7 @@ import {
|
||||
githubIssuesUrl,
|
||||
mailToUrl,
|
||||
spectrumUrl,
|
||||
settings,
|
||||
} from '../../shared/utils/routeHelpers';
|
||||
|
||||
type Props = {
|
||||
@@ -26,26 +25,15 @@ type Props = {
|
||||
|
||||
@observer
|
||||
class AccountMenu extends React.Component<Props> {
|
||||
@observable redirectTo: ?string;
|
||||
|
||||
componentDidUpdate() {
|
||||
this.redirectTo = undefined;
|
||||
}
|
||||
|
||||
handleOpenKeyboardShortcuts = () => {
|
||||
this.props.ui.setActiveModal('keyboard-shortcuts');
|
||||
};
|
||||
|
||||
handleOpenSettings = () => {
|
||||
this.redirectTo = '/settings';
|
||||
};
|
||||
|
||||
handleLogout = () => {
|
||||
this.props.auth.logout();
|
||||
};
|
||||
|
||||
render() {
|
||||
if (this.redirectTo) return <Redirect to={this.redirectTo} push />;
|
||||
const { ui, theme } = this.props;
|
||||
const isLightTheme = ui.theme === 'light';
|
||||
|
||||
@@ -54,9 +42,7 @@ class AccountMenu extends React.Component<Props> {
|
||||
style={{ marginRight: 10, marginTop: -10 }}
|
||||
label={this.props.label}
|
||||
>
|
||||
<DropdownMenuItem onClick={this.handleOpenSettings}>
|
||||
Settings
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem href={settings()}>Settings</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={this.handleOpenKeyboardShortcuts}>
|
||||
Keyboard shortcuts
|
||||
</DropdownMenuItem>
|
||||
@@ -77,8 +63,6 @@ class AccountMenu extends React.Component<Props> {
|
||||
Report a bug
|
||||
</DropdownMenuItem>
|
||||
<hr />
|
||||
<DropdownMenuItem onClick={this.handleLogout}>Logout</DropdownMenuItem>
|
||||
<hr />
|
||||
<DropdownMenuItem onClick={ui.toggleDarkMode}>
|
||||
<NightMode justify="space-between">
|
||||
Night Mode{' '}
|
||||
@@ -87,6 +71,8 @@ class AccountMenu extends React.Component<Props> {
|
||||
/>
|
||||
</NightMode>
|
||||
</DropdownMenuItem>
|
||||
<hr />
|
||||
<DropdownMenuItem onClick={this.handleLogout}>Logout</DropdownMenuItem>
|
||||
</DropdownMenu>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,20 @@ class DocumentMenu extends React.Component<Props> {
|
||||
|
||||
handleDuplicate = async (ev: SyntheticEvent<*>) => {
|
||||
const duped = await this.props.document.duplicate();
|
||||
|
||||
// when duplicating, go straight to the duplicated document content
|
||||
this.redirectTo = duped.url;
|
||||
this.props.ui.showToast('Document duplicated');
|
||||
};
|
||||
|
||||
handleArchive = async (ev: SyntheticEvent<*>) => {
|
||||
await this.props.document.archive();
|
||||
this.props.ui.showToast('Document archived');
|
||||
};
|
||||
|
||||
handleRestore = async (ev: SyntheticEvent<*>) => {
|
||||
await this.props.document.restore();
|
||||
this.props.ui.showToast('Document restored');
|
||||
};
|
||||
|
||||
handlePin = (ev: SyntheticEvent<*>) => {
|
||||
@@ -87,9 +100,22 @@ class DocumentMenu extends React.Component<Props> {
|
||||
const { document, label, className, showPrint, auth } = this.props;
|
||||
const canShareDocuments = auth.team && auth.team.sharing;
|
||||
|
||||
if (document.isArchived) {
|
||||
return (
|
||||
<DropdownMenu label={label || <MoreIcon />} className={className}>
|
||||
<DropdownMenuItem onClick={this.handleRestore}>
|
||||
Restore
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={this.handleDelete}>
|
||||
Delete…
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenu>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<DropdownMenu label={label || <MoreIcon />} className={className}>
|
||||
{!document.isDraft && (
|
||||
{!document.isDraft ? (
|
||||
<React.Fragment>
|
||||
{document.pinned ? (
|
||||
<DropdownMenuItem onClick={this.handleUnpin}>
|
||||
@@ -128,10 +154,19 @@ class DocumentMenu extends React.Component<Props> {
|
||||
<DropdownMenuItem onClick={this.handleDuplicate}>
|
||||
Duplicate
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={this.handleArchive}>
|
||||
Archive
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={this.handleDelete}>
|
||||
Delete…
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={this.handleMove}>Move…</DropdownMenuItem>
|
||||
</React.Fragment>
|
||||
) : (
|
||||
<DropdownMenuItem onClick={this.handleDelete}>
|
||||
Delete…
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem onClick={this.handleDelete}>Delete…</DropdownMenuItem>
|
||||
<hr />
|
||||
<DropdownMenuItem onClick={this.handleExport}>
|
||||
Download
|
||||
|
||||
@@ -41,14 +41,14 @@ class NewChildDocumentMenu extends React.Component<Props> {
|
||||
|
||||
return (
|
||||
<DropdownMenu label={label || <MoreIcon />} {...rest}>
|
||||
<DropdownMenuItem onClick={this.handleNewChild}>
|
||||
New child document
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={this.handleNewDocument}>
|
||||
<span>
|
||||
New document in <strong>{collection.name}</strong>
|
||||
</span>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={this.handleNewChild}>
|
||||
New child document
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenu>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user