From 444c9b6744f00a0fb8ac31cf0c827c150719bc68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?=
Date: Wed, 13 Nov 2019 15:43:11 +0100
Subject: [PATCH] Add settings front and split sharing entry config
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: John Molakvoæ (skjnldsv)
---
.../src/components/SharingEntry.vue | 22 ++++++++
.../src/components/SharingEntryLink.vue | 22 ++++++++
apps/files_sharing/src/mixins/SharesMixin.js | 22 --------
.../src/services/ConfigService.js | 55 ++++++++++++++++++-
apps/settings/js/admin.js | 4 ++
.../templates/settings/admin/sharing.php | 2 +-
6 files changed, 102 insertions(+), 25 deletions(-)
diff --git a/apps/files_sharing/src/components/SharingEntry.vue b/apps/files_sharing/src/components/SharingEntry.vue
index 09d09d607f..cde7d2ed2b 100644
--- a/apps/files_sharing/src/components/SharingEntry.vue
+++ b/apps/files_sharing/src/components/SharingEntry.vue
@@ -213,6 +213,28 @@ export default {
set: function(checked) {
this.updatePermissions(this.canEdit, checked)
}
+ },
+
+ /**
+ * Does the current share have an expiration date
+ * @returns {boolean}
+ */
+ hasExpirationDate: {
+ get: function() {
+ return this.config.isDefaultInternalExpireDateEnforced || !!this.share.expireDate
+ },
+ set: function(enabled) {
+ this.share.expireDate = enabled
+ ? this.config.defaultInternalExpirationDateString !== ''
+ ? this.config.defaultInternalExpirationDateString
+ : moment().format('YYYY-MM-DD')
+ : ''
+ }
+ },
+
+ dateMaxEnforced() {
+ return this.config.isDefaultInternalExpireDateEnforced
+ && moment().add(1 + this.config.defaultInternalExpireDate, 'days')
}
},
diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue
index 407d674e77..ddfe953e33 100644
--- a/apps/files_sharing/src/components/SharingEntryLink.vue
+++ b/apps/files_sharing/src/components/SharingEntryLink.vue
@@ -379,6 +379,28 @@ export default {
return t('files_sharing', 'Share link')
},
+ /**
+ * Does the current share have an expiration date
+ * @returns {boolean}
+ */
+ hasExpirationDate: {
+ get: function() {
+ return this.config.isDefaultExpireDateEnforced || !!this.share.expireDate
+ },
+ set: function(enabled) {
+ this.share.expireDate = enabled
+ ? this.config.defaultExpirationDateString !== ''
+ ? this.config.defaultExpirationDateString
+ : moment().format('YYYY-MM-DD')
+ : ''
+ }
+ },
+
+ dateMaxEnforced() {
+ return this.config.isDefaultExpireDateEnforced
+ && moment().add(1 + this.config.defaultExpireDate, 'days')
+ },
+
/**
* Is the current share password protected ?
* @returns {boolean}
diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js
index d012f35591..a0ec074895 100644
--- a/apps/files_sharing/src/mixins/SharesMixin.js
+++ b/apps/files_sharing/src/mixins/SharesMixin.js
@@ -82,23 +82,6 @@ export default {
computed: {
- /**
- * Does the current share have an expiration date
- * @returns {boolean}
- */
- hasExpirationDate: {
- get: function() {
- return this.config.isDefaultExpireDateEnforced || !!this.share.expireDate
- },
- set: function(enabled) {
- this.share.expireDate = enabled
- ? this.config.defaultExpirationDateString !== ''
- ? this.config.defaultExpirationDateString
- : moment().format('YYYY-MM-DD')
- : ''
- }
- },
-
/**
* Does the current share have a note
* @returns {boolean}
@@ -118,11 +101,6 @@ export default {
return moment().add(1, 'days')
},
- dateMaxEnforced() {
- return this.config.isDefaultExpireDateEnforced
- && moment().add(1 + this.config.defaultExpireDate, 'days')
- },
-
/**
* Datepicker lang values
* https://github.com/nextcloud/nextcloud-vue/pull/146
diff --git a/apps/files_sharing/src/services/ConfigService.js b/apps/files_sharing/src/services/ConfigService.js
index 7058c71477..7e0ae960c6 100644
--- a/apps/files_sharing/src/services/ConfigService.js
+++ b/apps/files_sharing/src/services/ConfigService.js
@@ -58,7 +58,7 @@ export default class Config {
}
/**
- * Get the default expiration date as string
+ * Get the default link share expiration date as string
*
* @returns {string}
* @readonly
@@ -75,6 +75,24 @@ export default class Config {
return expireDateString
}
+ /**
+ * Get the default internal expiration date as string
+ *
+ * @returns {string}
+ * @readonly
+ * @memberof Config
+ */
+ get defaultInternalExpirationDateString() {
+ let expireDateString = ''
+ if (this.isDefaultInternalExpireDateEnabled) {
+ const date = window.moment.utc()
+ const expireAfterDays = this.defaultInternalExpireDate
+ date.add(expireAfterDays, 'days')
+ expireDateString = date.format('YYYY-MM-DD')
+ }
+ return expireDateString
+ }
+
/**
* Are link shares password-enforced ?
*
@@ -119,6 +137,28 @@ export default class Config {
return OC.appConfig.core.defaultExpireDateEnabled === true
}
+ /**
+ * Is internal shares expiration enforced ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get isDefaultInternalExpireDateEnforced() {
+ return OC.appConfig.core.defaultInternalExpireDateEnforced === true
+ }
+
+ /**
+ * Is there a default expiration date for new internal shares ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get isDefaultInternalExpireDateEnabled() {
+ return OC.appConfig.core.defaultInternalExpireDateEnabled === true
+ }
+
/**
* Are users on this server allowed to send shares to other servers ?
*
@@ -142,7 +182,7 @@ export default class Config {
}
/**
- * Get the default days to expiration
+ * Get the default days to link shares expiration
*
* @returns {int}
* @readonly
@@ -152,6 +192,17 @@ export default class Config {
return OC.appConfig.core.defaultExpireDate
}
+ /**
+ * Get the default days to internal shares expiration
+ *
+ * @returns {int}
+ * @readonly
+ * @memberof Config
+ */
+ get defaultInternalExpireDate() {
+ return OC.appConfig.core.defaultInternalExpireDate
+ }
+
/**
* Is resharing allowed ?
*
diff --git a/apps/settings/js/admin.js b/apps/settings/js/admin.js
index b207886207..e798cd8d19 100644
--- a/apps/settings/js/admin.js
+++ b/apps/settings/js/admin.js
@@ -86,6 +86,10 @@ $(document).ready(function(){
$("#setDefaultExpireDate").toggleClass('hidden', !this.checked);
});
+ $('#shareapiDefaultInternalExpireDate').change(function() {
+ $("#setDefaultInternalExpireDate").toggleClass('hidden', !this.checked);
+ });
+
$('#publicShareDisclaimer').change(function() {
$("#publicShareDisclaimerText").toggleClass('hidden', !this.checked);
if(!this.checked) {
diff --git a/apps/settings/templates/settings/admin/sharing.php b/apps/settings/templates/settings/admin/sharing.php
index 4f4f16d038..3ed9871add 100644
--- a/apps/settings/templates/settings/admin/sharing.php
+++ b/apps/settings/templates/settings/admin/sharing.php
@@ -38,7 +38,7 @@
- ">
+
/>