aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorF. E Noel Nfebe <fenn25.fn@gmail.com>2024-06-25 20:51:39 +0100
committerGitHub <noreply@github.com>2024-06-25 20:51:39 +0100
commitf0182226d4986e00825f919eed9f20f0f0723e50 (patch)
treec1b9f26ab9f5bcbad6b8016336a5850f20bc8d89 /apps
parent952271929d888c8333f5b64aa676f802a8b682af (diff)
parent574669697bdb9f0327e390d647c7c31234e6e4a9 (diff)
downloadnextcloud-server-f0182226d4986e00825f919eed9f20f0f0723e50.tar.gz
nextcloud-server-f0182226d4986e00825f919eed9f20f0f0723e50.zip
Merge pull request #46030 from nextcloud/fix/44961/shared-state-file-list
fix(FilesView): Update files view upon share creation/delete
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/src/components/SharingEntryLink.vue8
-rw-r--r--apps/files_sharing/src/mixins/SharesMixin.js24
-rw-r--r--apps/files_sharing/src/services/WebdavClient.ts18
-rw-r--r--apps/files_sharing/src/views/SharingDetailsTab.vue22
4 files changed, 61 insertions, 11 deletions
diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue
index d5cb61f7ee7..cf2338fc4c4 100644
--- a/apps/files_sharing/src/components/SharingEntryLink.vue
+++ b/apps/files_sharing/src/components/SharingEntryLink.vue
@@ -134,7 +134,7 @@
{{ t('files_sharing', 'Customize link') }}
</NcActionButton>
</template>
-
+
<NcActionButton :close-after-click="true"
@click.prevent="showQRCode = true">
<template #icon>
@@ -210,11 +210,12 @@
</template>
<script>
+import { emit } from '@nextcloud/event-bus'
import { generateUrl } from '@nextcloud/router'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { Type as ShareTypes } from '@nextcloud/sharing'
import Vue from 'vue'
-import VueQrcode from '@chenfengyuan/vue-qrcode';
+import VueQrcode from '@chenfengyuan/vue-qrcode'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionInput from '@nextcloud/vue/dist/Components/NcActionInput.js'
@@ -686,6 +687,9 @@ export default {
})
}
+ await this.getNode()
+ emit('files:node:updated', this.node)
+
// Execute the copy link method
// freshly created share component
// ! somehow does not works on firefox !
diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js
index 23cc4fd343e..0d570b16918 100644
--- a/apps/files_sharing/src/mixins/SharesMixin.js
+++ b/apps/files_sharing/src/mixins/SharesMixin.js
@@ -3,6 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+import { emit } from '@nextcloud/event-bus'
+import { fetchNode } from '../services/WebdavClient.ts'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { getCurrentUser } from '@nextcloud/auth'
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
@@ -13,6 +15,7 @@ import Share from '../models/Share.js'
import SharesRequests from './ShareRequests.js'
import ShareTypes from './ShareTypes.js'
import Config from '../services/ConfigService.js'
+import logger from '../services/logger.ts'
import {
BUNDLED_PERMISSIONS,
@@ -40,6 +43,7 @@ export default {
data() {
return {
config: new Config(),
+ node: null,
// errors helpers
errors: {},
@@ -62,7 +66,9 @@ export default {
},
computed: {
-
+ path() {
+ return (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/')
+ },
/**
* Does the current share have a note
*
@@ -150,6 +156,20 @@ export default {
methods: {
/**
+ * Fetch webdav node
+ *
+ * @return {Node}
+ */
+ async getNode() {
+ const node = { path: this.path }
+ try {
+ this.node = await fetchNode(node)
+ logger.info('Fetched node:', { node: this.node })
+ } catch (error) {
+ logger.error('Error:', error)
+ }
+ },
+ /**
* Check if a share is valid before
* firing the request
*
@@ -247,6 +267,8 @@ export default {
: t('files_sharing', 'Folder "{path}" has been unshared', { path: this.share.path })
showSuccess(message)
this.$emit('remove:share', this.share)
+ await this.getNode()
+ emit('files:node:updated', this.node)
} catch (error) {
// re-open menu if error
this.open = true
diff --git a/apps/files_sharing/src/services/WebdavClient.ts b/apps/files_sharing/src/services/WebdavClient.ts
new file mode 100644
index 00000000000..cd33147b03f
--- /dev/null
+++ b/apps/files_sharing/src/services/WebdavClient.ts
@@ -0,0 +1,18 @@
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+import { davGetClient, davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files'
+import type { FileStat, ResponseDataDetailed } from 'webdav'
+import type { Node } from '@nextcloud/files'
+
+export const client = davGetClient()
+
+export const fetchNode = async (node: Node): Promise<Node> => {
+ const propfindPayload = davGetDefaultPropfind()
+ const result = await client.stat(`${davRootPath}${node.path}`, {
+ details: true,
+ data: propfindPayload,
+ }) as ResponseDataDetailed<FileStat>
+ return davResultToNode(result.data)
+}
diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue
index 9922caf4f4e..8254e84b4a3 100644
--- a/apps/files_sharing/src/views/SharingDetailsTab.vue
+++ b/apps/files_sharing/src/views/SharingDetailsTab.vue
@@ -245,6 +245,7 @@
</template>
<script>
+import { emit } from '@nextcloud/event-bus'
import { getLanguage } from '@nextcloud/l10n'
import { Type as ShareType } from '@nextcloud/sharing'
@@ -276,6 +277,7 @@ import Share from '../models/Share.js'
import ShareRequests from '../mixins/ShareRequests.js'
import ShareTypes from '../mixins/ShareTypes.js'
import SharesMixin from '../mixins/SharesMixin.js'
+import logger from '../services/logger.ts'
import {
ATOMIC_PERMISSIONS,
@@ -727,8 +729,8 @@ export default {
beforeMount() {
this.initializePermissions()
this.initializeAttributes()
- console.debug('shareSentIn', this.share)
- console.debug('config', this.config)
+ logger.debug('Share object received', { share: this.share })
+ logger.debug('Configuration object received', { config: this.config })
},
mounted() {
@@ -887,7 +889,7 @@ export default {
}
this.creating = true
- const share = await this.addShare(incomingShare, this.fileInfo)
+ const share = await this.addShare(incomingShare)
this.creating = false
this.share = share
this.$emit('add:share', this.share)
@@ -896,6 +898,9 @@ export default {
this.queueUpdate(...permissionsAndAttributes)
}
+ await this.getNode()
+ emit('files:node:updated', this.node)
+
if (this.$refs.externalLinkActions?.length > 0) {
await Promise.allSettled(this.$refs.externalLinkActions.map((action) => {
if (typeof action.$children.at(0)?.onSave !== 'function') {
@@ -911,12 +916,11 @@ export default {
* Process the new share request
*
* @param {Share} share incoming share object
- * @param {object} fileInfo file data
*/
- async addShare(share, fileInfo) {
- console.debug('Adding a new share from the input for', share)
+ async addShare(share) {
+ logger.debug('Adding a new share from the input for', { share })
+ const path = this.path
try {
- const path = (fileInfo.path + '/' + fileInfo.name).replace('//', '/')
const resultingShare = await this.createShare({
path,
shareType: share.shareType,
@@ -929,13 +933,15 @@ export default {
})
return resultingShare
} catch (error) {
- console.error('Error while adding new share', error)
+ logger.error('Error while adding new share', { error })
} finally {
// this.loading = false // No loader here yet
}
},
async removeShare() {
await this.onDelete()
+ await this.getNode()
+ emit('files:node:updated', this.node)
this.$emit('close-sharing-details')
},
/**