Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FilesView): Update files view upon share creation/delete #46030

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
{{ t('files_sharing', 'Customize link') }}
</NcActionButton>
</template>

<NcActionButton :close-after-click="true"
@click.prevent="showQRCode = true">
<template #icon>
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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 !
Expand Down
24 changes: 23 additions & 1 deletion apps/files_sharing/src/mixins/SharesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -40,6 +43,7 @@ export default {
data() {
return {
config: new Config(),
node: null,

// errors helpers
errors: {},
Expand All @@ -62,7 +66,9 @@ export default {
},

computed: {

path() {
return (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/')
},
/**
* Does the current share have a note
*
Expand Down Expand Up @@ -149,6 +155,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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions apps/files_sharing/src/services/WebdavClient.ts
Original file line number Diff line number Diff line change
@@ -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)
}
22 changes: 14 additions & 8 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
</template>

<script>
import { emit } from '@nextcloud/event-bus'
import { getLanguage } from '@nextcloud/l10n'
import { Type as ShareType } from '@nextcloud/sharing'

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 })
nfebe marked this conversation as resolved.
Show resolved Hide resolved
},

mounted() {
Expand Down Expand Up @@ -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)
Expand All @@ -896,6 +898,9 @@ export default {
this.queueUpdate(...permissionsAndAttributes)
}

await this.getNode()
emit('files:node:updated', this.node)
nfebe marked this conversation as resolved.
Show resolved Hide resolved

if (this.$refs.externalLinkActions?.length > 0) {
await Promise.allSettled(this.$refs.externalLinkActions.map((action) => {
if (typeof action.$children.at(0)?.onSave !== 'function') {
Expand All @@ -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,
Expand All @@ -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')
},
/**
Expand Down
2 changes: 2 additions & 0 deletions dist/1345-1345.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions dist/5733-5733.js.license → dist/1345-1345.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SPDX-FileCopyrightText: Julius Härtl <jus@bitgrid.net>
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Jordan Harband <ljharb@gmail.com>
SPDX-FileCopyrightText: Jordan Harband
SPDX-FileCopyrightText: Jonas Schade <derzade@gmail.com>
SPDX-FileCopyrightText: John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
SPDX-FileCopyrightText: Jerry Bendy <jerry@icewingcc.com>
Expand All @@ -45,11 +46,13 @@ SPDX-FileCopyrightText: Eric Norris (https://github.com/ericnorris)
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <mario@cure53.de> (https://cure53.de/)
SPDX-FileCopyrightText: Denis Pushkarev
SPDX-FileCopyrightText: David Clark
SPDX-FileCopyrightText: Christoph Wurst <christoph@winzerhof-wurst.at>
SPDX-FileCopyrightText: Christoph Wurst
SPDX-FileCopyrightText: Chen Fengyuan
SPDX-FileCopyrightText: Arnout Kazemier
SPDX-FileCopyrightText: Anthony Fu <https://github.com/antfu>
SPDX-FileCopyrightText: Andris Reinman
SPDX-FileCopyrightText: Alkemics
SPDX-FileCopyrightText: @nextcloud/dialogs developers


Expand Down Expand Up @@ -81,6 +84,12 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/event-bus
- version: 3.3.1
- license: GPL-3.0-or-later
- @nextcloud/l10n
- version: 3.1.0
- license: GPL-3.0-or-later
- @nextcloud/files
- version: 3.5.1
- license: AGPL-3.0-or-later
- @nextcloud/initial-state
- version: 2.2.0
- license: GPL-3.0-or-later
Expand Down Expand Up @@ -147,6 +156,9 @@ This file is generated from multiple sources. Included packages:
- call-bind
- version: 1.0.7
- license: MIT
- cancelable-promise
- version: 4.3.1
- license: MIT
- charenc
- version: 0.0.2
- license: BSD-3-Clause
Expand Down Expand Up @@ -309,6 +321,9 @@ This file is generated from multiple sources. Included packages:
- toastify-js
- version: 1.12.0
- license: MIT
- typescript-event-target
- version: 1.1.1
- license: MIT
- unist-builder
- version: 4.0.0
- license: MIT
Expand Down
1 change: 1 addition & 0 deletions dist/1345-1345.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/1345-1345.js.map.license
4 changes: 2 additions & 2 deletions dist/5455-5455.js

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions dist/5455-5455.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ SPDX-FileCopyrightText: Roeland Jago Douma
SPDX-FileCopyrightText: Richie Bendall
SPDX-FileCopyrightText: Raynos <raynos2@gmail.com>
SPDX-FileCopyrightText: Philipp Kewisch
SPDX-FileCopyrightText: Perry Mitchell <perry@perrymitchell.net>
SPDX-FileCopyrightText: Paul Vorbach <paul@vorba.ch> (http://paul.vorba.ch)
SPDX-FileCopyrightText: Paul Vorbach <paul@vorb.de> (http://vorb.de)
SPDX-FileCopyrightText: OpenJS Foundation and other contributors
Expand Down Expand Up @@ -110,9 +109,6 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/l10n
- version: 3.1.0
- license: GPL-3.0-or-later
- @nextcloud/sharing
- version: 0.2.2
- license: GPL-3.0-or-later
- @nextcloud/files
- version: 3.5.1
- license: AGPL-3.0-or-later
Expand Down Expand Up @@ -587,9 +583,6 @@ This file is generated from multiple sources. Included packages:
- web-namespaces
- version: 2.0.1
- license: MIT
- webdav
- version: 5.6.0
- license: MIT
- which-typed-array
- version: 1.1.14
- license: MIT
Expand Down
2 changes: 1 addition & 1 deletion dist/5455-5455.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions dist/5733-5733.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/5733-5733.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/5733-5733.js.map.license

This file was deleted.

4 changes: 2 additions & 2 deletions dist/6778-6778.js

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions dist/6778-6778.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ SPDX-FileCopyrightText: Stefan-Gabriel Muscalu <stefan.gabriel.muscalu@gmail.com
SPDX-FileCopyrightText: Sindre Sorhus
SPDX-FileCopyrightText: Roman Shtylman <shtylman@gmail.com>
SPDX-FileCopyrightText: Raynos <raynos2@gmail.com>
SPDX-FileCopyrightText: Perry Mitchell <perry@perrymitchell.net>
SPDX-FileCopyrightText: Matt Zabriskie
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Jordan Harband <ljharb@gmail.com>
Expand Down Expand Up @@ -58,9 +57,6 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/l10n
- version: 3.1.0
- license: GPL-3.0-or-later
- @nextcloud/sharing
- version: 0.2.2
- license: GPL-3.0-or-later
- @nextcloud/files
- version: 3.5.1
- license: AGPL-3.0-or-later
Expand Down Expand Up @@ -256,9 +252,6 @@ This file is generated from multiple sources. Included packages:
- vue
- version: 2.7.16
- license: MIT
- webdav
- version: 5.6.0
- license: MIT
- which-typed-array
- version: 1.1.14
- license: MIT
2 changes: 1 addition & 1 deletion dist/6778-6778.js.map

Large diffs are not rendered by default.

Loading
Loading