]> source.dussan.org Git - nextcloud-server.git/commitdiff
Refactor migrated addShare method
authorfenn-cs <fenn25.fn@gmail.com>
Mon, 11 Sep 2023 12:55:19 +0000 (13:55 +0100)
committerfenn-cs <fenn25.fn@gmail.com>
Tue, 12 Sep 2023 19:50:49 +0000 (20:50 +0100)
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
apps/files_sharing/src/views/SharingDetailsTab.vue

index 6368bb20b9fa8fa925388622d10235019193882a..d77688df2d7ac2c59af258e749e874a70aac3dd0 100644 (file)
@@ -784,7 +784,7 @@ export default {
                                        incomingShare.password = this.share.password
                                }
 
-                               const share = await this.addShare(incomingShare, this.fileInfo, this.config)
+                               const share = await this.addShare(incomingShare, this.fileInfo)
                                this.share = share
                                this.$emit('add:share', this.share)
                        } else {
@@ -796,36 +796,33 @@ export default {
                /**
                 * Process the new share request
                 *
-                * @param {object} value the multiselect option
+                * @param {Share} share incoming share object
                 * @param {object} fileInfo file data
-                * @param {Config} config instance configs
                 */
-               async addShare(value, fileInfo, config) {
-                       // Clear the displayed selection
-                       this.value = null
+               async addShare(share, fileInfo) {
 
                        // handle externalResults from OCA.Sharing.ShareSearch
-                       if (value.handler) {
-                               const share = await value.handler(this)
-                               this.$emit('add:share', new Share(share))
+                       if (share.handler) {
+                               const shareFromHandler = await share.handler(this)
+                               this.$emit('add:share', new Share(shareFromHandler))
                                return true
                        }
 
                        // this.loading = true // Are we adding loaders the new share flow?
-                       console.debug('Adding a new share from the input for', value)
+                       console.debug('Adding a new share from the input for', share)
                        try {
                                const path = (fileInfo.path + '/' + fileInfo.name).replace('//', '/')
-                               const share = await this.createShare({
+                               const resultingShare = await this.createShare({
                                        path,
-                                       shareType: value.shareType,
-                                       shareWith: value.shareWith,
-                                       permissions: value.permissions,
+                                       shareType: share.shareType,
+                                       shareWith: share.shareWith,
+                                       permissions: share.permissions,
                                        attributes: JSON.stringify(fileInfo.shareAttributes),
-                                       ...(value.note ? { note: value.note } : {}),
-                                       ...(value.password ? { password: value.password } : {}),
-                                       ...(value.expireDate ? { expireDate: value.expireDate } : {}),
+                                       ...(share.note ? { note: share.note } : {}),
+                                       ...(share.password ? { password: share.password } : {}),
+                                       ...(share.expireDate ? { expireDate: share.expireDate } : {}),
                                })
-                               return share
+                               return resultingShare
                        } catch (error) {
                                console.error('Error while adding new share', error)
                        } finally {