Merge pull request #15338 from nextcloud/refactor/oc-config-usage

Change oc_config usage to OC.config
This commit is contained in:
John Molakvoæ 2019-05-02 09:32:38 +02:00 committed by GitHub
commit ac700506bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 27 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -141,7 +141,7 @@ Object.assign(window.OC, {
}
if(oc_config.modRewriteWorking == true) {
if(OC.config.modRewriteWorking == true) {
return OC.getRootPath() + _build(url, params);
}
@ -203,7 +203,7 @@ Object.assign(window.OC, {
* @param {string} file to check
*/
fileIsBlacklisted: function(file) {
return !!(file.match(oc_config.blacklist_files_regex));
return !!(file.match(OC.config.blacklist_files_regex));
},
/**
@ -935,8 +935,8 @@ function initCore() {
function initSessionHeartBeat() {
// interval in seconds
var interval = NaN;
if (oc_config.session_lifetime) {
interval = Math.floor(oc_config.session_lifetime / 2);
if (OC.config.session_lifetime) {
interval = Math.floor(OC.config.session_lifetime / 2);
}
interval = isNaN(interval)? 900: interval;
@ -957,8 +957,8 @@ function initCore() {
}
// session heartbeat (defaults to enabled)
if (typeof(oc_config.session_keepalive) === 'undefined' ||
!!oc_config.session_keepalive) {
if (typeof(OC.config.session_keepalive) === 'undefined' ||
!!OC.config.session_keepalive) {
initSessionHeartBeat();
}

View File

@ -8,7 +8,7 @@
*
*/
/* global moment, oc_appconfig, oc_config */
/* global moment, oc_appconfig */
(function() {
if (!OC.Share) {

View File

@ -361,8 +361,8 @@
}
var moreResultsAvailable =
(
oc_config['sharing.maxAutocompleteResults'] > 0
&& Math.min(perPage, oc_config['sharing.maxAutocompleteResults'])
OC.config['sharing.maxAutocompleteResults'] > 0
&& Math.min(perPage, OC.config['sharing.maxAutocompleteResults'])
<= Math.max(
users.length + exactUsers.length,
groups.length + exactGroups.length,
@ -624,8 +624,8 @@
}
var moreResultsAvailable =
(
oc_config['sharing.maxAutocompleteResults'] > 0
&& Math.min(perPage, oc_config['sharing.maxAutocompleteResults'])
OC.config['sharing.maxAutocompleteResults'] > 0
&& Math.min(perPage, OC.config['sharing.maxAutocompleteResults'])
<= Math.max(
users.length + exactUsers.length,
groups.length + exactGroups.length,
@ -690,7 +690,7 @@
$loading = this.$el.find('.shareWithLoading'),
$confirm = this.$el.find('.shareWithConfirm');
var count = oc_config['sharing.minSearchStringLength'];
var count = OC.config['sharing.minSearchStringLength'];
if (search.term.trim().length < count) {
var title = n('core',
'At least {count} character is needed for autocompletion',
@ -719,7 +719,7 @@
$shareWithField.removeClass('error')
.tooltip('hide');
var perPage = parseInt(oc_config['sharing.maxAutocompleteResults'], 10) || 200;
var perPage = parseInt(OC.config['sharing.maxAutocompleteResults'], 10) || 200;
this._getSuggestions(
search.term.trim(),
perPage,
@ -972,7 +972,7 @@
$shareWithField.focus();
};
var perPage = parseInt(oc_config['sharing.maxAutocompleteResults'], 10) || 200;
var perPage = parseInt(OC.config['sharing.maxAutocompleteResults'], 10) || 200;
this._getSuggestions(
$shareWithField.val(),
perPage,

View File

@ -373,7 +373,7 @@ describe('Core base tests', function() {
beforeEach(function() {
clock = sinon.useFakeTimers();
oldConfig = window.oc_config;
oldConfig = OC.config;
routeStub = sinon.stub(OC, 'generateUrl').returns('/csrftoken');
counter = 0;
@ -388,14 +388,14 @@ describe('Core base tests', function() {
afterEach(function() {
clock.restore();
/* jshint camelcase: false */
window.oc_config = oldConfig;
OC.config = oldConfig;
routeStub.restore();
$(document).off('ajaxError');
$(document).off('ajaxComplete');
});
it('sends heartbeat half the session lifetime when heartbeat enabled', function() {
/* jshint camelcase: false */
window.oc_config = {
OC.config = {
session_keepalive: true,
session_lifetime: 300
};
@ -422,7 +422,7 @@ describe('Core base tests', function() {
});
it('does not send heartbeat when heartbeat disabled', function() {
/* jshint camelcase: false */
window.oc_config = {
OC.config = {
session_keepalive: false,
session_lifetime: 300
};
@ -439,7 +439,7 @@ describe('Core base tests', function() {
it('limits the heartbeat between one minute and one day', function() {
/* jshint camelcase: false */
var setIntervalStub = sinon.stub(window, 'setInterval');
window.oc_config = {
OC.config = {
session_keepalive: true,
session_lifetime: 5
};
@ -447,7 +447,7 @@ describe('Core base tests', function() {
expect(setIntervalStub.getCall(0).args[1]).toEqual(60 * 1000);
setIntervalStub.reset();
window.oc_config = {
OC.config = {
session_keepalive: true,
session_lifetime: 48 * 3600
};

View File

@ -41,9 +41,8 @@ describe('OC.Share.ShareDialogView', function() {
// horrible parameters
$('#testArea').append('<input id="allowShareWithLink" type="hidden" value="yes">');
$container = $('#shareContainer');
oldConfig = window.oc_config;
window.oc_config = window.oc_config || {};
window.oc_config['sharing.maxAutocompleteResults'] = 0;
oldConfig = OC.config;
OC.config['sharing.maxAutocompleteResults'] = 0;
/* jshint camelcase:false */
oldAppConfig = _.extend({}, oc_appconfig.core);
oc_appconfig.core.enforcePasswordForPublicLink = false;
@ -112,7 +111,7 @@ describe('OC.Share.ShareDialogView', function() {
});
afterEach(function() {
OC.currentUser = oldCurrentUser;
window.oc_config = oldConfig;
OC.config = oldConfig;
/* jshint camelcase:false */
oc_appconfig.core = oldAppConfig;
@ -620,7 +619,7 @@ describe('OC.Share.ShareDialogView', function() {
});
it('capped mixed matches', function() {
window.oc_config['sharing.maxAutocompleteResults'] = 3;
OC.config['sharing.maxAutocompleteResults'] = 3;
var doneStub = sinon.stub();
var failStub = sinon.stub();