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

[stable29] fix(files_sharing): Stop infinite loop blocking link share requests #49723

Merged
merged 3 commits into from
Dec 9, 2024
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
65 changes: 53 additions & 12 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</div>

<!-- pending actions -->
<NcActions v-if="!pending && (pendingPassword || pendingEnforcedPassword || pendingExpirationDate)"
<NcActions v-if="!pending && pendingDataIsMissing"
class="sharing-entry__actions"
:aria-label="actionsTooltip"
menu-align="right"
Expand Down Expand Up @@ -98,10 +98,18 @@
</template>
</NcActionInput>

<NcActionCheckbox v-if="pendingDefaultExpirationDate"
:checked.sync="defaultExpirationDateEnabled"
:disabled="pendingEnforcedExpirationDate || saving"
class="share-link-expiration-date-checkbox"
@change="onDefaultExpirationDateEnabledChange">
{{ config.enforcePasswordForPublicLink ? t('files_sharing', 'Enable link expiration (enforced)') : t('files_sharing', 'Enable link expiration') }}
</NcActionCheckbox>

<!-- expiration date -->
<NcActionInput v-if="pendingExpirationDate"
<NcActionInput v-if="(pendingDefaultExpirationDate || pendingEnforcedExpirationDate) && defaultExpirationDateEnabled"
class="share-link-expire-date"
:label="t('files_sharing', 'Expiration date (enforced)')"
:label="pendingEnforcedExpirationDate ? t('files_sharing', 'Enter expiration date (enforced)') : t('files_sharing', 'Enter expiration date')"
:disabled="saving"
:is-native-picker="true"
:hide-label="true"
Expand All @@ -115,7 +123,7 @@
</template>
</NcActionInput>

<NcActionButton @click.prevent.stop="onNewLinkShare">
<NcActionButton @click.prevent.stop="onNewLinkShare(true)">
<template #icon>
<CheckIcon :size="20" />
</template>
Expand Down Expand Up @@ -304,6 +312,7 @@ export default {
shareCreationComplete: false,
copySuccess: true,
copied: false,
defaultExpirationDateEnabled: false,

// Are we waiting for password/expiration date
pending: false,
Expand Down Expand Up @@ -467,16 +476,25 @@ export default {
*
* @return {boolean}
*/
pendingDataIsMissing() {
return this.pendingPassword || this.pendingEnforcedPassword || this.pendingDefaultExpirationDate || this.pendingEnforcedExpirationDate
},
pendingPassword() {
return this.config.enableLinkPasswordByDefault && this.share && !this.share.id
return this.config.enableLinkPasswordByDefault && this.isPendingShare
},
pendingEnforcedPassword() {
return this.config.enforcePasswordForPublicLink && this.share && !this.share.id
return this.config.enforcePasswordForPublicLink && this.isPendingShare
},
pendingEnforcedExpirationDate() {
return this.config.isDefaultExpireDateEnforced && this.isPendingShare
},
pendingExpirationDate() {
return this.config.isDefaultExpireDateEnforced && this.share && !this.share.id
pendingDefaultExpirationDate() {
return (this.config.defaultExpirationDate instanceof Date || !isNaN(new Date(this.config.defaultExpirationDate).getTime())) && this.isPendingShare
},

isPendingShare() {
return !!(this.share && !this.share.id)
},
sharePolicyHasRequiredProperties() {
return this.config.enforcePasswordForPublicLink || this.config.isDefaultExpireDateEnforced
},
Expand Down Expand Up @@ -573,12 +591,30 @@ export default {
return this.fileInfo.shareAttributes.some(hasDisabledDownload)
},
},
mounted() {
this.defaultExpirationDateEnabled = this.config.defaultExpirationDate instanceof Date
this.share.expireDate = this.defaultExpirationDateEnabled ? this.formatDateToString(this.config.defaultExpirationDate) : ''
},

methods: {
/**
* Check if the share requires review
*
* @param {boolean} shareReviewComplete if the share was reviewed
* @return {boolean}
*/
shareRequiresReview(shareReviewComplete) {
// If a user clicks 'Create share' it means they have reviewed the share
if (shareReviewComplete) {
return false
}
return this.defaultExpirationDateEnabled || this.config.enableLinkPasswordByDefault
},
/**
* Create a new share link and append it to the list
* @param {boolean} shareReviewComplete if the share was reviewed
*/
async onNewLinkShare() {
async onNewLinkShare(shareReviewComplete = false) {
this.logger.debug('onNewLinkShare called (with this.share)', this.share)
// do not run again if already loading
if (this.loading) {
Expand All @@ -595,12 +631,14 @@ export default {
}

this.logger.debug('Missing required properties?', this.requiredPropertiesMissing)
// do not push yet if we need a password or an expiration date: show pending menu
if (this.sharePolicyHasRequiredProperties && this.requiredPropertiesMissing) {
// Do not push yet if we need a password or an expiration date: show pending menu
// A share would require a review for example is default expiration date is set but not enforced, this allows
// the user to review the share and remove the expiration date if they don't want it
if ((this.sharePolicyHasEnforcedProperties && this.enforcedPropertiesMissing) || this.shareRequiresReview(shareReviewComplete === true)) {
this.pending = true
this.shareCreationComplete = false

this.logger.info('Share policy requires mandated properties (password)...')
this.logger.info('Share policy requires a review or has mandated properties (password, expirationDate)...')

// ELSE, show the pending popovermenu
// if password default or enforced, pre-fill with random one
Expand Down Expand Up @@ -830,6 +868,9 @@ export default {
this.onPasswordSubmit()
this.onNoteSubmit()
},
onDefaultExpirationDateEnabledChange(enabled) {
this.share.expireDate = enabled ? this.formatDateToString(this.config.defaultExpirationDate) : ''
},

/**
* Cancel the share creation
Expand Down
3 changes: 3 additions & 0 deletions dist/2247-2247.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/2247-2247.js.map

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions dist/7445-7445.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/7445-7445.js.map

This file was deleted.

Loading
Loading