From 09ff7f0c7de368dbb969efee17ba4b4e81304875 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Wed, 27 Mar 2024 21:12:38 +0100 Subject: [PATCH] client: add button to delete all shown notes in clip This makes use of the API functionality in the backend which was introduced in commit 89761c86ab06ae1f25294de51c78e306cfd7cff9 . --- locales/en-US.yml | 2 ++ packages/client/src/pages/clip.vue | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 488c12965..1d899193e 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -494,6 +494,8 @@ output: "Output" updateRemoteUser: "Update remote user information" deleteAllFiles: "Delete all files" deleteAllFilesConfirm: "Are you sure that you want to delete all files?" +deleteAllNotes: "Delete all notes" +deleteAllNotesConfirm: "Are you sure that you want to delete all visible notes of this clip?" removeAllFollowing: "Unfollow all followed users" removeAllFollowingDescription: "Executing this unfollows all accounts from {host}.\ \ Please run this if the instance e.g. no longer exists." diff --git a/packages/client/src/pages/clip.vue b/packages/client/src/pages/clip.vue index 8300c4d87..37adbc19c 100644 --- a/packages/client/src/pages/clip.vue +++ b/packages/client/src/pages/clip.vue @@ -12,7 +12,7 @@ - + @@ -39,6 +39,7 @@ const pagination = { clipId: props.clipId, })), }; +const tlComponent = $ref(); const isOwned: boolean | null = $computed(() => $i && clip && ($i.id === clip.userId)); @@ -52,7 +53,25 @@ watch(() => props.clipId, async () => { provide('currentClipPage', $$(clip)); -const headerActions = $computed(() => clip && isOwned ? [{ +const headerActions = $computed(() => clip && isOwned ? [ +...($i.isAdmin ? [{ + icon: 'fas fa-dumpster', + text: i18n.ts.deleteAllNotes, + handler: async (): Promise => { + const { canceled } = await os.confirm({ + type: 'warning', + text: i18n.ts.deleteAllNotesConfirm, + }); + if (canceled) return; + + await os.apiWithDialog('notes/delete-many', { + noteIds: tlComponent.pagingComponent?.items.map(item => item.id) + }); + + tlComponent.pagingComponent?.reload(); + }, +}] : []), +{ icon: 'fas fa-pencil-alt', text: i18n.ts.edit, handler: async (): Promise => {