Skip to content

Commit eb79cb6

Browse files
authored
Merge pull request #29393 from nextcloud/backport/26725/stable22
[stable22] Fix federated scope not shown when public addressbook upload is disabled
2 parents 6c7efef + 09a5413 commit eb79cb6

File tree

7 files changed

+38
-17
lines changed

7 files changed

+38
-17
lines changed

apps/provisioning_api/lib/Capabilities.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,23 @@ public function __construct(IAppManager $appManager) {
4141
* @return array Array containing the apps capabilities
4242
*/
4343
public function getCapabilities() {
44-
$federationScopesEnabled = false;
44+
$federatedScopeEnabled = $this->appManager->isEnabledForUser('federation');
45+
46+
$publishedScopeEnabled = false;
4547

4648
$federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
4749
if ($federatedFileSharingEnabled) {
4850
/** @var FederatedShareProvider $shareProvider */
4951
$shareProvider = \OC::$server->query(FederatedShareProvider::class);
50-
$federationScopesEnabled = $shareProvider->isLookupServerUploadEnabled();
52+
$publishedScopeEnabled = $shareProvider->isLookupServerUploadEnabled();
5153
}
5254

5355
return [
5456
'provisioning_api' => [
5557
'version' => $this->appManager->getAppVersion('provisioning_api'),
5658
'AccountPropertyScopesVersion' => 2,
57-
'AccountPropertyScopesFederationEnabled' => $federationScopesEnabled,
59+
'AccountPropertyScopesFederatedEnabled' => $federatedScopeEnabled,
60+
'AccountPropertyScopesPublishedEnabled' => $publishedScopeEnabled,
5861
]
5962
];
6063
}

apps/provisioning_api/tests/CapabilitiesTest.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,25 @@ public function setUp(): void {
5757

5858
public function getCapabilitiesProvider() {
5959
return [
60-
[false, false, false],
61-
[true, false, false],
62-
[true, true, true],
60+
[true, false, false, true, false],
61+
[true, true, false, true, false],
62+
[true, true, true, true, true],
63+
[false, false, false, false, false],
64+
[false, true, false, false, false],
65+
[false, true, true, false, true],
6366
];
6467
}
6568

6669
/**
6770
* @dataProvider getCapabilitiesProvider
6871
*/
69-
public function testGetCapabilities($federationAppEnabled, $lookupServerEnabled, $expectedFederationScopesEnabled) {
70-
$this->appManager->expects($this->once())
71-
->method('isEnabledForUser')
72-
->with('federatedfilesharing')
73-
->willReturn($federationAppEnabled);
72+
public function testGetCapabilities($federationAppEnabled, $federatedFileSharingAppEnabled, $lookupServerEnabled, $expectedFederatedScopeEnabled, $expectedPublishedScopeEnabled) {
73+
$this->appManager->expects($this->any())
74+
->method('isEnabledForUser')
75+
->will($this->returnValueMap([
76+
['federation', null, $federationAppEnabled],
77+
['federatedfilesharing', null, $federatedFileSharingAppEnabled],
78+
]));
7479

7580
$federatedShareProvider = $this->createMock(FederatedShareProvider::class);
7681
$this->overwriteService(FederatedShareProvider::class, $federatedShareProvider);
@@ -83,7 +88,8 @@ public function testGetCapabilities($federationAppEnabled, $lookupServerEnabled,
8388
'provisioning_api' => [
8489
'version' => '1.12',
8590
'AccountPropertyScopesVersion' => 2,
86-
'AccountPropertyScopesFederationEnabled' => $expectedFederationScopesEnabled,
91+
'AccountPropertyScopesFederatedEnabled' => $expectedFederatedScopeEnabled,
92+
'AccountPropertyScopesPublishedEnabled' => $expectedPublishedScopeEnabled,
8793
],
8894
];
8995
$this->assertSame($expected, $this->capabilities->getCapabilities());

apps/settings/js/federationsettingsview.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
* @constructs FederationScopeMenu
1616
* @memberof OC.Settings
1717
* @param {object} options
18-
* @param {bool} [options.lookupServerUploadEnabled=false] whether uploading to the lookup server is enabled
18+
* @param {bool} [options.showFederatedScope=false] whether show the
19+
* "v2-federated" scope or not
20+
* @param {bool} [options.showPublishedScope=false] whether show the
21+
* "v2-published" scope or not
1922
*/
2023
var FederationSettingsView = OC.Backbone.View.extend({
2124
_inputFields: undefined,
@@ -31,7 +34,8 @@
3134
} else {
3235
this._config = new OC.Settings.UserSettings();
3336
}
34-
this.showFederationScopes = !!options.showFederationScopes;
37+
this.showFederatedScope = !!options.showFederatedScope;
38+
this.showPublishedScope = !!options.showPublishedScope;
3539

3640
this._inputFields = [
3741
'displayname',
@@ -85,8 +89,11 @@
8589
excludedScopes.push('v2-private');
8690
}
8791

88-
if (!self.showFederationScopes) {
92+
if (!self.showFederatedScope) {
8993
excludedScopes.push('v2-federated');
94+
}
95+
96+
if (!self.showPublishedScope) {
9097
excludedScopes.push('v2-published');
9198
}
9299

apps/settings/js/settings/personalInfo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ window.addEventListener('DOMContentLoaded', function () {
204204
var federationSettingsView = new OC.Settings.FederationSettingsView({
205205
el: settingsEl,
206206
config: userSettings,
207-
showFederationScopes: !!settingsEl.data('lookup-server-upload-enabled'),
207+
showFederatedScope: !!settingsEl.data('federation-enabled'),
208+
showPublishedScope: !!settingsEl.data('lookup-server-upload-enabled'),
208209
});
209210

210211
userSettings.on("sync", function() {

apps/settings/lib/Settings/Personal/PersonalInfo.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function __construct(
9292
}
9393

9494
public function getForm(): TemplateResponse {
95+
$federationEnabled = $this->appManager->isEnabledForUser('federation');
9596
$federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
9697
$lookupServerUploadEnabled = false;
9798
if ($federatedFileSharingEnabled) {
@@ -124,6 +125,7 @@ public function getForm(): TemplateResponse {
124125
'usage_relative' => round($storageInfo['relative']),
125126
'quota' => $storageInfo['quota'],
126127
'avatarChangeSupported' => $user->canChangeAvatar(),
128+
'federationEnabled' => $federationEnabled,
127129
'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
128130
'avatarScope' => $account->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(),
129131
'displayNameChangeSupported' => $user->canChangeDisplayName(),

apps/settings/templates/settings/personal/personal.info.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
]);
3636
?>
3737

38-
<div id="personal-settings" data-lookup-server-upload-enabled="<?php p($_['lookupServerUploadEnabled'] ? 'true' : 'false') ?>">
38+
<div id="personal-settings" data-federation-enabled="<?php p($_['federationEnabled'] ? 'true' : 'false') ?>"
39+
data-lookup-server-upload-enabled="<?php p($_['lookupServerUploadEnabled'] ? 'true' : 'false') ?>">
3940
<h2 class="hidden-visually"><?php p($l->t('Personal info')); ?></h2>
4041
<div id="personal-settings-avatar-container" class="personal-settings-container">
4142
<div>

tests/lib/Accounts/AccountPropertyTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function scopesProvider() {
7878
// current values
7979
[IAccountManager::SCOPE_PRIVATE, IAccountManager::SCOPE_PRIVATE],
8080
[IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_LOCAL],
81+
[IAccountManager::SCOPE_FEDERATED, IAccountManager::SCOPE_FEDERATED],
8182
[IAccountManager::SCOPE_PUBLISHED, IAccountManager::SCOPE_PUBLISHED],
8283
// legacy values
8384
[IAccountManager::VISIBILITY_PRIVATE, IAccountManager::SCOPE_LOCAL],

0 commit comments

Comments
 (0)