Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: add delete all button in inbox history dialog Signed-off-by: 01zulfi <[email protected]>

01zulfi2c578c9695c4
diff --git a/apps/web/src/components/dialog/index.tsx b/apps/web/src/components/dialog/index.tsx
index 2216f9b31..e969b02f8 100644
--- a/apps/web/src/components/dialog/index.tsx
+++ b/apps/web/src/components/dialog/index.tsx
@@ -49,6 +49,7 @@ type DialogProps = SxProp & {
textAlignment?: "left" | "right" | "center";
buttonsAlignment?: "start" | "center" | "end";
title?: string;
+ titleAction?: React.ReactNode;
description?: string;
positiveButton?: DialogButtonProps | null;
negativeButton?: DialogButtonProps | null;
@@ -140,19 +141,24 @@ function BaseDialog(props: React.PropsWithChildren<DialogProps>) {
{props.title || props.description ? (
<Flex sx={{ flexDirection: "column" }} p={4} pb={0}>
{props.title && (
- <Text
- variant="heading"
- data-test-id="dialog-title"
- sx={{
- fontSize: "subheading",
- textAlign: props.textAlignment || "left",
- color: "paragraph",
- overflowWrap: "anywhere",
- wordSpacing: "wrap"
- }}
+ <Flex
+ sx={{ alignItems: "center", justifyContent: "space-between" }}
>
- {props.title}
- </Text>
+ <Text
+ variant="heading"
+ data-test-id="dialog-title"
+ sx={{
+ fontSize: "subheading",
+ textAlign: props.textAlignment || "left",
+ color: "paragraph",
+ overflowWrap: "anywhere",
+ wordSpacing: "wrap"
+ }}
+ >
+ {props.title}
+ </Text>
+ {props.titleAction}
+ </Flex>
)}
{props.description && (
<Text
diff --git a/apps/web/src/dialogs/InboxHistoryDialog.tsx b/apps/web/src/dialogs/inbox-history-dialog.tsx
similarity index 94%
rename from apps/web/src/dialogs/InboxHistoryDialog.tsx
rename to apps/web/src/dialogs/inbox-history-dialog.tsx
index 5093361b5..c36f96626 100644
--- a/apps/web/src/dialogs/InboxHistoryDialog.tsx
+++ b/apps/web/src/dialogs/inbox-history-dialog.tsx
@@ -159,10 +159,26 @@ export const InboxHistoryDialog = DialogManager.register(
}
}
+ async function deleteAll() {
+ await db.inboxItemsHistory.deleteFailed();
+ showToast("success", strings.allItemsDeleted());
+ if (result.status !== "pending") {
+ result.refresh();
+ }
+ }
+
return (
<Dialog
isOpen={true}
title={strings.failedInboxItems()}
+ titleAction={
+ result.status === "fulfilled" &&
+ result.value.length > 0 && (
+ <Button variant="errorSecondary" onClick={deleteAll}>
+ {strings.deleteAll()}
+ </Button>
+ )
+ }
onClose={() => props.onClose(false)}
negativeButton={{
text: strings.close(),
diff --git a/apps/web/src/dialogs/settings/inbox-settings.ts b/apps/web/src/dialogs/settings/inbox-settings.ts
index 34288e302..de0281c3c 100644
--- a/apps/web/src/dialogs/settings/inbox-settings.ts
+++ b/apps/web/src/dialogs/settings/inbox-settings.ts
@@ -24,7 +24,7 @@ import { InboxPGPKeysDialog } from "../inbox-pgp-keys-dialog";
import { db } from "../../common/db";
import { showPasswordDialog } from "../password-dialog";
import { strings } from "@notesnook/intl";
-import { InboxHistoryDialog } from "../InboxHistoryDialog";
+import { InboxHistoryDialog } from "../inbox-history-dialog";
export const InboxSettings: SettingsGroup[] = [
{
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 03ffd2a8e..8d937f8f4 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -821,6 +821,10 @@ msgstr "All fields are required"
msgid "All files"
msgstr "All files"
+#: src/strings.ts:2756
+msgid "All items deleted"
+msgstr "All items deleted"
+
#: src/strings.ts:1176
msgid "All locked notes will be re-encrypted with the new password."
msgstr "All locked notes will be re-encrypted with the new password."
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index 59210397a..737e6d398 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -821,6 +821,10 @@ msgstr ""
msgid "All files"
msgstr ""
+#: src/strings.ts:2756
+msgid "All items deleted"
+msgstr ""
+
#: src/strings.ts:1176
msgid "All locked notes will be re-encrypted with the new password."
msgstr ""
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index 7cb632b72..b5bce3913 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2754,5 +2754,6 @@ Continue without attachments?`,
itemDeleted: () => t`Item deleted`,
deleteAll: () => t`Delete all`,
deleteAllFailedItemsDesc: () =>
- t`Are you sure you want to delete all failed inbox items?`
+ t`Are you sure you want to delete all failed inbox items?`,
+ allItemsDeleted: () => t`All items deleted`
};