From da84ed7d4c2d05b4f9841d345d3a47dfe673ea7a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?=
Date: Mon, 1 Feb 2021 03:34:36 +0100
Subject: [PATCH] Fix active scope not visible in the menu if excluded
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Depending on some settings (for example, if lookup server upload is
disabled) some items can be hidden in the scope menu. However, if the
user selected an scope in the past once the settings were changed the
scope was no longer visible in the menu. Now the active scope will be
always visible in the menu, although if it is an excluded scope it will
be disabled. Selecting any other scope will then hide the excluded and
no longer active one.
When upload to the lookup server is disabled the scope menu was hidden
for display name and email in the personal information settings; now the
menu will be always shown to enable the above described behaviour.
Note that the menu will be shown even if there is a single available
scope so the user can read its description.
Signed-off-by: Daniel Calviño Sánchez
---
apps/settings/css/settings.scss | 10 +++
apps/settings/js/federationscopemenu.js | 16 ++++-
apps/settings/js/templates.js | 72 ++++++++++++++-----
.../templates/federationscopemenu.handlebars | 10 +++
.../settings/personal/personal.info.php | 6 +-
5 files changed, 90 insertions(+), 24 deletions(-)
diff --git a/apps/settings/css/settings.scss b/apps/settings/css/settings.scss
index 88c5e4dbcf990..53a9a28c0800b 100644
--- a/apps/settings/css/settings.scss
+++ b/apps/settings/css/settings.scss
@@ -425,6 +425,16 @@ select {
font-weight: bold;
}
}
+
+ &.disabled {
+ opacity: .5;
+
+ cursor: default;
+
+ * {
+ cursor: default;
+ }
+ }
}
}
}
diff --git a/apps/settings/js/federationscopemenu.js b/apps/settings/js/federationscopemenu.js
index d19c9d7d0bf7b..72fd8bc7284e7 100644
--- a/apps/settings/js/federationscopemenu.js
+++ b/apps/settings/js/federationscopemenu.js
@@ -23,6 +23,7 @@
className: 'federationScopeMenu popovermenu bubble menu menu-center',
field: undefined,
_scopes: undefined,
+ _excludedScopes: [],
initialize: function(options) {
this.field = options.field;
@@ -58,9 +59,7 @@
];
if (options.excludedScopes && options.excludedScopes.length) {
- this._scopes = this._scopes.filter(function(scopeEntry) {
- return options.excludedScopes.indexOf(scopeEntry.name) === -1;
- })
+ this._excludedScopes = options.excludedScopes
}
},
@@ -122,6 +121,17 @@
} else {
this._scopes[i].active = false;
}
+
+ var isExcludedScope = this._excludedScopes.includes(this._scopes[i].name)
+ if (isExcludedScope && !this._scopes[i].active) {
+ this._scopes[i].hidden = true
+ } else if (isExcludedScope && this._scopes[i].active) {
+ this._scopes[i].hidden = false
+ this._scopes[i].disabled = true
+ } else {
+ this._scopes[i].hidden = false
+ this._scopes[i].disabled = false
+ }
}
this.render();
diff --git a/apps/settings/js/templates.js b/apps/settings/js/templates.js
index d0d623d9ed939..7988a8df6a926 100644
--- a/apps/settings/js/templates.js
+++ b/apps/settings/js/templates.js
@@ -1,6 +1,15 @@
(function() {
var template = Handlebars.template, templates = OC.Settings.Templates = OC.Settings.Templates || {};
templates['federationscopemenu'] = template({"1":function(container,depth0,helpers,partials,data) {
+ var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {
+ if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
+ return parent[propertyName];
+ }
+ return undefined
+ };
+
+ return ((stack1 = lookupProperty(helpers,"unless").call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? lookupProperty(depth0,"hidden") : depth0),{"name":"unless","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":3,"column":2},"end":{"line":25,"column":13}}})) != null ? stack1 : "");
+},"2":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
return parent[propertyName];
@@ -8,22 +17,49 @@ templates['federationscopemenu'] = template({"1":function(container,depth0,helpe
return undefined
};
- return "
\n";
},"useData":true});
})();
\ No newline at end of file
diff --git a/apps/settings/js/templates/federationscopemenu.handlebars b/apps/settings/js/templates/federationscopemenu.handlebars
index e5cfd942f4661..5a2077d4fc3bf 100644
--- a/apps/settings/js/templates/federationscopemenu.handlebars
+++ b/apps/settings/js/templates/federationscopemenu.handlebars
@@ -1,7 +1,12 @@