diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2021-10-22 11:52:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-22 11:52:56 +0200 |
commit | c98039c1df19f8b53efea5b627d5e8f183ec77c3 (patch) | |
tree | fd4fef772d501f21573bdf1a16e30a68c907060d | |
parent | 0a359376628b36256aa8332d79b1af1dfc513ce8 (diff) | |
parent | 193cf6cfde8a91e225947021e582997403074c78 (diff) | |
download | nextcloud-server-c98039c1df19f8b53efea5b627d5e8f183ec77c3.tar.gz nextcloud-server-c98039c1df19f8b53efea5b627d5e8f183ec77c3.zip |
Merge pull request #26725 from nextcloud/fix-federated-scope-not-shown-when-public-addressbook-upload-is-disabled
-rw-r--r-- | apps/provisioning_api/lib/Capabilities.php | 9 | ||||
-rw-r--r-- | apps/provisioning_api/tests/CapabilitiesTest.php | 24 | ||||
-rw-r--r-- | apps/settings/js/federationsettingsview.js | 13 | ||||
-rw-r--r-- | apps/settings/js/settings/personalInfo.js | 3 | ||||
-rw-r--r-- | apps/settings/lib/Settings/Personal/PersonalInfo.php | 2 | ||||
-rw-r--r-- | apps/settings/templates/settings/personal/personal.info.php | 3 | ||||
-rw-r--r-- | tests/lib/Accounts/AccountPropertyTest.php | 1 |
7 files changed, 38 insertions, 17 deletions
diff --git a/apps/provisioning_api/lib/Capabilities.php b/apps/provisioning_api/lib/Capabilities.php index 59c462c5d90..835bbfe9b5c 100644 --- a/apps/provisioning_api/lib/Capabilities.php +++ b/apps/provisioning_api/lib/Capabilities.php @@ -41,20 +41,23 @@ class Capabilities implements ICapability { * @return array Array containing the apps capabilities */ public function getCapabilities() { - $federationScopesEnabled = false; + $federatedScopeEnabled = $this->appManager->isEnabledForUser('federation'); + + $publishedScopeEnabled = false; $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); if ($federatedFileSharingEnabled) { /** @var FederatedShareProvider $shareProvider */ $shareProvider = \OC::$server->query(FederatedShareProvider::class); - $federationScopesEnabled = $shareProvider->isLookupServerUploadEnabled(); + $publishedScopeEnabled = $shareProvider->isLookupServerUploadEnabled(); } return [ 'provisioning_api' => [ 'version' => $this->appManager->getAppVersion('provisioning_api'), 'AccountPropertyScopesVersion' => 2, - 'AccountPropertyScopesFederationEnabled' => $federationScopesEnabled, + 'AccountPropertyScopesFederatedEnabled' => $federatedScopeEnabled, + 'AccountPropertyScopesPublishedEnabled' => $publishedScopeEnabled, ] ]; } diff --git a/apps/provisioning_api/tests/CapabilitiesTest.php b/apps/provisioning_api/tests/CapabilitiesTest.php index 97f9ba562bc..8fc29b442eb 100644 --- a/apps/provisioning_api/tests/CapabilitiesTest.php +++ b/apps/provisioning_api/tests/CapabilitiesTest.php @@ -57,20 +57,25 @@ class CapabilitiesTest extends TestCase { public function getCapabilitiesProvider() { return [ - [false, false, false], - [true, false, false], - [true, true, true], + [true, false, false, true, false], + [true, true, false, true, false], + [true, true, true, true, true], + [false, false, false, false, false], + [false, true, false, false, false], + [false, true, true, false, true], ]; } /** * @dataProvider getCapabilitiesProvider */ - public function testGetCapabilities($federationAppEnabled, $lookupServerEnabled, $expectedFederationScopesEnabled) { - $this->appManager->expects($this->once()) - ->method('isEnabledForUser') - ->with('federatedfilesharing') - ->willReturn($federationAppEnabled); + public function testGetCapabilities($federationAppEnabled, $federatedFileSharingAppEnabled, $lookupServerEnabled, $expectedFederatedScopeEnabled, $expectedPublishedScopeEnabled) { + $this->appManager->expects($this->any()) + ->method('isEnabledForUser') + ->will($this->returnValueMap([ + ['federation', null, $federationAppEnabled], + ['federatedfilesharing', null, $federatedFileSharingAppEnabled], + ])); $federatedShareProvider = $this->createMock(FederatedShareProvider::class); $this->overwriteService(FederatedShareProvider::class, $federatedShareProvider); @@ -83,7 +88,8 @@ class CapabilitiesTest extends TestCase { 'provisioning_api' => [ 'version' => '1.12', 'AccountPropertyScopesVersion' => 2, - 'AccountPropertyScopesFederationEnabled' => $expectedFederationScopesEnabled, + 'AccountPropertyScopesFederatedEnabled' => $expectedFederatedScopeEnabled, + 'AccountPropertyScopesPublishedEnabled' => $expectedPublishedScopeEnabled, ], ]; $this->assertSame($expected, $this->capabilities->getCapabilities()); diff --git a/apps/settings/js/federationsettingsview.js b/apps/settings/js/federationsettingsview.js index 602acab5c8d..ca56992b1ed 100644 --- a/apps/settings/js/federationsettingsview.js +++ b/apps/settings/js/federationsettingsview.js @@ -15,7 +15,10 @@ * @constructs FederationScopeMenu * @memberof OC.Settings * @param {object} options - * @param {bool} [options.lookupServerUploadEnabled=false] whether uploading to the lookup server is enabled + * @param {bool} [options.showFederatedScope=false] whether show the + * "v2-federated" scope or not + * @param {bool} [options.showPublishedScope=false] whether show the + * "v2-published" scope or not */ var FederationSettingsView = OC.Backbone.View.extend({ _inputFields: undefined, @@ -31,7 +34,8 @@ } else { this._config = new OC.Settings.UserSettings(); } - this.showFederationScopes = !!options.showFederationScopes; + this.showFederatedScope = !!options.showFederatedScope; + this.showPublishedScope = !!options.showPublishedScope; this._inputFields = [ 'displayname', @@ -85,8 +89,11 @@ excludedScopes.push('v2-private'); } - if (!self.showFederationScopes) { + if (!self.showFederatedScope) { excludedScopes.push('v2-federated'); + } + + if (!self.showPublishedScope) { excludedScopes.push('v2-published'); } diff --git a/apps/settings/js/settings/personalInfo.js b/apps/settings/js/settings/personalInfo.js index 1e2a8d58ab9..a4b1713c662 100644 --- a/apps/settings/js/settings/personalInfo.js +++ b/apps/settings/js/settings/personalInfo.js @@ -204,7 +204,8 @@ window.addEventListener('DOMContentLoaded', function () { var federationSettingsView = new OC.Settings.FederationSettingsView({ el: settingsEl, config: userSettings, - showFederationScopes: !!settingsEl.data('lookup-server-upload-enabled'), + showFederatedScope: !!settingsEl.data('federation-enabled'), + showPublishedScope: !!settingsEl.data('lookup-server-upload-enabled'), }); userSettings.on("sync", function() { diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php index 40ce3b62e11..928c18998df 100644 --- a/apps/settings/lib/Settings/Personal/PersonalInfo.php +++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php @@ -107,6 +107,7 @@ class PersonalInfo implements ISettings { } public function getForm(): TemplateResponse { + $federationEnabled = $this->appManager->isEnabledForUser('federation'); $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); $lookupServerUploadEnabled = false; if ($federatedFileSharingEnabled) { @@ -139,6 +140,7 @@ class PersonalInfo implements ISettings { 'usage_relative' => round($storageInfo['relative']), 'quota' => $storageInfo['quota'], 'avatarChangeSupported' => $user->canChangeAvatar(), + 'federationEnabled' => $federationEnabled, 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, 'avatarScope' => $account->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(), 'displayNameChangeSupported' => $user->canChangeDisplayName(), diff --git a/apps/settings/templates/settings/personal/personal.info.php b/apps/settings/templates/settings/personal/personal.info.php index 23c150c0060..d258f616229 100644 --- a/apps/settings/templates/settings/personal/personal.info.php +++ b/apps/settings/templates/settings/personal/personal.info.php @@ -36,7 +36,8 @@ script('settings', [ ]); ?> -<div id="personal-settings" data-lookup-server-upload-enabled="<?php p($_['lookupServerUploadEnabled'] ? 'true' : 'false') ?>"> +<div id="personal-settings" data-federation-enabled="<?php p($_['federationEnabled'] ? 'true' : 'false') ?>" + data-lookup-server-upload-enabled="<?php p($_['lookupServerUploadEnabled'] ? 'true' : 'false') ?>"> <h2 class="hidden-visually"><?php p($l->t('Personal info')); ?></h2> <div id="personal-settings-avatar-container" class="personal-settings-container"> <div> diff --git a/tests/lib/Accounts/AccountPropertyTest.php b/tests/lib/Accounts/AccountPropertyTest.php index 50c3b8f84a4..c2ba96ef8a5 100644 --- a/tests/lib/Accounts/AccountPropertyTest.php +++ b/tests/lib/Accounts/AccountPropertyTest.php @@ -78,6 +78,7 @@ class AccountPropertyTest extends TestCase { // current values [IAccountManager::SCOPE_PRIVATE, IAccountManager::SCOPE_PRIVATE], [IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_LOCAL], + [IAccountManager::SCOPE_FEDERATED, IAccountManager::SCOPE_FEDERATED], [IAccountManager::SCOPE_PUBLISHED, IAccountManager::SCOPE_PUBLISHED], // legacy values [IAccountManager::VISIBILITY_PRIVATE, IAccountManager::SCOPE_LOCAL], |