Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(files_reminders): Fix reminder actions being displayed on invalid…
… nodes

Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Mar 26, 2025
commit 99bba9f507ea7fe9add295d14a9a32b0ac79edac
19 changes: 17 additions & 2 deletions apps/files_reminders/src/actions/setReminderCustomAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { FileAction, Node } from '@nextcloud/files'

import type { Node, View } from '@nextcloud/files'

import { FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import CalendarClockSvg from '@mdi/svg/svg/calendar-clock.svg?raw'

Expand All @@ -32,7 +35,19 @@ export const action = new FileAction({
title: () => t('files_reminders', 'Set reminder at custom date & time'),
iconSvgInline: () => CalendarClockSvg,

enabled: () => true,
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,

async exec(file: Node) {
Expand Down
16 changes: 15 additions & 1 deletion apps/files_reminders/src/actions/setReminderMenuAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

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'
Expand All @@ -30,7 +33,18 @@ export const action = new FileAction({
displayName: () => t('files_reminders', 'Set reminder'),
iconSvgInline: () => AlarmSvg,

enabled: () => true,
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

import Vue from 'vue'
import type { Node } from '@nextcloud/files'
import type { Node, View } from '@nextcloud/files'

import { FileAction } from '@nextcloud/files'
import { emit } from '@nextcloud/event-bus'
Expand Down Expand Up @@ -91,7 +91,19 @@ const generateFileAction = (option: ReminderOption): FileAction|null => {
// Empty svg to hide the icon
iconSvgInline: () => '<svg></svg>',

enabled: () => Boolean(getDateTime(option.dateTimePreset)),
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 && Boolean(getDateTime(option.dateTimePreset))
},

parent: SET_REMINDER_MENU_ID,

async exec(node: Node) {
Expand Down
Loading