Skip to content

Commit 2152650

Browse files
authored
Merge pull request #51740 from nextcloud/backport/51737/stable29
[stable29] fix(files_reminders): Fix reminder actions being displayed on invalid nodes
2 parents 0e8be44 + ed5e796 commit 2152650

File tree

5 files changed

+49
-8
lines changed

5 files changed

+49
-8
lines changed

apps/files_reminders/src/actions/setReminderCustomAction.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
*
2121
*/
22-
import { FileAction, Node } from '@nextcloud/files'
22+
23+
import type { Node, View } from '@nextcloud/files'
24+
25+
import { FileAction } from '@nextcloud/files'
2326
import { translate as t } from '@nextcloud/l10n'
2427
import CalendarClockSvg from '@mdi/svg/svg/calendar-clock.svg?raw'
2528

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

35-
enabled: () => true,
38+
enabled: (nodes: Node[], view: View) => {
39+
if (view.id === 'trashbin') {
40+
return false
41+
}
42+
// Only allow on a single node
43+
if (nodes.length !== 1) {
44+
return false
45+
}
46+
const node = nodes.at(0)!
47+
const dueDate = node.attributes['reminder-due-date']
48+
return dueDate !== undefined
49+
},
50+
3651
parent: SET_REMINDER_MENU_ID,
3752

3853
async exec(file: Node) {

apps/files_reminders/src/actions/setReminderMenuAction.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
*
2121
*/
22+
23+
import type { Node, View } from '@nextcloud/files'
24+
2225
import { FileAction } from '@nextcloud/files'
2326
import { translate as t } from '@nextcloud/l10n'
2427
import AlarmSvg from '@mdi/svg/svg/alarm.svg?raw'
@@ -30,7 +33,18 @@ export const action = new FileAction({
3033
displayName: () => t('files_reminders', 'Set reminder'),
3134
iconSvgInline: () => AlarmSvg,
3235

33-
enabled: () => true,
36+
enabled: (nodes: Node[], view: View) => {
37+
if (view.id === 'trashbin') {
38+
return false
39+
}
40+
// Only allow on a single node
41+
if (nodes.length !== 1) {
42+
return false
43+
}
44+
const node = nodes.at(0)!
45+
const dueDate = node.attributes['reminder-due-date']
46+
return dueDate !== undefined
47+
},
3448

3549
async exec() {
3650
return null

apps/files_reminders/src/actions/setReminderSuggestionActions.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222

2323
import Vue from 'vue'
24-
import type { Node } from '@nextcloud/files'
24+
import type { Node, View } from '@nextcloud/files'
2525

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

94-
enabled: () => Boolean(getDateTime(option.dateTimePreset)),
94+
enabled: (nodes: Node[], view: View) => {
95+
if (view.id === 'trashbin') {
96+
return false
97+
}
98+
// Only allow on a single node
99+
if (nodes.length !== 1) {
100+
return false
101+
}
102+
const node = nodes.at(0)!
103+
const dueDate = node.attributes['reminder-due-date']
104+
return dueDate !== undefined && Boolean(getDateTime(option.dateTimePreset))
105+
},
106+
95107
parent: SET_REMINDER_MENU_ID,
96108

97109
async exec(node: Node) {

dist/files_reminders-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_reminders-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)