File tree Expand file tree Collapse file tree
apps/files_reminders/src/actions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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'
2326import { translate as t } from '@nextcloud/l10n'
2427import 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 ) {
Original file line number Diff line number Diff line change 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+
2225import { FileAction } from '@nextcloud/files'
2326import { translate as t } from '@nextcloud/l10n'
2427import 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
Original file line number Diff line number Diff line change 2121 */
2222
2323import Vue from 'vue'
24- import type { Node } from '@nextcloud/files'
24+ import type { Node , View } from '@nextcloud/files'
2525
2626import { FileAction } from '@nextcloud/files'
2727import { 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 ) {
You can’t perform that action at this time.
0 commit comments