Skip to content

Commit

Permalink
fix(files_sharing): Do not nothing pre-create share actions menu closed
Browse files Browse the repository at this point in the history
- This fixes the issue of having the refresh the UI after share creation, as the share is not
immediately removed from the UI list.

- We explicitly call cancel, when the cancel button is pressed, if click-outside, it's okay
to do nothing, new share proccesses starts with a new share object.

Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
  • Loading branch information
Fenn-CS committed Apr 8, 2024
1 parent d4cea1c commit 22c9019
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
34 changes: 29 additions & 5 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export default {
data() {
return {
shareCreationComplete: false,
showDropdown: false,
copySuccess: true,
copied: false,
Expand Down Expand Up @@ -296,7 +297,7 @@ export default {
* @return {string}
*/
subtitle() {
if (this.isEmailShareType
if (this.isEmailShareTypef
&& this.title !== this.share.shareWith) {
return this.share.shareWith
}
Expand Down Expand Up @@ -483,6 +484,7 @@ export default {
* Create a new share link and append it to the list
*/
async onNewLinkShare() {
console.log('Level 0')

Check failure on line 487 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
// do not run again if already loading
if (this.loading) {
return
Expand All @@ -500,13 +502,17 @@ export default {
// do not push yet if we need a password or an expiration date: show pending menu
if (this.config.enableLinkPasswordByDefault || this.config.enforcePasswordForPublicLink || this.config.isDefaultExpireDateEnforced) {
this.pending = true
this.shareCreationComplete = false
// if a share already exists, pushing it
if (this.share && !this.share.id) {
// if the share is valid, create it on the server
if (this.checkShare(this.share)) {
try {
await this.pushNewLinkShare(this.share, true)
console.log('Level 1')

Check failure on line 512 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
debugger

Check failure on line 513 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected 'debugger' statement
const success = await this.pushNewLinkShare(this.share, true)
console.log('Level 2', success)

Check failure on line 515 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
} catch (e) {
this.pending = false
console.error(e)
Expand Down Expand Up @@ -536,12 +542,17 @@ export default {
// freshly created share component
this.open = false
this.pending = false
this.shareCreationComplete = true
component.open = true
console.log('Level 3')

Check failure on line 547 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
// Nothing is enforced, creating share directly
} else {
const share = new Share(shareDefaults)
console.log('Level 4')

Check failure on line 552 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
await this.pushNewLinkShare(share)
this.shareCreationComplete = true
console.log('Level 5')

Check failure on line 555 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
}
},
Expand Down Expand Up @@ -582,7 +593,6 @@ export default {
this.open = false
console.debug('Link share created', newShare)
// if share already exists, copy link directly on next tick
let component
if (update) {
Expand All @@ -609,13 +619,17 @@ export default {
showSuccess(t('files_sharing', 'Link share created'))
} catch (data) {
console.log('Error null')

Check failure on line 622 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
const message = data?.response?.data?.ocs?.meta?.message
if (!message) {
showError(t('files_sharing', 'Error while creating the share'))
console.error(data)
console.log('Error a')

Check failure on line 627 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
return
}
console.log('Error b')

Check failure on line 631 in apps/files_sharing/src/components/SharingEntryLink.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
if (message.match(/password/i)) {
this.onSyncError('password', message)
} else if (message.match(/date/i)) {
Expand All @@ -624,8 +638,13 @@ export default {
this.onSyncError('pending', message)
}
throw data
console.log('Error c')
} finally {
this.loading = false
this.shareCreationComplete = true
console.log('End of share creation')
}
},
async copyLink() {
Expand Down Expand Up @@ -723,12 +742,17 @@ export default {
/**
* Cancel the share creation
* Used in the pending popover
*
* @param e
*/
onCancel() {
onCancel(e) {
console.log("SHARE COMPLETE", this.shareCreationComplete)
// this.share already exists at this point,
// but is incomplete as not pushed to server
// YET. We can safely delete the share :)
this.$emit('remove:share', this.share)
if (!this.shareCreationComplete) {
this.$emit('remove:share', this.share)
}
},
toggleQuickShareSelect() {
Expand Down
1 change: 1 addition & 0 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ export default {
this.share = share
this.$emit('add:share', this.share)
} else {
this.$emit('update:share', this.share)
this.queueUpdate(...permissionsAndAttributes)
}
Expand Down

0 comments on commit 22c9019

Please sign in to comment.