Move OC.getCapabilities to the bundle and deprecate OC._capabilities,… (#15521)

Move OC.getCapabilities to the bundle and deprecate OC._capabilities,…
This commit is contained in:
John Molakvoæ 2019-05-14 07:32:59 +02:00 committed by GitHub
commit c1bd7e7fe7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 50 additions and 25 deletions

BIN
core/js/dist/login.js vendored

Binary file not shown.

Binary file not shown.

BIN
core/js/dist/main.js vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -6,12 +6,6 @@ var OCP = Object.assign({}, window.OCP);
*/
Object.assign(window.OC, {
/* jshint camelcase: false */
/**
* Capabilities
*
* @type array
*/
_capabilities: window.oc_capabilities || null,
theme: window.oc_defaults || {},
@ -70,17 +64,6 @@ Object.assign(window.OC, {
return window.location.port;
},
/**
* Returns the capabilities
*
* @return {array} capabilities
*
* @since 14.0
*/
getCapabilities: function() {
return OC._capabilities;
},
/**
* Loads translations for the given app asynchronously.
*

View file

@ -598,8 +598,8 @@
var minPasswordLength = 4
// password policy?
if(oc_capabilities.password_policy && oc_capabilities.password_policy.minLength) {
minPasswordLength = oc_capabilities.password_policy.minLength;
if(OC.getCapabilities().password_policy && OC.getCapabilities().password_policy.minLength) {
minPasswordLength = OC.getCapabilities().password_policy.minLength;
}
var popoverBase = {

View file

@ -0,0 +1,31 @@
/*
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @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/>.
*/
const capabilities = window._oc_capabilities || {}
/**
* Returns the capabilities
*
* @return {Array} capabilities
*
* @since 14.0
*/
export const getCapabilities = () => capabilities

View file

@ -49,6 +49,7 @@ import {currentUser, getCurrentUser} from './currentuser'
import Dialogs from './dialogs'
import EventSource from './eventsource'
import {get, set} from './get_set'
import {getCapabilities} from './capabilities'
import {
getToken as getRequestToken,
subscribe as subscribeToRequestTokenChange,
@ -130,6 +131,15 @@ export default {
isUserAdmin,
L10N,
/**
* Capabilities
*
* @type {Array}
* @deprecated 17.0.0 use OC.getCapabilities() instead
*/
_capabilities: getCapabilities(),
getCapabilities,
/*
* Legacy menu helpers
*/

View file

@ -119,6 +119,7 @@ window['moment'] = moment
window['OC'] = OC
setDeprecatedProp('initCore', () => initCore, 'this is an internal function')
setDeprecatedProp('oc_appswebroots', () => OC.appswebroots, 'use OC.appswebroots instead')
setDeprecatedProp('oc_capabilities', OC.getCapabilities, 'use OC.getCapabilities instead')
setDeprecatedProp('oc_config', () => OC.config, 'use OC.config instead')
setDeprecatedProp('oc_current_user', () => OC.getCurrentUser().uid, 'use OC.getCurrentUser().uid instead')
setDeprecatedProp('oc_debug', () => OC.debug, 'use OC.debug instead')

View file

@ -271,7 +271,7 @@ class JSConfigHelper {
'longFooter' => $this->defaults->getLongFooter(),
'folder' => \OC_Util::getTheme(),
]),
"oc_capabilities" => json_encode($capabilities),
"_oc_capabilities" => json_encode($capabilities),
];
if ($this->currentUser !== null) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -279,9 +279,9 @@ const actions = {
getPasswordPolicyMinLength(context) {
if(oc_capabilities.password_policy && oc_capabilities.password_policy.minLength) {
context.commit('setPasswordPolicyMinLength', oc_capabilities.password_policy.minLength);
return oc_capabilities.password_policy.minLength;
if(OC.getCapabilities().password_policy && OC.getCapabilities().password_policy.minLength) {
context.commit('setPasswordPolicyMinLength', OC.getCapabilities().password_policy.minLength);
return OC.getCapabilities().password_policy.minLength;
}
return false;
},