aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/js
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-03-23 11:38:25 +0100
committerVincent Petry <vincent@nextcloud.com>2021-03-26 13:07:08 +0100
commit9fb447ea427428c86a8d6be77d0145f4fb0ed777 (patch)
treeb8aa943599cf02618d532f18ea7aadb2d1fdadb0 /apps/settings/js
parentb81a1c1bdbf7c7ca3e71a7c7cd7eb21edd0a3fb9 (diff)
downloadnextcloud-server-9fb447ea427428c86a8d6be77d0145f4fb0ed777.tar.gz
nextcloud-server-9fb447ea427428c86a8d6be77d0145f4fb0ed777.zip
Adjust scopes menu based on conditions
Now not all fields have the "v2-private" option in place. Fix dropdown issue when a scope was stored that is not listed after disabling the lookup server. Whenever the lookup server upload is disabled, the scope menu is now displayed where it makes sense to allow switching between the two private scopes. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'apps/settings/js')
-rw-r--r--apps/settings/js/federationscopemenu.js23
-rw-r--r--apps/settings/js/federationsettingsview.js17
-rw-r--r--apps/settings/js/settings/personalInfo.js6
3 files changed, 25 insertions, 21 deletions
diff --git a/apps/settings/js/federationscopemenu.js b/apps/settings/js/federationscopemenu.js
index 1c854a7ee57..b94e1686a4e 100644
--- a/apps/settings/js/federationscopemenu.js
+++ b/apps/settings/js/federationscopemenu.js
@@ -57,7 +57,7 @@
}
];
- if (options.excludedScopes) {
+ if (options.excludedScopes && options.excludedScopes.length) {
this._scopes = this._scopes.filter(function(scopeEntry) {
return options.excludedScopes.indexOf(scopeEntry.name) === -1;
})
@@ -117,22 +117,11 @@
var currentlyActiveValue = $('#'+context.target.closest('form').id).find('input[type="hidden"]')[0].value;
for(var i in this._scopes) {
- this._scopes[i].active = false;
- }
-
- switch (currentlyActiveValue) {
- case 'v2-private':
- this._scopes[0].active = true;
- break;
- case 'private':
- this._scopes[1].active = true;
- break;
- case 'contacts':
- this._scopes[2].active = true;
- break;
- case 'public':
- this._scopes[3].active = true;
- break;
+ if (this._scopes[i].name === currentlyActiveValue) {
+ this._scopes[i].active = true;
+ } else {
+ this._scopes[i].active = false;
+ }
}
this.render();
diff --git a/apps/settings/js/federationsettingsview.js b/apps/settings/js/federationsettingsview.js
index 293989baa0c..759bf85c3e1 100644
--- a/apps/settings/js/federationsettingsview.js
+++ b/apps/settings/js/federationsettingsview.js
@@ -10,6 +10,13 @@
(function(_, $, OC) {
'use strict';
+ /**
+ * Construct a new FederationScopeMenu instance
+ * @constructs FederationScopeMenu
+ * @memberof OC.Settings
+ * @param {object} options
+ * @param {bool} [options.lookupServerUploadEnabled=false] whether uploading to the lookup server is enabled
+ */
var FederationSettingsView = OC.Backbone.View.extend({
_inputFields: undefined,
@@ -24,6 +31,7 @@
} else {
this._config = new OC.Settings.UserSettings();
}
+ this.showFederationScopes = !!options.showFederationScopes;
this._inputFields = [
'displayname',
@@ -71,10 +79,15 @@
_.each(this._inputFields, function(field) {
var $icon = self.$('#' + field + 'form h3 > .federation-menu');
- var excludedScopes = null
+ var excludedScopes = []
if (fieldsWithV2Private.indexOf(field) === -1) {
- excludedScopes = ['v2-private']
+ excludedScopes.push('v2-private');
+ }
+
+ if (!self.showFederationScopes) {
+ excludedScopes.push('contacts');
+ excludedScopes.push('public');
}
var scopeMenu = new OC.Settings.FederationScopeMenu({
diff --git a/apps/settings/js/settings/personalInfo.js b/apps/settings/js/settings/personalInfo.js
index a6055fd7a94..e71f4840123 100644
--- a/apps/settings/js/settings/personalInfo.js
+++ b/apps/settings/js/settings/personalInfo.js
@@ -199,10 +199,12 @@ window.addEventListener('DOMContentLoaded', function () {
});
+ var settingsEl = $('#personal-settings')
var userSettings = new OC.Settings.UserSettings();
var federationSettingsView = new OC.Settings.FederationSettingsView({
- el: '#personal-settings',
- config: userSettings
+ el: settingsEl,
+ config: userSettings,
+ showFederationScopes: !!settingsEl.data('lookup-server-upload-enabled'),
});
userSettings.on("sync", function() {