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

[stable19] Avoid creating two share links when password is enforced #25741

Merged
merged 1 commit into from
Mar 1, 2021
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
2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing_tab.js.map

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</Actions>

<!-- pending actions -->
<Actions v-if="!loading && (pendingPassword || pendingExpirationDate)"
<Actions v-if="!pending && (pendingPassword || pendingExpirationDate)"
class="sharing-entry__actions"
menu-align="right"
:open.sync="open"
Expand Down Expand Up @@ -284,7 +284,7 @@
<!-- Create new share -->
<ActionButton v-else-if="canReshare"
class="new-share-link"
icon="icon-add"
:icon="loading ? 'icon-loading-small' : 'icon-add'"
@click.prevent.stop="onNewLinkShare">
{{ t('files_sharing', 'Create a new share link') }}
</ActionButton>
Expand Down Expand Up @@ -349,6 +349,9 @@ export default {
copySuccess: true,
copied: false,

// Are we waiting for password/expiration date
pending: false,

publicUploadRWValue: OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE,
publicUploadRValue: OC.PERMISSION_READ,
publicUploadWValue: OC.PERMISSION_CREATE,
Expand Down Expand Up @@ -586,6 +589,11 @@ export default {
* Create a new share link and append it to the list
*/
async onNewLinkShare() {
// do not run again if already loading
if (this.loading) {
return
}

const shareDefaults = {
share_type: OC.Share.SHARE_TYPE_LINK,
}
Expand All @@ -598,11 +606,13 @@ export default {
shareDefaults.password = await this.generatePassword()
}

// do not push yet if we need a password or an expiration date
// do not push yet if we need a password or an expiration date: show pending menu
if (this.config.enforcePasswordForPublicLink || this.config.isDefaultExpireDateEnforced) {
this.loading = true
this.pending = true

// 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)) {
await this.pushNewLinkShare(this.share, true)
return true
Expand All @@ -628,10 +638,10 @@ export default {
// open the menu on the
// freshly created share component
this.open = false
this.loading = false
this.pending = false
component.open = true

// Nothing enforced, creating share directly
// Nothing is enforced, creating share directly
} else {
const share = new Share(shareDefaults)
await this.pushNewLinkShare(share)
Expand All @@ -648,6 +658,11 @@ export default {
*/
async pushNewLinkShare(share, update) {
try {
// do nothing if we're already pending creation
if (this.loading) {
return true
}

this.loading = true
this.errors = {}

Expand Down