aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_reminders/src/actions/setReminderMenuAction.ts
blob: d6ddcd9067794a94d639bce1153c1b9d3151ff6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
 * 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,
})