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:
@@ -27,6 +27,8 @@ import LoadingPlaceholder from 'components/LoadingPlaceholder';
|
||||
import LoadingIndicator from 'components/LoadingIndicator';
|
||||
import CenteredContent from 'components/CenteredContent';
|
||||
import PageTitle from 'components/PageTitle';
|
||||
import Notice from 'shared/components/Notice';
|
||||
import Time from 'shared/components/Time';
|
||||
import Search from 'scenes/Search';
|
||||
import Error404 from 'scenes/Error404';
|
||||
import ErrorOffline from 'scenes/ErrorOffline';
|
||||
@@ -98,7 +100,19 @@ class DocumentScene extends React.Component<Props> {
|
||||
@keydown('m')
|
||||
goToMove(ev) {
|
||||
ev.preventDefault();
|
||||
if (this.document) this.props.history.push(documentMoveUrl(this.document));
|
||||
|
||||
if (this.document && !this.document.isArchived) {
|
||||
this.props.history.push(documentMoveUrl(this.document));
|
||||
}
|
||||
}
|
||||
|
||||
@keydown('e')
|
||||
goToEdit(ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
if (this.document && !this.document.isArchived) {
|
||||
this.props.history.push(documentEditUrl(this.document));
|
||||
}
|
||||
}
|
||||
|
||||
@keydown('esc')
|
||||
@@ -156,6 +170,10 @@ class DocumentScene extends React.Component<Props> {
|
||||
if (document) {
|
||||
this.props.ui.setActiveDocument(document);
|
||||
|
||||
if (document.isArchived && this.isEditing) {
|
||||
return this.goToDocumentCanonical();
|
||||
}
|
||||
|
||||
if (this.props.auth.user && !shareId) {
|
||||
if (!this.isEditing && document.publishedAt) {
|
||||
this.viewTimeout = setTimeout(document.view, MARK_AS_VIEWED_AFTER);
|
||||
@@ -200,10 +218,6 @@ class DocumentScene extends React.Component<Props> {
|
||||
handleCloseMoveModal = () => (this.moveModalOpen = false);
|
||||
handleOpenMoveModal = () => (this.moveModalOpen = true);
|
||||
|
||||
onSaveAndExit = () => {
|
||||
this.onSave({ done: true });
|
||||
};
|
||||
|
||||
onSave = async (
|
||||
options: { done?: boolean, publish?: boolean, autosave?: boolean } = {}
|
||||
) => {
|
||||
@@ -366,7 +380,13 @@ class DocumentScene extends React.Component<Props> {
|
||||
onSave={this.onSave}
|
||||
/>
|
||||
)}
|
||||
<MaxWidth column auto>
|
||||
<MaxWidth archived={document.isArchived} column auto>
|
||||
{document.archivedAt && (
|
||||
<Notice muted>
|
||||
Archived by {document.updatedBy.name}{' '}
|
||||
<Time dateTime={document.archivedAt} /> ago
|
||||
</Notice>
|
||||
)}
|
||||
<Editor
|
||||
id={document.id}
|
||||
key={embedsDisabled ? 'embeds-disabled' : 'embeds-enabled'}
|
||||
@@ -377,9 +397,9 @@ class DocumentScene extends React.Component<Props> {
|
||||
onImageUploadStop={this.onImageUploadStop}
|
||||
onSearchLink={this.onSearchLink}
|
||||
onChange={this.onChange}
|
||||
onSave={this.onSaveAndExit}
|
||||
onSave={this.onSave}
|
||||
onCancel={this.onDiscard}
|
||||
readOnly={!this.isEditing}
|
||||
readOnly={!this.isEditing || document.isArchived}
|
||||
toc={!revision}
|
||||
ui={this.props.ui}
|
||||
schema={schema}
|
||||
@@ -394,6 +414,8 @@ class DocumentScene extends React.Component<Props> {
|
||||
}
|
||||
|
||||
const MaxWidth = styled(Flex)`
|
||||
${props =>
|
||||
props.archived && `* { color: ${props.theme.textSecondary} !important; } `};
|
||||
padding: 0 16px;
|
||||
max-width: 100vw;
|
||||
width: 100%;
|
||||
|
||||
Reference in New Issue
Block a user