Skip to content

Commit 36ba9f2

Browse files
committed
fix(files): fix private variables and share loading marker between header and row
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
1 parent d6a5fba commit 36ba9f2

File tree

7 files changed

+31
-10
lines changed

7 files changed

+31
-10
lines changed

apps/files/src/components/FileEntry.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<!-- Menu actions -->
6464
<NcActions v-if="active"
6565
ref="actionsMenu"
66+
:disabled="source._loading"
6667
:force-title="true"
6768
:inline="enabledInlineActions.length">
6869
<NcActionButton v-for="action in enabledMenuActions"
@@ -433,7 +434,10 @@ export default Vue.extend({
433434
async onActionClick(action) {
434435
const displayName = action.displayName([this.source], this.currentView)
435436
try {
437+
// Set the loading marker
436438
this.loading = action.id
439+
Vue.set(this.source, '_loading', true)
440+
437441
const success = await action.exec(this.source, this.currentView)
438442
if (success) {
439443
showSuccess(this.t('files', '"{displayName}" action executed successfully', { displayName }))
@@ -444,7 +448,9 @@ export default Vue.extend({
444448
logger.error('Error while executing action', { action, e })
445449
showError(this.t('files', '"{displayName}" action failed', { displayName }))
446450
} finally {
451+
// Reset the loading marker
447452
this.loading = ''
453+
Vue.set(this.source, '_loading', false)
448454
}
449455
},
450456

apps/files/src/components/FilesListHeaderActions.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<template>
2323
<th class="files-list__column files-list__row-actions-batch" colspan="2">
2424
<NcActions ref="actionsMenu"
25-
:disabled="!!loading"
25+
:disabled="!!loading || areSomeNodesLoading"
2626
:force-title="true"
2727
:inline="3">
2828
<NcActionButton v-for="action in enabledActions"
@@ -105,6 +105,10 @@ export default Vue.extend({
105105
.map(fileid => this.getNode(fileid))
106106
.filter(node => node)
107107
},
108+
109+
areSomeNodesLoading() {
110+
return this.nodes.some(node => node._loading)
111+
},
108112
},
109113
110114
methods: {
@@ -122,9 +126,16 @@ export default Vue.extend({
122126
const displayName = action.displayName(this.nodes, this.currentView)
123127
const selectionIds = this.selectedNodes
124128
try {
129+
// Set loading markers
125130
this.loading = action.id
131+
this.nodes.forEach(node => {
132+
Vue.set(node, '_loading', true)
133+
})
134+
135+
// Dispatch action execution
126136
const results = await action.execBatch(this.nodes, this.currentView)
127137
138+
// Handle potential failures
128139
if (results.some(result => result !== true)) {
129140
// Remove the failed ids from the selection
130141
const failedIds = selectionIds
@@ -142,7 +153,11 @@ export default Vue.extend({
142153
logger.error('Error while executing action', { action, e })
143154
showError(this.t('files', '"{displayName}" action failed', { displayName }))
144155
} finally {
156+
// Remove loading markers
145157
this.loading = null
158+
this.nodes.forEach(node => {
159+
Vue.set(node, '_loading', false)
160+
})
146161
}
147162
},
148163

apps/files/src/views/FilesList.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ export default Vue.extend({
175175
176176
// Custom column must provide their own sorting methods
177177
if (customColumn?.sort && typeof customColumn.sort === 'function') {
178-
const results = [...(this.currentFolder?.children || []).map(this.getNode).filter(file => file)]
178+
const results = [...(this.currentFolder?._children || []).map(this.getNode).filter(file => file)]
179179
.sort(customColumn.sort)
180180
return this.isAscSorting ? results : results.reverse()
181181
}
182182
183183
return orderBy(
184-
[...(this.currentFolder?.children || []).map(this.getNode).filter(file => file)],
184+
[...(this.currentFolder?._children || []).map(this.getNode).filter(file => file)],
185185
[
186186
// Sort folders first if sorting by name
187187
...this.sortingMode === 'basename' ? [v => v.type !== 'folder'] : [],
@@ -272,7 +272,7 @@ export default Vue.extend({
272272
this.filesStore.updateNodes(contents)
273273
274274
// Define current directory children
275-
folder.children = contents.map(node => node.attributes.fileid)
275+
folder._children = contents.map(node => node.attributes.fileid)
276276
277277
// If we're in the root dir, define the root
278278
if (dir === '/') {

dist/core-common.js

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

dist/core-common.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.

dist/files-main.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-main.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)