Skip to content

Commit 97ffc66

Browse files
committed
fix(papercut) - rerendered submenu actions for time sensitive actions
Signed-off-by: Eduardo Morales <emoral435@gmail.com>
1 parent 0309faa commit 97ffc66

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

apps/files/src/components/FileEntry/FileEntryActions.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<NcActionSeparator />
7474

7575
<!-- Submenu actions -->
76-
<NcActionButton v-for="action in enabledSubmenuActions[openedSubmenu?.id]"
76+
<NcActionButton v-for="action in reloadedSubmenuActions(openedSubmenu)"
7777
:key="action.id"
7878
:class="`files-list__row-action-${action.id}`"
7979
class="files-list__row-action--submenu"
@@ -108,6 +108,7 @@ import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
108108
109109
import CustomElementRender from '../CustomElementRender.vue'
110110
import logger from '../../logger.js'
111+
import type { LogLevel } from '@nextcloud/logger'
111112
112113
// The registered actions list
113114
const actions = getFileActions()
@@ -270,6 +271,32 @@ export default Vue.extend({
270271
return action.displayName([this.source], this.currentView)
271272
},
272273
274+
// same as enabledSubmenuActions computed function, but instead as a method to be able to
275+
// recompuate elements that may have changed due to being time sensitive
276+
reloadedSubmenuActions(openedSubmenu: FileAction) {
277+
return this.reloadedActions()
278+
.filter(action => action.parent)
279+
.reduce((arr, action) => {
280+
if (!arr[action.parent]) {
281+
arr[action.parent] = []
282+
}
283+
arr[action.parent].push(action)
284+
return arr
285+
}, {} as Record<string, FileAction>)[openedSubmenu?.id] // indexes directly into the FileAction list
286+
},
287+
288+
// same as enabledActions computed function, but instead as a method to be able to
289+
// recompuate elements that may have changed due to being time sensitive
290+
reloadedActions() {
291+
if (this.source.attributes.failed) {
292+
return []
293+
}
294+
295+
return actions
296+
.filter(action => !action.enabled || action.enabled([this.source], this.currentView))
297+
.sort((a, b) => (a.order || 0) - (b.order || 0))
298+
},
299+
273300
async onActionClick(action, isSubmenu = false) {
274301
// If the action is a submenu, we open it
275302
if (this.enabledSubmenuActions[action.id]) {

apps/files_reminders/src/actions/setReminderSuggestionActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const nextWeek: ReminderOption = {
6969
* @param option The option to generate the action for
7070
* @return The file action or null if the option should not be shown
7171
*/
72-
const generateFileAction = (option): FileAction|null => {
72+
const generateFileAction = (option: ReminderOption): FileAction|null => {
7373
const dateTime = getDateTime(option.dateTimePreset)
7474
if (!dateTime) {
7575
return null
@@ -83,7 +83,7 @@ const generateFileAction = (option): FileAction|null => {
8383
// Empty svg to hide the icon
8484
iconSvgInline: () => '<svg></svg>',
8585

86-
enabled: () => true,
86+
enabled: () => Boolean(getDateTime(option.dateTimePreset)),
8787
parent: SET_REMINDER_MENU_ID,
8888

8989
async exec(node: Node) {

0 commit comments

Comments
 (0)