From 83b39d6111fe5c63fe3d488d15e565fd04e1ceaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 16 Apr 2021 18:21:11 +0200 Subject: [PATCH 1/4] Add missing scope to test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- tests/lib/Accounts/AccountPropertyTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/lib/Accounts/AccountPropertyTest.php b/tests/lib/Accounts/AccountPropertyTest.php index 50c3b8f84a439..c2ba96ef8a50a 100644 --- a/tests/lib/Accounts/AccountPropertyTest.php +++ b/tests/lib/Accounts/AccountPropertyTest.php @@ -78,6 +78,7 @@ public function scopesProvider() { // 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], From 2c70e4689af774d010a1106bf17559071ee926e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 16 Apr 2021 18:24:40 +0200 Subject: [PATCH 2/4] Fix "Federated" scope not shown when the lookup server is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the lookup server is disabled the address books can still be exchanged between trusted servers. Therefore the user should be able to set the "Federated" scope in that case. Signed-off-by: Daniel Calviño Sánchez --- apps/settings/js/federationsettingsview.js | 8 ++++---- apps/settings/js/settings/personalInfo.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/settings/js/federationsettingsview.js b/apps/settings/js/federationsettingsview.js index 602acab5c8deb..58e2583546c6e 100644 --- a/apps/settings/js/federationsettingsview.js +++ b/apps/settings/js/federationsettingsview.js @@ -15,7 +15,8 @@ * @constructs FederationScopeMenu * @memberof OC.Settings * @param {object} options - * @param {bool} [options.lookupServerUploadEnabled=false] whether uploading to the lookup server is enabled + * @param {bool} [options.showPublishedScope=false] whether show the + * "v2-published" scope or not */ var FederationSettingsView = OC.Backbone.View.extend({ _inputFields: undefined, @@ -31,7 +32,7 @@ } else { this._config = new OC.Settings.UserSettings(); } - this.showFederationScopes = !!options.showFederationScopes; + this.showPublishedScope = !!options.showPublishedScope; this._inputFields = [ 'displayname', @@ -85,8 +86,7 @@ excludedScopes.push('v2-private'); } - if (!self.showFederationScopes) { - 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 2e57537d424df..72ce39d5693b8 100644 --- a/apps/settings/js/settings/personalInfo.js +++ b/apps/settings/js/settings/personalInfo.js @@ -204,7 +204,7 @@ window.addEventListener('DOMContentLoaded', function () { var federationSettingsView = new OC.Settings.FederationSettingsView({ el: settingsEl, config: userSettings, - showFederationScopes: !!settingsEl.data('lookup-server-upload-enabled'), + showPublishedScope: !!settingsEl.data('lookup-server-upload-enabled'), }); userSettings.on("sync", function() { From 1e19b1cc994d38b19a29494cc1579fe3182a34bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 24 Jun 2021 01:46:44 +0200 Subject: [PATCH 3/4] Hide "federated" scope when Federation app is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the Federation app is disabled it is not possible to synchronize the users from a different server. Signed-off-by: Daniel Calviño Sánchez --- apps/settings/js/federationsettingsview.js | 7 +++++++ apps/settings/js/settings/personalInfo.js | 1 + apps/settings/lib/Settings/Personal/PersonalInfo.php | 2 ++ .../settings/templates/settings/personal/personal.info.php | 3 ++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/settings/js/federationsettingsview.js b/apps/settings/js/federationsettingsview.js index 58e2583546c6e..ca56992b1ed66 100644 --- a/apps/settings/js/federationsettingsview.js +++ b/apps/settings/js/federationsettingsview.js @@ -15,6 +15,8 @@ * @constructs FederationScopeMenu * @memberof OC.Settings * @param {object} options + * @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 */ @@ -32,6 +34,7 @@ } else { this._config = new OC.Settings.UserSettings(); } + this.showFederatedScope = !!options.showFederatedScope; this.showPublishedScope = !!options.showPublishedScope; this._inputFields = [ @@ -86,6 +89,10 @@ excludedScopes.push('v2-private'); } + 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 72ce39d5693b8..dcac153c1f64f 100644 --- a/apps/settings/js/settings/personalInfo.js +++ b/apps/settings/js/settings/personalInfo.js @@ -204,6 +204,7 @@ window.addEventListener('DOMContentLoaded', function () { var federationSettingsView = new OC.Settings.FederationSettingsView({ el: settingsEl, config: userSettings, + showFederatedScope: !!settingsEl.data('federation-enabled'), showPublishedScope: !!settingsEl.data('lookup-server-upload-enabled'), }); diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php index 387843c552258..fede5c4f5948b 100644 --- a/apps/settings/lib/Settings/Personal/PersonalInfo.php +++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php @@ -92,6 +92,7 @@ public function __construct( } public function getForm(): TemplateResponse { + $federationEnabled = $this->appManager->isEnabledForUser('federation'); $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); $lookupServerUploadEnabled = false; if ($federatedFileSharingEnabled) { @@ -124,6 +125,7 @@ public function getForm(): TemplateResponse { '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 23ee1ca0367a7..c1a5735aa8fdf 100644 --- a/apps/settings/templates/settings/personal/personal.info.php +++ b/apps/settings/templates/settings/personal/personal.info.php @@ -35,7 +35,8 @@ ]); ?> -
+

t('Personal info')); ?>

From 193cf6cfde8a91e225947021e582997403074c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 24 Jun 2021 01:47:07 +0200 Subject: [PATCH 4/4] Split capability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "federated" and "published" scopes are independent one from each other, so the capability that encompassed both needs to be split. Signed-off-by: Daniel Calviño Sánchez --- apps/provisioning_api/lib/Capabilities.php | 9 ++++--- .../tests/CapabilitiesTest.php | 24 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/apps/provisioning_api/lib/Capabilities.php b/apps/provisioning_api/lib/Capabilities.php index 59c462c5d90c1..835bbfe9b5c62 100644 --- a/apps/provisioning_api/lib/Capabilities.php +++ b/apps/provisioning_api/lib/Capabilities.php @@ -41,20 +41,23 @@ public function __construct(IAppManager $appManager) { * @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 97f9ba562bcf3..8fc29b442eb4e 100644 --- a/apps/provisioning_api/tests/CapabilitiesTest.php +++ b/apps/provisioning_api/tests/CapabilitiesTest.php @@ -57,20 +57,25 @@ public function setUp(): void { 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 @@ public function testGetCapabilities($federationAppEnabled, $lookupServerEnabled, 'provisioning_api' => [ 'version' => '1.12', 'AccountPropertyScopesVersion' => 2, - 'AccountPropertyScopesFederationEnabled' => $expectedFederationScopesEnabled, + 'AccountPropertyScopesFederatedEnabled' => $expectedFederatedScopeEnabled, + 'AccountPropertyScopesPublishedEnabled' => $expectedPublishedScopeEnabled, ], ]; $this->assertSame($expected, $this->capabilities->getCapabilities());