aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2023-04-11 12:28:36 +0200
committerGitHub <noreply@github.com>2023-04-11 12:28:36 +0200
commitc6645cbc46291d2621992b7f0bb087f115e849eb (patch)
tree4239c728272dbd2dd0fcdbf6fab84ca810e62c40 /apps/files/src
parenta16703d18183aa34a7e6ffcb9c9cb3756cfb0c2e (diff)
parent0b0dbb99d30fc8bfb0cb34e194f8b7412fbab5ca (diff)
downloadnextcloud-server-c6645cbc46291d2621992b7f0bb087f115e849eb.tar.gz
nextcloud-server-c6645cbc46291d2621992b7f0bb087f115e849eb.zip
Merge pull request #37633 from nextcloud/fix/trashbin
Trashbin followup fixes
Diffstat (limited to 'apps/files/src')
-rw-r--r--apps/files/src/components/BreadCrumbs.vue34
-rw-r--r--apps/files/src/components/FileEntry.vue6
-rw-r--r--apps/files/src/components/FilesListHeaderActions.vue17
-rw-r--r--apps/files/src/store/files.ts20
-rw-r--r--apps/files/src/store/paths.ts4
-rw-r--r--apps/files/src/store/userconfig.ts4
-rw-r--r--apps/files/src/views/FilesList.vue6
7 files changed, 68 insertions, 23 deletions
diff --git a/apps/files/src/components/BreadCrumbs.vue b/apps/files/src/components/BreadCrumbs.vue
index d2f8610e9ca..c2938c5aca2 100644
--- a/apps/files/src/components/BreadCrumbs.vue
+++ b/apps/files/src/components/BreadCrumbs.vue
@@ -21,6 +21,9 @@ import NcBreadcrumb from '@nextcloud/vue/dist/Components/NcBreadcrumb.js'
import NcBreadcrumbs from '@nextcloud/vue/dist/Components/NcBreadcrumbs.js'
import Vue from 'vue'
+import { useFilesStore } from '../store/files.ts'
+import { usePathsStore } from '../store/paths.ts'
+
export default Vue.extend({
name: 'BreadCrumbs',
@@ -37,7 +40,20 @@ export default Vue.extend({
},
},
+ setup() {
+ const filesStore = useFilesStore()
+ const pathsStore = usePathsStore()
+ return {
+ filesStore,
+ pathsStore,
+ }
+ },
+
computed: {
+ currentView() {
+ return this.$navigation.active
+ },
+
dirs() {
const cumulativePath = (acc) => (value) => (acc += `${value}/`)
// Generate a cumulative path for each path segment: ['/', '/foo', '/foo/bar', ...] etc
@@ -52,7 +68,7 @@ export default Vue.extend({
return {
dir,
exact: true,
- name: basename(dir),
+ name: this.getDirDisplayName(dir),
to,
}
})
@@ -60,6 +76,22 @@ export default Vue.extend({
},
methods: {
+ getNodeFromId(id) {
+ return this.filesStore.getNode(id)
+ },
+ getFileIdFromPath(path) {
+ return this.pathsStore.getPath(this.currentView?.id, path)
+ },
+ getDirDisplayName(path) {
+ if (path === '/') {
+ return t('files', 'Home')
+ }
+
+ const fileId = this.getFileIdFromPath(path)
+ const node = this.getNodeFromId(fileId)
+ return node?.attributes?.displayName || basename(path)
+ },
+
onClick(to) {
if (to?.query?.dir === this.$route.query.dir) {
this.$emit('reload')
diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue
index 130cd12367e..fca83cabbd1 100644
--- a/apps/files/src/components/FileEntry.vue
+++ b/apps/files/src/components/FileEntry.vue
@@ -63,6 +63,7 @@
<!-- Menu actions -->
<NcActions v-if="active"
ref="actionsMenu"
+ :disabled="source._loading"
:force-title="true"
:inline="enabledInlineActions.length">
<NcActionButton v-for="action in enabledMenuActions"
@@ -433,7 +434,10 @@ export default Vue.extend({
async onActionClick(action) {
const displayName = action.displayName([this.source], this.currentView)
try {
+ // Set the loading marker
this.loading = action.id
+ Vue.set(this.source, '_loading', true)
+
const success = await action.exec(this.source, this.currentView)
if (success) {
showSuccess(this.t('files', '"{displayName}" action executed successfully', { displayName }))
@@ -444,7 +448,9 @@ export default Vue.extend({
logger.error('Error while executing action', { action, e })
showError(this.t('files', '"{displayName}" action failed', { displayName }))
} finally {
+ // Reset the loading marker
this.loading = ''
+ Vue.set(this.source, '_loading', false)
}
},
diff --git a/apps/files/src/components/FilesListHeaderActions.vue b/apps/files/src/components/FilesListHeaderActions.vue
index b7d48f1de25..d60fd81ad00 100644
--- a/apps/files/src/components/FilesListHeaderActions.vue
+++ b/apps/files/src/components/FilesListHeaderActions.vue
@@ -22,7 +22,7 @@
<template>
<th class="files-list__column files-list__row-actions-batch" colspan="2">
<NcActions ref="actionsMenu"
- :disabled="!!loading"
+ :disabled="!!loading || areSomeNodesLoading"
:force-title="true"
:inline="3">
<NcActionButton v-for="action in enabledActions"
@@ -105,6 +105,10 @@ export default Vue.extend({
.map(fileid => this.getNode(fileid))
.filter(node => node)
},
+
+ areSomeNodesLoading() {
+ return this.nodes.some(node => node._loading)
+ },
},
methods: {
@@ -122,9 +126,16 @@ export default Vue.extend({
const displayName = action.displayName(this.nodes, this.currentView)
const selectionIds = this.selectedNodes
try {
+ // Set loading markers
this.loading = action.id
+ this.nodes.forEach(node => {
+ Vue.set(node, '_loading', true)
+ })
+
+ // Dispatch action execution
const results = await action.execBatch(this.nodes, this.currentView)
+ // Handle potential failures
if (results.some(result => result !== true)) {
// Remove the failed ids from the selection
const failedIds = selectionIds
@@ -142,7 +153,11 @@ export default Vue.extend({
logger.error('Error while executing action', { action, e })
showError(this.t('files', '"{displayName}" action failed', { displayName }))
} finally {
+ // Remove loading markers
this.loading = null
+ this.nodes.forEach(node => {
+ Vue.set(node, '_loading', false)
+ })
}
},
diff --git a/apps/files/src/store/files.ts b/apps/files/src/store/files.ts
index f3289378096..27b6b12f348 100644
--- a/apps/files/src/store/files.ts
+++ b/apps/files/src/store/files.ts
@@ -81,34 +81,26 @@ export const useFilesStore = () => {
Vue.set(this.roots, service, root)
},
- onCreatedNode() {
- // TODO: do something
- },
-
onDeletedNode(node: Node) {
this.deleteNodes([node])
},
-
- onMovedNode() {
- // TODO: do something
- },
}
})
const fileStore = store()
// Make sure we only register the listeners once
- if (!fileStore.initialized) {
- subscribe('files:file:created', fileStore.onCreatedNode)
+ if (!fileStore._initialized) {
+ // subscribe('files:file:created', fileStore.onCreatedNode)
subscribe('files:file:deleted', fileStore.onDeletedNode)
- subscribe('files:file:moved', fileStore.onMovedNode)
+ // subscribe('files:file:moved', fileStore.onMovedNode)
// subscribe('files:file:updated', fileStore.onUpdatedNode)
- subscribe('files:folder:created', fileStore.onCreatedNode)
+ // subscribe('files:folder:created', fileStore.onCreatedNode)
subscribe('files:folder:deleted', fileStore.onDeletedNode)
- subscribe('files:folder:moved', fileStore.onMovedNode)
+ // subscribe('files:folder:moved', fileStore.onMovedNode)
// subscribe('files:folder:updated', fileStore.onUpdatedNode)
- fileStore.initialized = true
+ fileStore._initialized = true
}
return fileStore
diff --git a/apps/files/src/store/paths.ts b/apps/files/src/store/paths.ts
index b0f9552f606..8e458eb87b0 100644
--- a/apps/files/src/store/paths.ts
+++ b/apps/files/src/store/paths.ts
@@ -56,13 +56,13 @@ export const usePathsStore = () => {
const pathsStore = store()
// Make sure we only register the listeners once
- if (!pathsStore.initialized) {
+ if (!pathsStore._initialized) {
// TODO: watch folders to update paths?
// subscribe('files:folder:created', pathsStore.onCreatedNode)
// subscribe('files:folder:deleted', pathsStore.onDeletedNode)
// subscribe('files:folder:moved', pathsStore.onMovedNode)
- pathsStore.initialized = true
+ pathsStore._initialized = true
}
return pathsStore
diff --git a/apps/files/src/store/userconfig.ts b/apps/files/src/store/userconfig.ts
index f771de7cc5c..05d63c95424 100644
--- a/apps/files/src/store/userconfig.ts
+++ b/apps/files/src/store/userconfig.ts
@@ -63,11 +63,11 @@ export const useUserConfigStore = () => {
const userConfigStore = store()
// Make sure we only register the listeners once
- if (!userConfigStore.initialized) {
+ if (!userConfigStore._initialized) {
subscribe('files:config:updated', function({ key, value }: { key: string, value: boolean }) {
userConfigStore.onUpdate(key, value)
})
- userConfigStore.initialized = true
+ userConfigStore._initialized = true
}
return userConfigStore
diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue
index c8d539113ce..fad161a56ec 100644
--- a/apps/files/src/views/FilesList.vue
+++ b/apps/files/src/views/FilesList.vue
@@ -175,13 +175,13 @@ export default Vue.extend({
// Custom column must provide their own sorting methods
if (customColumn?.sort && typeof customColumn.sort === 'function') {
- const results = [...(this.currentFolder?.children || []).map(this.getNode).filter(file => file)]
+ const results = [...(this.currentFolder?._children || []).map(this.getNode).filter(file => file)]
.sort(customColumn.sort)
return this.isAscSorting ? results : results.reverse()
}
return orderBy(
- [...(this.currentFolder?.children || []).map(this.getNode).filter(file => file)],
+ [...(this.currentFolder?._children || []).map(this.getNode).filter(file => file)],
[
// Sort folders first if sorting by name
...this.sortingMode === 'basename' ? [v => v.type !== 'folder'] : [],
@@ -272,7 +272,7 @@ export default Vue.extend({
this.filesStore.updateNodes(contents)
// Define current directory children
- folder.children = contents.map(node => node.attributes.fileid)
+ folder._children = contents.map(node => node.attributes.fileid)
// If we're in the root dir, define the root
if (dir === '/') {