Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-05-23 18:03:04 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2019-10-29 14:56:00 +0300
commitfd90af50d910e659aa8df0d380424383c6c09620 (patch)
tree76d8ddcc7cf44ba6852f31b0a2323d23d6b1c258 /apps/files_sharing/src/services
parentea6f423e2c8e50cf1357a0e2182dc4c9a9bf981e (diff)
Add OCA.Files.Sidebar
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing/src/services')
-rw-r--r--apps/files_sharing/src/services/ConfigService.js223
-rw-r--r--apps/files_sharing/src/services/ExternalLinkActions.js63
-rw-r--r--apps/files_sharing/src/services/ShareSearch.js71
3 files changed, 357 insertions, 0 deletions
diff --git a/apps/files_sharing/src/services/ConfigService.js b/apps/files_sharing/src/services/ConfigService.js
new file mode 100644
index 00000000000..7058c714776
--- /dev/null
+++ b/apps/files_sharing/src/services/ConfigService.js
@@ -0,0 +1,223 @@
+/**
+ * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+export default class Config {
+
+ /**
+ * Is public upload allowed on link shares ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get isPublicUploadEnabled() {
+ return document.getElementById('filestable')
+ && document.getElementById('filestable').dataset.allowPublicUpload === 'yes'
+ }
+
+ /**
+ * Are link share allowed ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get isShareWithLinkAllowed() {
+ return document.getElementById('allowShareWithLink')
+ && document.getElementById('allowShareWithLink').value === 'yes'
+ }
+
+ /**
+ * Get the federated sharing documentation link
+ *
+ * @returns {string}
+ * @readonly
+ * @memberof Config
+ */
+ get federatedShareDocLink() {
+ return OC.appConfig.core.federatedCloudShareDoc
+ }
+
+ /**
+ * Get the default expiration date as string
+ *
+ * @returns {string}
+ * @readonly
+ * @memberof Config
+ */
+ get defaultExpirationDateString() {
+ let expireDateString = ''
+ if (this.isDefaultExpireDateEnabled) {
+ const date = window.moment.utc()
+ const expireAfterDays = this.defaultExpireDate
+ date.add(expireAfterDays, 'days')
+ expireDateString = date.format('YYYY-MM-DD')
+ }
+ return expireDateString
+ }
+
+ /**
+ * Are link shares password-enforced ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get enforcePasswordForPublicLink() {
+ return OC.appConfig.core.enforcePasswordForPublicLink === true
+ }
+
+ /**
+ * Is password asked by default on link shares ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get enableLinkPasswordByDefault() {
+ return OC.appConfig.core.enableLinkPasswordByDefault === true
+ }
+
+ /**
+ * Is link shares expiration enforced ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get isDefaultExpireDateEnforced() {
+ return OC.appConfig.core.defaultExpireDateEnforced === true
+ }
+
+ /**
+ * Is there a default expiration date for new link shares ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get isDefaultExpireDateEnabled() {
+ return OC.appConfig.core.defaultExpireDateEnabled === true
+ }
+
+ /**
+ * Are users on this server allowed to send shares to other servers ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get isRemoteShareAllowed() {
+ return OC.appConfig.core.remoteShareAllowed === true
+ }
+
+ /**
+ * Is sharing my mail (link share) enabled ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get isMailShareAllowed() {
+ return OC.appConfig.shareByMailEnabled !== undefined
+ }
+
+ /**
+ * Get the default days to expiration
+ *
+ * @returns {int}
+ * @readonly
+ * @memberof Config
+ */
+ get defaultExpireDate() {
+ return OC.appConfig.core.defaultExpireDate
+ }
+
+ /**
+ * Is resharing allowed ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get isResharingAllowed() {
+ return OC.appConfig.core.resharingAllowed === true
+ }
+
+ /**
+ * Is password enforced for mail shares ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get isPasswordForMailSharesRequired() {
+ return (OC.appConfig.shareByMail === undefined) ? false : OC.appConfig.shareByMail.enforcePasswordProtection === true
+ }
+
+ /**
+ * Is sharing with groups allowed ?
+ *
+ * @returns {boolean}
+ * @readonly
+ * @memberof Config
+ */
+ get allowGroupSharing() {
+ return OC.appConfig.core.allowGroupSharing === true
+ }
+
+ /**
+ * Get the maximum results of a share search
+ *
+ * @returns {int}
+ * @readonly
+ * @memberof Config
+ */
+ get maxAutocompleteResults() {
+ return parseInt(OC.config['sharing.maxAutocompleteResults'], 10) || 200
+ }
+
+ /**
+ * Get the minimal string length
+ * to initiate a share search
+ *
+ * @returns {int}
+ * @readonly
+ * @memberof Config
+ */
+ get minSearchStringLength() {
+ return parseInt(OC.config['sharing.minSearchStringLength'], 10) || 0
+ }
+
+ /**
+ * Get the password policy config
+ *
+ * @returns {Object}
+ * @readonly
+ * @memberof Config
+ */
+ get passwordPolicy() {
+ const capabilities = OC.getCapabilities()
+ return capabilities.password_policy ? capabilities.password_policy : {}
+ }
+
+}
diff --git a/apps/files_sharing/src/services/ExternalLinkActions.js b/apps/files_sharing/src/services/ExternalLinkActions.js
new file mode 100644
index 00000000000..f67a1cb1155
--- /dev/null
+++ b/apps/files_sharing/src/services/ExternalLinkActions.js
@@ -0,0 +1,63 @@
+/**
+ * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+export default class ExternalLinkActions {
+
+ #state;
+
+ constructor() {
+ // init empty state
+ this.#state = {}
+
+ // init default values
+ this.#state.actions = []
+ console.debug('OCA.Sharing.ExternalLinkActions initialized')
+ }
+
+ /**
+ * Get the state
+ *
+ * @readonly
+ * @memberof ExternalLinkActions
+ * @returns {Object} the data state
+ */
+ get state() {
+ return this.#state
+ }
+
+ /**
+ * Register a new action for the link share
+ * Mostly used by the social sharing app.
+ *
+ * @param {Object} action new action component to register
+ * @returns {boolean}
+ */
+ registerAction(action) {
+ if (typeof action === 'object' && action.render && action.components) {
+ this.#state.actions.push(action)
+ return true
+ }
+ console.error(`Invalid action component provided`, action)
+ return false
+ }
+
+}
diff --git a/apps/files_sharing/src/services/ShareSearch.js b/apps/files_sharing/src/services/ShareSearch.js
new file mode 100644
index 00000000000..dda1feb30a2
--- /dev/null
+++ b/apps/files_sharing/src/services/ShareSearch.js
@@ -0,0 +1,71 @@
+/**
+ * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+export default class ShareSearch {
+
+ #state;
+
+ constructor() {
+ // init empty state
+ this.#state = {}
+
+ // init default values
+ this.#state.results = []
+ console.debug('OCA.Sharing.ShareSearch initialized')
+ }
+
+ /**
+ * Get the state
+ *
+ * @readonly
+ * @memberof ShareSearch
+ * @returns {Object} the data state
+ */
+ get state() {
+ return this.#state
+ }
+
+ /**
+ * Register a new result
+ * Mostly used by the guests app.
+ * We should consider deprecation and add results via php ?
+ *
+ * @param {Object} result entry to append
+ * @param {string} [result.user] entry user
+ * @param {string} result.displayName entry first line
+ * @param {string} [result.desc] entry second line
+ * @param {string} [result.icon] entry icon
+ * @param {function} result.handler function to run on entry selection
+ * @param {function} [result.condition] condition to add entry or not
+ * @returns {boolean}
+ */
+ addNewResult(result) {
+ if (result.displayName.trim() !== ''
+ && typeof result.handler === 'function') {
+ this.#state.results.push(result)
+ return true
+ }
+ console.error(`Invalid search result provided`, result)
+ return false
+ }
+
+}