fix: Include nested documents when downloading a document (#13465)

Replacing the download dialog with the export submenu lost the option to
include child documents, which defaulted to on. Restore it as the default
behavior for every format, and move the background export toast into the
model so all download paths raise it.
This commit is contained in:
Tom Moor authored and GitHub committed 2026-08-17 08:08:21 -04:00
1 parent fb4ad4d046
commit d43cb6dfce
5 files changed
+54 -37

No files matched your search

-4
View File
@@ -729,7 +729,6 @@ export const downloadDocumentAsMarkdown = createAction({
const document = stores.documents.get(activeDocumentId);
await document?.download({
contentType: ExportContentType.Markdown,
includeChildDocuments: false,
});
},
});
@@ -751,7 +750,6 @@ export const downloadDocumentAsHTML = createAction({
const document = stores.documents.get(activeDocumentId);
await document?.download({
contentType: ExportContentType.Html,
includeChildDocuments: false,
});
},
});
@@ -774,7 +772,6 @@ export const downloadDocumentAsTextBundle = createAction({
const document = stores.documents.get(activeDocumentId);
await document?.download({
contentType: ExportContentType.TextBundle,
includeChildDocuments: false,
});
},
});
@@ -800,7 +797,6 @@ export const downloadDocumentAsPDF = createAction({
const document = stores.documents.get(activeDocumentId);
await document?.download({
contentType: ExportContentType.Pdf,
includeChildDocuments: false,
});
},
});
+1 -20
View File
@@ -2,7 +2,6 @@ import { observer } from "mobx-react";
import { ArchiveIcon, CodeIcon } from "outline-icons";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import styled from "styled-components";
import { FileOperationFormat, NotificationEventType } from "@shared/types";
import type Collection from "~/models/Collection";
@@ -60,25 +59,7 @@ export const ExportDialog = observer(({ collection, onSubmit }: Props) => {
}
if (response?.data?.fileOperation) {
const fileOperationId = response.data.fileOperation.id;
const toastId = `export-${fileOperationId}`;
const timeoutId = setTimeout(() => {
toast.success(t("Export started"), {
id: toastId,
description: t("A link to your file will be sent through email soon"),
duration: 3000,
});
ui.exportToasts.delete(fileOperationId);
}, 6000);
ui.registerExportToast(fileOperationId, toastId, timeoutId);
toast.loading(t("Export started"), {
id: toastId,
description: `${t("Preparing your download")}…`,
duration: Infinity,
});
ui.showExportToast(response.data.fileOperation.id);
}
onSubmit();
+24 -5
View File
@@ -679,18 +679,29 @@ export default class Document extends ArchivableModel implements Searchable {
);
}
download = ({
/**
* Download the document in the given format.
*
* Nested documents are included by default when the document has children, in
* which case the file is prepared in the background and the user is notified
* with a toast once it is ready.
*
* @param options.contentType The format to export the document in.
* @param options.includeChildDocuments Whether to include nested documents.
* @returns the API response.
*/
download = async ({
contentType,
includeChildDocuments,
includeChildDocuments = this.children.length > 0,
}: {
contentType: ExportContentType;
includeChildDocuments?: boolean;
}) =>
client.post(
}) => {
const response = await client.post(
`/documents.export`,
{
id: this.id,
includeChildDocuments: includeChildDocuments ?? false,
includeChildDocuments,
},
{
...(includeChildDocuments ? {} : { download: true }),
@@ -699,4 +710,12 @@ export default class Document extends ArchivableModel implements Searchable {
},
}
);
const fileOperation = response?.data?.fileOperation;
if (fileOperation) {
this.store.rootStore.ui.showExportToast(fileOperation.id);
}
return response;
};
}
+26 -5
View File
@@ -1,6 +1,8 @@
import { clamp } from "es-toolkit";
import { t } from "i18next";
import { action, computed, observable } from "mobx";
import { flushSync } from "react-dom";
import { toast } from "sonner";
import { light as defaultTheme } from "@shared/styles/theme";
import type { ProsemirrorData } from "@shared/types";
import Storage from "@shared/utils/Storage";
@@ -486,13 +488,32 @@ class UiStore {
this.debugSafeArea = !this.debugSafeArea;
};
/**
* Display a toast for an export that is being prepared in the background,
* it is updated in place once the export completes or fails.
*
* @param fileOperationId The identifier of the export file operation.
*/
@action
registerExportToast = (
fileOperationId: string,
toastId: string,
timeoutId: ReturnType<typeof setTimeout>
) => {
showExportToast = (fileOperationId: string) => {
const toastId = `export-${fileOperationId}`;
const timeoutId = setTimeout(() => {
toast.success(t("Export started"), {
id: toastId,
description: t("A link to your file will be sent through email soon"),
duration: 3000,
});
this.exportToasts.delete(fileOperationId);
}, 6000);
this.exportToasts.set(fileOperationId, { toastId, timeoutId });
toast.loading(t("Export started"), {
id: toastId,
description: `${t("Preparing your download")}…`,
duration: Infinity,
});
};
@action
+3 -3
View File
@@ -409,9 +409,6 @@
"our engineers have been notified": "our engineers have been notified",
"Clear cache + reload": "Clear cache + reload",
"Show detail": "Show detail",
"Export started": "Export started",
"A link to your file will be sent through email soon": "A link to your file will be sent through email soon",
"Preparing your download": "Preparing your download",
"Exporting the collection may take some time.": "Exporting the collection may take some time.",
"You will receive an email when it's complete.": "You will receive an email when it's complete.",
"Include attachments": "Include attachments",
@@ -1518,6 +1515,9 @@
"A confirmation code has been sent to your email address, please enter the code below to permanently destroy your account.": "A confirmation code has been sent to your email address, please enter the code below to permanently destroy your account.",
"Are you sure? Deleting your account will destroy identifying data associated with your user and cannot be undone. You will be immediately logged out of {{appName}} and all your API tokens will be revoked.": "Are you sure? Deleting your account will destroy identifying data associated with your user and cannot be undone. You will be immediately logged out of {{appName}} and all your API tokens will be revoked.",
"Delete my account": "Delete my account",
"Export started": "Export started",
"A link to your file will be sent through email soon": "A link to your file will be sent through email soon",
"Preparing your download": "Preparing your download",
"Today": "Today",
"Yesterday": "Yesterday",
"Last week": "Last week",