diff options
author | fenn-cs <fenn25.fn@gmail.com> | 2023-09-19 11:57:43 +0100 |
---|---|---|
committer | nextcloud-command <nextcloud-command@users.noreply.github.com> | 2023-09-20 16:43:12 +0000 |
commit | 56771b50c45172ddb2bf4e125a7981528fdb4a77 (patch) | |
tree | dfdbdf57f2aee424a813cfe8e49a1f1570523ecb /apps | |
parent | 09794b67922bf9da70fc6207486d1be5a3898e41 (diff) | |
download | nextcloud-server-56771b50c45172ddb2bf4e125a7981528fdb4a77.tar.gz nextcloud-server-56771b50c45172ddb2bf4e125a7981528fdb4a77.zip |
Consider share type for enforced share expiry dates
We have three kind of share expiry date enforcements.
- `isDefaultExpireDateEnforced`
- `isDefaultInternalExpireDateEnforced`
- `isDefaultRemoteExpireDateEnforced`
Before these commit, `isExpiryDateEnforced` that is used to
disable/enable the set expiry date checkbox does not take those into consideration
which is problematic as those have different applications.
In addition, this commit now uses `isExpiryDateEnforced` to disable/enable the input for
expiry date that shows up before the creation of link shares.
Here, `hasExpirationDate` is also removed from 'SharingEntryLink` component as it is
not used.
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/src/components/SharingEntryLink.vue | 24 | ||||
-rw-r--r-- | apps/files_sharing/src/mixins/SharesMixin.js | 9 | ||||
-rw-r--r-- | apps/files_sharing/src/views/SharingDetailsTab.vue | 13 |
3 files changed, 18 insertions, 28 deletions
diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue index bb5c8ab52b4..896ca1bbc95 100644 --- a/apps/files_sharing/src/components/SharingEntryLink.vue +++ b/apps/files_sharing/src/components/SharingEntryLink.vue @@ -97,7 +97,7 @@ </NcActionText> <NcActionInput v-if="pendingExpirationDate" class="share-link-expire-date" - :disabled="saving" + :disabled="saving || isExpiryDateEnforced" :is-native-picker="true" :hide-label="true" :value="new Date(share.expireDate)" @@ -302,34 +302,12 @@ export default { } return null }, - - /** - * Does the current share have an expiration date - * - * @return {boolean} - */ - hasExpirationDate: { - get() { - return this.config.isDefaultExpireDateEnforced - || !!this.share.expireDate - }, - set(enabled) { - const defaultExpirationDate = this.config.defaultExpirationDate - || new Date(new Date().setDate(new Date().getDate() + 1)) - this.share.expireDate = enabled - ? this.formatDateToString(defaultExpirationDate) - : '' - console.debug('Expiration date status', enabled, this.share.expireDate) - }, - }, - dateMaxEnforced() { if (this.config.isDefaultExpireDateEnforced) { return new Date(new Date().setDate(new Date().getDate() + this.config.defaultExpireDate)) } return null }, - /** * Is the current share password protected ? * diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js index aba1462248a..2dfcc3e9c0e 100644 --- a/apps/files_sharing/src/mixins/SharesMixin.js +++ b/apps/files_sharing/src/mixins/SharesMixin.js @@ -135,6 +135,15 @@ export default { isShareOwner() { return this.share && this.share.owner === getCurrentUser().uid }, + isExpiryDateEnforced() { + if (this.isPublicShare) { + return this.config.isDefaultExpireDateEnforced + } + if (this.isRemoteShare) { + return this.config.isDefaultRemoteExpireDateEnforced || this.config.isDefaultExpireDateEnforced + } + return this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced + }, hasCustomPermissions() { const bundledPermissions = [ BUNDLED_PERMISSIONS.ALL, diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue index 7c68e50b1c1..429034c4520 100644 --- a/apps/files_sharing/src/views/SharingDetailsTab.vue +++ b/apps/files_sharing/src/views/SharingDetailsTab.vue @@ -368,7 +368,13 @@ export default { */ hasExpirationDate: { get() { - return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced + if (this.isPublicShare) { + return !!this.share.expireDate || this.config.isDefaultExpireDateEnforced + } + if (this.isRemoteShare) { + return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced + } + return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced }, set(enabled) { this.share.expireDate = enabled @@ -401,7 +407,7 @@ export default { return this.fileInfo.type === 'dir' }, dateMaxEnforced() { - if (!this.isRemote && this.config.isDefaultInternalExpireDateEnforced) { + if (!this.isRemoteShare && this.config.isDefaultInternalExpireDateEnforced) { return new Date(new Date().setDate(new Date().getDate() + 1 + this.config.defaultInternalExpireDate)) } else if (this.config.isDefaultRemoteExpireDateEnforced) { return new Date(new Date().setDate(new Date().getDate() + 1 + this.config.defaultRemoteExpireDate)) @@ -430,9 +436,6 @@ export default { isPasswordEnforced() { return this.isPublicShare && this.config.enforcePasswordForPublicLink }, - isExpiryDateEnforced() { - return this.config.isDefaultInternalExpireDateEnforced - }, defaultExpiryDate() { if ((this.isGroupShare || this.isUserShare) && this.config.isDefaultInternalExpireDateEnabled) { return new Date(this.config.defaultInternalExpirationDate) |