|
73 | 73 | <NcActionSeparator /> |
74 | 74 |
|
75 | 75 | <!-- Submenu actions --> |
76 | | - <NcActionButton v-for="action in enabledSubmenuActions[openedSubmenu?.id]" |
| 76 | + <NcActionButton v-for="action in reloadedSubmenuActions(openedSubmenu)" |
77 | 77 | :key="action.id" |
78 | 78 | :class="`files-list__row-action-${action.id}`" |
79 | 79 | class="files-list__row-action--submenu" |
@@ -108,6 +108,7 @@ import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js' |
108 | 108 |
|
109 | 109 | import CustomElementRender from '../CustomElementRender.vue' |
110 | 110 | import logger from '../../logger.js' |
| 111 | +import type { LogLevel } from '@nextcloud/logger' |
111 | 112 |
|
112 | 113 | // The registered actions list |
113 | 114 | const actions = getFileActions() |
@@ -270,6 +271,32 @@ export default Vue.extend({ |
270 | 271 | return action.displayName([this.source], this.currentView) |
271 | 272 | }, |
272 | 273 |
|
| 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 | +
|
273 | 300 | async onActionClick(action, isSubmenu = false) { |
274 | 301 | // If the action is a submenu, we open it |
275 | 302 | if (this.enabledSubmenuActions[action.id]) { |
|
0 commit comments