Merge pull request #51737 from nextcloud/fix/disable-reminder-invalid-nodes

fix(files_reminders): Fix reminder actions being displayed on invalid nodes
pull/51777/head
Pytal 2025-03-27 09:11:37 +07:00 committed by GitHub
commit 1560fc835c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 33 additions and 9 deletions

@ -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,

@ -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() {

@ -74,11 +74,17 @@ const generateFileAction = (option: ReminderOption): FileAction|null => {
// Empty svg to hide the icon
iconSvgInline: () => '<svg></svg>',
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,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long