mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
fix(files_reminders): Fix reminder actions being displayed on invalid nodes
Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
parent
fa475f157c
commit
f0f6b0b69d
3 changed files with 30 additions and 6 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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue