From 00481d2bfcd86c47701ab2304c3369dacafb4141 Mon Sep 17 00:00:00 2001 From: Apoorv Mishra Date: Tue, 2 Aug 2022 04:21:30 +0530 Subject: [PATCH] fix: Improve document delete confirmation message (#3876) Modify document delete confirmation message to warn about the number of expected nested documents to be deleted. --- app/scenes/DocumentDelete.tsx | 19 +++++++++++++++++-- shared/i18n/locales/en_US/translation.json | 4 +++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/scenes/DocumentDelete.tsx b/app/scenes/DocumentDelete.tsx index 774a4fa1d..82537a6f5 100644 --- a/app/scenes/DocumentDelete.tsx +++ b/app/scenes/DocumentDelete.tsx @@ -24,6 +24,9 @@ function DocumentDelete({ document, onSubmit }: Props) { const { showToast } = useToasts(); const canArchive = !document.isDraft && !document.isArchived; const collection = collections.get(document.collectionId); + const nestedDocumentsCount = collection + ? collection.getDocumentChildren(document.id).length + : 0; const handleSubmit = React.useCallback( async (ev: React.SyntheticEvent) => { ev.preventDefault(); @@ -94,9 +97,9 @@ function DocumentDelete({ document, onSubmit }: Props) { em: , }} /> - ) : ( + ) : nestedDocumentsCount < 1 ? ( , }} /> + ) : ( + , + }} + /> )} {canArchive && ( diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 78e52a662..c532d18cd 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -432,7 +432,9 @@ "Nested documents are not shared": "Nested documents are not shared", "{{ teamName }} is using Outline to share documents, please login to continue.": "{{ teamName }} is using Outline to share documents, please login to continue.", "Are you sure you want to delete the {{ documentTitle }} template?": "Are you sure you want to delete the {{ documentTitle }} template?", - "Are you sure about that? Deleting the {{ documentTitle }} document will delete all of its history and any nested documents.": "Are you sure about that? Deleting the {{ documentTitle }} document will delete all of its history and any nested documents.", + "Are you sure about that? Deleting the {{ documentTitle }} document will delete all of its history.": "Are you sure about that? Deleting the {{ documentTitle }} document will delete all of its history.", + "Are you sure about that? Deleting the {{ documentTitle }} document will delete all of its history and {{ any }} nested document.": "Are you sure about that? Deleting the {{ documentTitle }} document will delete all of its history and one nested document.", + "Are you sure about that? Deleting the {{ documentTitle }} document will delete all of its history and {{ any }} nested document._plural": "Are you sure about that? Deleting the {{ documentTitle }} document will delete all of its history and {{ any }} nested documents.", "If you’d like the option of referencing or restoring the {{noun}} in the future, consider archiving it instead.": "If you’d like the option of referencing or restoring the {{noun}} in the future, consider archiving it instead.", "Archiving": "Archiving", "Document moved": "Document moved",