Skip to content

Commit cfacd1e

Browse files
nfebebackportbot[bot]
authored andcommitted
fix(files_sharing): Stop infinite loop blocking link share requests
Fixes infinite loop preventing share link creation requests from being sent to the backend. Signed-off-by: nfebe <[email protected]> [skip ci]
1 parent d8efc7e commit cfacd1e

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
</template>
8282
</NcActionInput>
8383

84-
<NcActionCheckbox v-if="hasDefaultExpirationDate"
84+
<NcActionCheckbox v-if="pendingDefaultExpirationDate"
8585
:checked.sync="defaultExpirationDateEnabled"
8686
:disabled="pendingEnforcedExpirationDate || saving"
8787
class="share-link-expiration-date-checkbox"
@@ -90,7 +90,7 @@
9090
</NcActionCheckbox>
9191

9292
<!-- expiration date -->
93-
<NcActionInput v-if="(hasDefaultExpirationDate || pendingEnforcedExpirationDate) && defaultExpirationDateEnabled"
93+
<NcActionInput v-if="(pendingDefaultExpirationDate || pendingEnforcedExpirationDate) && defaultExpirationDateEnabled"
9494
class="share-link-expire-date"
9595
:label="pendingEnforcedExpirationDate ? t('files_sharing', 'Enter expiration date (enforced)') : t('files_sharing', 'Enter expiration date')"
9696
:disabled="saving"
@@ -106,7 +106,7 @@
106106
</template>
107107
</NcActionInput>
108108

109-
<NcActionButton @click.prevent.stop="onNewLinkShare">
109+
<NcActionButton @click.prevent.stop="onNewLinkShare(true)">
110110
<template #icon>
111111
<CheckIcon :size="20" />
112112
</template>
@@ -470,7 +470,7 @@ export default {
470470
* @return {boolean}
471471
*/
472472
pendingDataIsMissing() {
473-
return this.pendingPassword || this.pendingEnforcedPassword || this.pendingEnforcedExpirationDate
473+
return this.pendingPassword || this.pendingEnforcedPassword || this.pendingDefaultExpirationDate || this.pendingEnforcedExpirationDate
474474
},
475475
pendingPassword() {
476476
return this.config.enableLinkPasswordByDefault && this.isPendingShare
@@ -481,18 +481,13 @@ export default {
481481
pendingEnforcedExpirationDate() {
482482
return this.config.isDefaultExpireDateEnforced && this.isPendingShare
483483
},
484-
hasDefaultExpirationDate() {
484+
pendingDefaultExpirationDate() {
485485
return (this.config.defaultExpirationDate instanceof Date || !isNaN(new Date(this.config.defaultExpirationDate).getTime())) && this.isPendingShare
486486
},
487487
488488
isPendingShare() {
489489
return !!(this.share && !this.share.id)
490490
},
491-
492-
shareRequiresReview() {
493-
return this.defaultExpirationDateEnabled || this.config.enableLinkPasswordByDefault
494-
},
495-
496491
sharePolicyHasRequiredProperties() {
497492
return this.config.enforcePasswordForPublicLink || this.config.isDefaultExpireDateEnforced
498493
},
@@ -601,10 +596,24 @@ export default {
601596
},
602597
603598
methods: {
599+
/**
600+
* Check if the share requires review
601+
*
602+
* @param {boolean} shareReviewComplete if the share was reviewed
603+
* @return {boolean}
604+
*/
605+
shareRequiresReview(shareReviewComplete) {
606+
// If a user clicks 'Create share' it means they have reviewed the share
607+
if (shareReviewComplete) {
608+
return false
609+
}
610+
return this.defaultExpirationDateEnabled || this.config.enableLinkPasswordByDefault
611+
},
604612
/**
605613
* Create a new share link and append it to the list
614+
* @param {boolean} shareReviewComplete if the share was reviewed
606615
*/
607-
async onNewLinkShare() {
616+
async onNewLinkShare(shareReviewComplete = false) {
608617
this.logger.debug('onNewLinkShare called (with this.share)', this.share)
609618
// do not run again if already loading
610619
if (this.loading) {
@@ -624,11 +633,11 @@ export default {
624633
// Do not push yet if we need a password or an expiration date: show pending menu
625634
// A share would require a review for example is default expiration date is set but not enforced, this allows
626635
// the user to review the share and remove the expiration date if they don't want it
627-
if ((this.sharePolicyHasRequiredProperties && this.requiredPropertiesMissing) || this.shareRequiresReview) {
636+
if ((this.sharePolicyHasEnforcedProperties && this.enforcedPropertiesMissing) || this.shareRequiresReview(shareReviewComplete === true)) {
628637
this.pending = true
629638
this.shareCreationComplete = false
630639
631-
this.logger.info('Share policy requires mandated properties (password)...')
640+
this.logger.info('Share policy requires a review or has mandated properties (password, expirationDate)...')
632641
633642
// ELSE, show the pending popovermenu
634643
// if password default or enforced, pre-fill with random one

0 commit comments

Comments
 (0)