fix: Improve document delete confirmation message (#3876)

Modify document delete confirmation message to warn
about the number of expected nested documents to be deleted.
This commit is contained in:
Apoorv Mishra
2022-08-02 04:21:30 +05:30
committed by GitHub
parent eace258a86
commit 00481d2bfc
2 changed files with 20 additions and 3 deletions

View File

@@ -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: <strong />,
}}
/>
) : (
) : nestedDocumentsCount < 1 ? (
<Trans
defaults="Are you sure about that? Deleting the <em>{{ documentTitle }}</em> document will delete all of its history and any nested documents."
defaults="Are you sure about that? Deleting the <em>{{ documentTitle }}</em> document will delete all of its history</em>."
values={{
documentTitle: document.titleWithDefault,
}}
@@ -104,6 +107,18 @@ function DocumentDelete({ document, onSubmit }: Props) {
em: <strong />,
}}
/>
) : (
<Trans
count={nestedDocumentsCount}
defaults="Are you sure about that? Deleting the <em>{{ documentTitle }}</em> document will delete all of its history and <em>{{ any }} nested document</em>."
values={{
documentTitle: document.titleWithDefault,
any: nestedDocumentsCount,
}}
components={{
em: <strong />,
}}
/>
)}
</Text>
{canArchive && (