From af61486aea90cfc1a82301ce624dffb59ed01e07 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 25 Mar 2021 17:32:49 +0100 Subject: Separate settings for remote share expiration Added separate settings for default and enforced expiration date for remote shares. Signed-off-by: Vincent Petry --- apps/files_sharing/src/components/SharingEntry.vue | 17 ++++++--- apps/files_sharing/src/services/ConfigService.js | 40 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) (limited to 'apps/files_sharing/src') diff --git a/apps/files_sharing/src/components/SharingEntry.vue b/apps/files_sharing/src/components/SharingEntry.vue index 0e6975d9d57..e07654a19c1 100644 --- a/apps/files_sharing/src/components/SharingEntry.vue +++ b/apps/files_sharing/src/components/SharingEntry.vue @@ -222,8 +222,12 @@ export default { }, canHaveNote() { - return this.share.type !== this.SHARE_TYPES.SHARE_TYPE_REMOTE - && this.share.type !== this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP + return !this.isRemote + }, + + isRemote() { + return this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE + || this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP }, /** @@ -348,8 +352,13 @@ export default { }, dateMaxEnforced() { - return this.config.isDefaultInternalExpireDateEnforced - && moment().add(1 + this.config.defaultInternalExpireDate, 'days') + if (!this.isRemote) { + return this.config.isDefaultInternalExpireDateEnforced + && moment().add(1 + this.config.defaultInternalExpireDate, 'days') + } else { + return this.config.isDefaultRemoteExpireDateEnforced + && moment().add(1 + this.config.defaultRemoteExpireDate, 'days') + } }, /** diff --git a/apps/files_sharing/src/services/ConfigService.js b/apps/files_sharing/src/services/ConfigService.js index 84ee5ee0a69..4c8326b1570 100644 --- a/apps/files_sharing/src/services/ConfigService.js +++ b/apps/files_sharing/src/services/ConfigService.js @@ -95,6 +95,24 @@ export default class Config { return expireDateString } + /** + * Get the default remote expiration date as string + * + * @returns {string} + * @readonly + * @memberof Config + */ + get defaultRemoteExpirationDateString() { + let expireDateString = '' + if (this.isDefaultRemoteExpireDateEnabled) { + const date = window.moment.utc() + const expireAfterDays = this.defaultRemoteExpireDate + date.add(expireAfterDays, 'days') + expireDateString = date.format('YYYY-MM-DD') + } + return expireDateString + } + /** * Are link shares password-enforced ? * @@ -150,6 +168,17 @@ export default class Config { return OC.appConfig.core.defaultInternalExpireDateEnforced === true } + /** + * Is remote shares expiration enforced ? + * + * @returns {boolean} + * @readonly + * @memberof Config + */ + get isDefaultRemoteExpireDateEnforced() { + return OC.appConfig.core.defaultRemoteExpireDateEnforced === true + } + /** * Is there a default expiration date for new internal shares ? * @@ -209,6 +238,17 @@ export default class Config { return OC.appConfig.core.defaultInternalExpireDate } + /** + * Get the default days to remote shares expiration + * + * @returns {int} + * @readonly + * @memberof Config + */ + get defaultRemoteExpireDate() { + return OC.appConfig.core.defaultRemoteExpireDate + } + /** * Is resharing allowed ? * -- cgit v1.2.3