feat: Add option to not include attachments in exported data (#5463)

This commit is contained in:
Tom Moor
2023-06-20 21:17:39 -04:00
committed by GitHub
parent 0e5a576439
commit eb62b961a4
13 changed files with 106 additions and 23 deletions

View File

@@ -21,6 +21,8 @@ function ExportDialog({ collection, onSubmit }: Props) {
const [format, setFormat] = React.useState<FileOperationFormat>(
FileOperationFormat.MarkdownZip
);
const [includeAttachments, setIncludeAttachments] =
React.useState<boolean>(true);
const user = useCurrentUser();
const { showToast } = useToasts();
const { collections } = useStores();
@@ -34,11 +36,18 @@ function ExportDialog({ collection, onSubmit }: Props) {
[]
);
const handleIncludeAttachmentsChange = React.useCallback(
(ev: React.ChangeEvent<HTMLInputElement>) => {
setIncludeAttachments(ev.target.checked);
},
[]
);
const handleSubmit = async () => {
if (collection) {
await collection.export(format);
await collection.export(format, includeAttachments);
} else {
await collections.export(format);
await collections.export(format, includeAttachments);
}
onSubmit();
showToast(t("Export started"), { type: "success" });
@@ -107,6 +116,23 @@ function ExportDialog({ collection, onSubmit }: Props) {
</Option>
))}
</Flex>
<hr />
<Option>
<input
type="checkbox"
name="includeAttachments"
checked={includeAttachments}
onChange={handleIncludeAttachmentsChange}
/>
<div>
<Text size="small" weight="bold">
{t("Include attachments")}
</Text>
<Text size="small">
{t("Including uploaded images and files in the exported data")}.
</Text>{" "}
</div>
</Option>
</ConfirmationDialog>
);
}