From 830078356e640403188c3da390365f234f8824e0 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Tue, 7 May 2024 15:16:49 -0700 Subject: [PATCH] fix: Remove reminder action from trash Signed-off-by: Christopher Ng --- .../src/actions/setReminderCustomAction.ts | 10 ++++++++-- .../src/actions/setReminderMenuAction.ts | 7 ++++++- .../src/actions/setReminderSuggestionActions.ts | 10 ++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/apps/files_reminders/src/actions/setReminderCustomAction.ts b/apps/files_reminders/src/actions/setReminderCustomAction.ts index 2130adbb12d..5aaef27d277 100644 --- a/apps/files_reminders/src/actions/setReminderCustomAction.ts +++ b/apps/files_reminders/src/actions/setReminderCustomAction.ts @@ -19,7 +19,10 @@ * along with this program. If not, see . * */ -import { FileAction, Node } from '@nextcloud/files' + +import type { Node, View } from '@nextcloud/files' + +import { FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import CalendarClockSvg from '@mdi/svg/svg/calendar-clock.svg?raw' @@ -32,7 +35,10 @@ export const action = new FileAction({ title: () => t('files_reminders', 'Set reminder at custom date & time'), iconSvgInline: () => CalendarClockSvg, - enabled: () => true, + enabled: (_nodes: Node[], view: View) => { + return view.id !== 'trashbin' + }, + parent: SET_REMINDER_MENU_ID, async exec(file: Node) { diff --git a/apps/files_reminders/src/actions/setReminderMenuAction.ts b/apps/files_reminders/src/actions/setReminderMenuAction.ts index 20a4e89d2e9..73b86b9940e 100644 --- a/apps/files_reminders/src/actions/setReminderMenuAction.ts +++ b/apps/files_reminders/src/actions/setReminderMenuAction.ts @@ -19,6 +19,9 @@ * along with this program. If not, see . * */ + +import type { Node, View } from '@nextcloud/files' + import { FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import AlarmSvg from '@mdi/svg/svg/alarm.svg?raw' @@ -30,7 +33,9 @@ export const action = new FileAction({ displayName: () => t('files_reminders', 'Set reminder'), iconSvgInline: () => AlarmSvg, - enabled: () => true, + enabled: (_nodes: Node[], view: View) => { + return view.id !== 'trashbin' + }, async exec() { return null diff --git a/apps/files_reminders/src/actions/setReminderSuggestionActions.ts b/apps/files_reminders/src/actions/setReminderSuggestionActions.ts index e713f51ec7c..321de4229a0 100644 --- a/apps/files_reminders/src/actions/setReminderSuggestionActions.ts +++ b/apps/files_reminders/src/actions/setReminderSuggestionActions.ts @@ -21,7 +21,7 @@ */ import Vue from 'vue' -import type { Node } from '@nextcloud/files' +import type { Node, View } from '@nextcloud/files' import { FileAction } from '@nextcloud/files' import { emit } from '@nextcloud/event-bus' @@ -91,7 +91,13 @@ const generateFileAction = (option: ReminderOption): FileAction|null => { // Empty svg to hide the icon iconSvgInline: () => '', - enabled: () => Boolean(getDateTime(option.dateTimePreset)), + enabled: (_nodes: Node[], view: View) => { + if (view.id === 'trashbin') { + return false + } + return Boolean(getDateTime(option.dateTimePreset)) + }, + parent: SET_REMINDER_MENU_ID, async exec(node: Node) {