aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src
diff options
context:
space:
mode:
authorfenn-cs <fenn25.fn@gmail.com>2024-11-06 16:50:59 +0100
committerskjnldsv <skjnldsv@protonmail.com>2024-11-08 16:20:19 +0100
commite581e11ae275cbc8d9b96dd1ed678563b2aab94e (patch)
treea5c975d0d87995331a2d2a3ee03bff150d4efd77 /apps/files_sharing/src
parentfcf11d58286bdac93460055d3f3a665036a2c55b (diff)
downloadnextcloud-server-e581e11ae275cbc8d9b96dd1ed678563b2aab94e.tar.gz
nextcloud-server-e581e11ae275cbc8d9b96dd1ed678563b2aab94e.zip
fix(SharingEntryLink): Show default password before create if any
Prevent silent addition of expiration date to shares. Prevent silent addition for password to shares. Both now have a `shareRequiresReview` check Resolves : https://github.com/nextcloud/server/issues/48860 Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
Diffstat (limited to 'apps/files_sharing/src')
-rw-r--r--apps/files_sharing/src/components/SharingEntryLink.vue50
1 files changed, 41 insertions, 9 deletions
diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue
index 8fb6b61e18b..41373ef0430 100644
--- a/apps/files_sharing/src/components/SharingEntryLink.vue
+++ b/apps/files_sharing/src/components/SharingEntryLink.vue
@@ -40,7 +40,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"
@@ -81,10 +81,18 @@
</template>
</NcActionInput>
+ <NcActionCheckbox v-if="hasDefaultExpirationDate"
+ :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="(hasDefaultExpirationDate || 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"
@@ -287,6 +295,7 @@ export default {
shareCreationComplete: false,
copySuccess: true,
copied: false,
+ defaultExpirationDateEnabled: false,
// Are we waiting for password/expiration date
pending: false,
@@ -460,14 +469,28 @@ export default {
*
* @return {boolean}
*/
+ pendingDataIsMissing() {
+ return this.pendingPassword || this.pendingEnforcedPassword || 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
+ },
+ hasDefaultExpirationDate() {
+ return (this.config.defaultExpirationDate instanceof Date || !isNaN(new Date(this.config.defaultExpirationDate).getTime())) && this.isPendingShare
},
- pendingExpirationDate() {
- return this.config.isDefaultExpireDateEnforced && this.share && !this.share.id
+
+ isPendingShare() {
+ return !!(this.share && !this.share.id)
+ },
+
+ shareRequiresReview() {
+ return this.defaultExpirationDateEnabled || this.config.enableLinkPasswordByDefault
},
sharePolicyHasRequiredProperties() {
@@ -570,6 +593,10 @@ export default {
return this.share.isFileRequest
},
},
+ mounted() {
+ this.defaultExpirationDateEnabled = this.config.defaultExpirationDate instanceof Date
+ this.share.expireDate = this.defaultExpirationDateEnabled ? this.formatDateToString(this.config.defaultExpirationDate) : ''
+ },
methods: {
/**
@@ -592,8 +619,10 @@ 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.sharePolicyHasRequiredProperties && this.requiredPropertiesMissing) || this.shareRequiresReview) {
this.pending = true
this.shareCreationComplete = false
@@ -827,6 +856,9 @@ export default {
this.onPasswordSubmit()
this.onNoteSubmit()
},
+ onDefaultExpirationDateEnabledChange(enabled) {
+ this.share.expireDate = enabled ? this.formatDateToString(this.config.defaultExpirationDate) : ''
+ },
/**
* Cancel the share creation