0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-05-16 03:11:54 +00:00
nextcloud_server/apps/files_reminders/src/actions/setReminderMenuAction.ts
Christopher Ng 88d6771b1f fix(files_reminders): Fix reminder actions being displayed on invalid nodes
Signed-off-by: Christopher Ng <chrng8@gmail.com>
2025-03-26 11:34:08 -07:00

37 lines
886 B
TypeScript

/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
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'
export const SET_REMINDER_MENU_ID = 'set-reminder-menu'
export const action = new FileAction({
id: SET_REMINDER_MENU_ID,
displayName: () => t('files_reminders', 'Set reminder'),
iconSvgInline: () => AlarmSvg,
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() {
return null
},
order: 20,
})