diff options
author | nfebe <fenn25.fn@gmail.com> | 2024-12-09 01:20:20 +0100 |
---|---|---|
committer | nfebe <fenn25.fn@gmail.com> | 2024-12-09 02:58:21 +0100 |
commit | 304926d13b0c3e803f7d98b82042ec19ce97b992 (patch) | |
tree | ce88d7620358701bfa09024493c18f2edf5e2221 | |
parent | 1b726cdb8e9a03e3a0148241c9d1794cd7c9463b (diff) | |
download | nextcloud-server-304926d13b0c3e803f7d98b82042ec19ce97b992.tar.gz nextcloud-server-304926d13b0c3e803f7d98b82042ec19ce97b992.zip |
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 <fenn25.fn@gmail.com>
-rw-r--r-- | apps/files_sharing/src/components/SharingEntryLink.vue | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue index 8feeb92990e..296289a1ad5 100644 --- a/apps/files_sharing/src/components/SharingEntryLink.vue +++ b/apps/files_sharing/src/components/SharingEntryLink.vue @@ -87,7 +87,7 @@ </template> </NcActionInput> - <NcActionCheckbox v-if="hasDefaultExpirationDate" + <NcActionCheckbox v-if="pendingDefaultExpirationDate" :checked.sync="defaultExpirationDateEnabled" :disabled="pendingEnforcedExpirationDate || saving" class="share-link-expiration-date-checkbox" @@ -96,7 +96,7 @@ </NcActionCheckbox> <!-- expiration date --> - <NcActionInput v-if="(hasDefaultExpirationDate || pendingEnforcedExpirationDate) && defaultExpirationDateEnabled" + <NcActionInput v-if="(pendingDefaultExpirationDate || pendingEnforcedExpirationDate) && defaultExpirationDateEnabled" class="share-link-expire-date" :label="pendingEnforcedExpirationDate ? t('files_sharing', 'Enter expiration date (enforced)') : t('files_sharing', 'Enter expiration date')" :disabled="saving" @@ -112,7 +112,10 @@ </template> </NcActionInput> - <NcActionButton icon="icon-checkmark" @click.prevent.stop="onNewLinkShare"> + <NcActionButton @click.prevent.stop="onNewLinkShare(true)"> + <template #icon> + <CheckIcon :size="20" /> + </template> {{ t('files_sharing', 'Create share') }} </NcActionButton> <NcActionButton icon="icon-close" @click.prevent.stop="onCancel"> @@ -203,6 +206,8 @@ import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator. import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js' +import CheckIcon from 'vue-material-design-icons/CheckBold.vue' +import LockIcon from 'vue-material-design-icons/Lock.vue' import Tune from 'vue-material-design-icons/Tune.vue' import IconCalendarBlank from 'vue-material-design-icons/CalendarBlank.vue' @@ -219,6 +224,7 @@ export default { name: 'SharingEntryLink', components: { + CheckIcon, ExternalShareAction, NcActions, NcActionButton, @@ -228,6 +234,7 @@ export default { NcActionText, NcActionSeparator, NcAvatar, + LockIcon, Tune, IconCalendarBlank, SharingEntryQuickShareSelect, @@ -413,7 +420,7 @@ export default { * @return {boolean} */ pendingDataIsMissing() { - return this.pendingPassword || this.pendingEnforcedPassword || this.pendingEnforcedExpirationDate + return this.pendingPassword || this.pendingEnforcedPassword || this.pendingDefaultExpirationDate || this.pendingEnforcedExpirationDate }, pendingPassword() { return this.config.enableLinkPasswordByDefault && this.isPendingShare @@ -424,18 +431,13 @@ export default { pendingEnforcedExpirationDate() { return this.config.isDefaultExpireDateEnforced && this.isPendingShare }, - hasDefaultExpirationDate() { + pendingDefaultExpirationDate() { return (this.config.defaultExpirationDate instanceof Date || !isNaN(new Date(this.config.defaultExpirationDate).getTime())) && this.isPendingShare }, isPendingShare() { return !!(this.share && !this.share.id) }, - - shareRequiresReview() { - return this.defaultExpirationDateEnabled || this.config.enableLinkPasswordByDefault - }, - sharePolicyHasRequiredProperties() { return this.config.enforcePasswordForPublicLink || this.config.isDefaultExpireDateEnforced }, @@ -547,9 +549,23 @@ export default { 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) { @@ -569,11 +585,11 @@ export default { // 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.sharePolicyHasRequiredProperties && this.requiredPropertiesMissing) || this.shareRequiresReview) { + 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 |