Merge pull request #25739 from nextcloud/backport/25602/stable21
[stable21] Avoid creating two share links when password is enforced
This commit is contained in:
commit
256927d8d4
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -44,7 +44,7 @@
|
||||||
</Actions>
|
</Actions>
|
||||||
|
|
||||||
<!-- pending actions -->
|
<!-- pending actions -->
|
||||||
<Actions v-if="!loading && (pendingPassword || pendingExpirationDate)"
|
<Actions v-if="!pending && (pendingPassword || pendingExpirationDate)"
|
||||||
class="sharing-entry__actions"
|
class="sharing-entry__actions"
|
||||||
menu-align="right"
|
menu-align="right"
|
||||||
:open.sync="open"
|
:open.sync="open"
|
||||||
|
@ -308,7 +308,7 @@
|
||||||
<!-- Create new share -->
|
<!-- Create new share -->
|
||||||
<ActionButton v-else-if="canReshare"
|
<ActionButton v-else-if="canReshare"
|
||||||
class="new-share-link"
|
class="new-share-link"
|
||||||
icon="icon-add"
|
:icon="loading ? 'icon-loading-small' : 'icon-add'"
|
||||||
@click.prevent.stop="onNewLinkShare">
|
@click.prevent.stop="onNewLinkShare">
|
||||||
{{ t('files_sharing', 'Create a new share link') }}
|
{{ t('files_sharing', 'Create a new share link') }}
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
|
@ -373,6 +373,9 @@ export default {
|
||||||
copySuccess: true,
|
copySuccess: true,
|
||||||
copied: false,
|
copied: false,
|
||||||
|
|
||||||
|
// Are we waiting for password/expiration date
|
||||||
|
pending: false,
|
||||||
|
|
||||||
publicUploadRWValue: OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE,
|
publicUploadRWValue: OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE,
|
||||||
publicUploadRValue: OC.PERMISSION_READ,
|
publicUploadRValue: OC.PERMISSION_READ,
|
||||||
publicUploadWValue: OC.PERMISSION_CREATE,
|
publicUploadWValue: OC.PERMISSION_CREATE,
|
||||||
|
@ -618,6 +621,11 @@ export default {
|
||||||
* Create a new share link and append it to the list
|
* Create a new share link and append it to the list
|
||||||
*/
|
*/
|
||||||
async onNewLinkShare() {
|
async onNewLinkShare() {
|
||||||
|
// do not run again if already loading
|
||||||
|
if (this.loading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const shareDefaults = {
|
const shareDefaults = {
|
||||||
share_type: OC.Share.SHARE_TYPE_LINK,
|
share_type: OC.Share.SHARE_TYPE_LINK,
|
||||||
}
|
}
|
||||||
|
@ -630,11 +638,13 @@ export default {
|
||||||
shareDefaults.password = await this.generatePassword()
|
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) {
|
if (this.config.enforcePasswordForPublicLink || this.config.isDefaultExpireDateEnforced) {
|
||||||
this.loading = true
|
this.pending = true
|
||||||
|
|
||||||
// if a share already exists, pushing it
|
// if a share already exists, pushing it
|
||||||
if (this.share && !this.share.id) {
|
if (this.share && !this.share.id) {
|
||||||
|
// if the share is valid, create it on the server
|
||||||
if (this.checkShare(this.share)) {
|
if (this.checkShare(this.share)) {
|
||||||
await this.pushNewLinkShare(this.share, true)
|
await this.pushNewLinkShare(this.share, true)
|
||||||
return true
|
return true
|
||||||
|
@ -660,10 +670,10 @@ export default {
|
||||||
// open the menu on the
|
// open the menu on the
|
||||||
// freshly created share component
|
// freshly created share component
|
||||||
this.open = false
|
this.open = false
|
||||||
this.loading = false
|
this.pending = false
|
||||||
component.open = true
|
component.open = true
|
||||||
|
|
||||||
// Nothing enforced, creating share directly
|
// Nothing is enforced, creating share directly
|
||||||
} else {
|
} else {
|
||||||
const share = new Share(shareDefaults)
|
const share = new Share(shareDefaults)
|
||||||
await this.pushNewLinkShare(share)
|
await this.pushNewLinkShare(share)
|
||||||
|
@ -680,6 +690,11 @@ export default {
|
||||||
*/
|
*/
|
||||||
async pushNewLinkShare(share, update) {
|
async pushNewLinkShare(share, update) {
|
||||||
try {
|
try {
|
||||||
|
// do nothing if we're already pending creation
|
||||||
|
if (this.loading) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.errors = {}
|
this.errors = {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue