From 88d6771b1f82d517df6ce1005cb64f6856adcb0f Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Wed, 26 Mar 2025 11:34:08 -0700 Subject: [PATCH] fix(files_reminders): Fix reminder actions being displayed on invalid nodes Signed-off-by: Christopher Ng --- .../src/actions/setReminderCustomAction.ts | 13 +++++++++++-- .../src/actions/setReminderMenuAction.ts | 13 +++++++++++-- .../src/actions/setReminderSuggestionActions.ts | 10 ++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/apps/files_reminders/src/actions/setReminderCustomAction.ts b/apps/files_reminders/src/actions/setReminderCustomAction.ts index 0c932fa4799..cfaa1ad169f 100644 --- a/apps/files_reminders/src/actions/setReminderCustomAction.ts +++ b/apps/files_reminders/src/actions/setReminderCustomAction.ts @@ -18,8 +18,17 @@ export const action = new FileAction({ title: () => t('files_reminders', 'Set reminder at custom date & time'), iconSvgInline: () => CalendarClockSvg, - enabled: (_nodes: Node[], view: View) => { - return view.id !== 'trashbin' + enabled: (nodes: Node[], view: View) => { + if (view.id === 'trashbin') { + return false + } + // Only allow on a single node + if (nodes.length !== 1) { + return false + } + const node = nodes.at(0)! + const dueDate = node.attributes['reminder-due-date'] + return dueDate !== undefined }, parent: SET_REMINDER_MENU_ID, diff --git a/apps/files_reminders/src/actions/setReminderMenuAction.ts b/apps/files_reminders/src/actions/setReminderMenuAction.ts index f42277b055a..d6ddcd90677 100644 --- a/apps/files_reminders/src/actions/setReminderMenuAction.ts +++ b/apps/files_reminders/src/actions/setReminderMenuAction.ts @@ -16,8 +16,17 @@ export const action = new FileAction({ displayName: () => t('files_reminders', 'Set reminder'), iconSvgInline: () => AlarmSvg, - enabled: (_nodes: Node[], view: View) => { - return view.id !== 'trashbin' + enabled: (nodes: Node[], view: View) => { + if (view.id === 'trashbin') { + return false + } + // Only allow on a single node + if (nodes.length !== 1) { + return false + } + const node = nodes.at(0)! + const dueDate = node.attributes['reminder-due-date'] + return dueDate !== undefined }, async exec() { diff --git a/apps/files_reminders/src/actions/setReminderSuggestionActions.ts b/apps/files_reminders/src/actions/setReminderSuggestionActions.ts index fae18d758a8..f92b2f89108 100644 --- a/apps/files_reminders/src/actions/setReminderSuggestionActions.ts +++ b/apps/files_reminders/src/actions/setReminderSuggestionActions.ts @@ -74,11 +74,17 @@ const generateFileAction = (option: ReminderOption): FileAction|null => { // Empty svg to hide the icon iconSvgInline: () => '', - enabled: (_nodes: Node[], view: View) => { + enabled: (nodes: Node[], view: View) => { if (view.id === 'trashbin') { return false } - return Boolean(getDateTime(option.dateTimePreset)) + // Only allow on a single node + if (nodes.length !== 1) { + return false + } + const node = nodes.at(0)! + const dueDate = node.attributes['reminder-due-date'] + return dueDate !== undefined && Boolean(getDateTime(option.dateTimePreset)) }, parent: SET_REMINDER_MENU_ID,