Browse Source

Merge pull request #54310 from nextcloud/fix/conditional-federation-placeholders

fix(files_sharing): Implementation conditional federation placeholder
pull/54370/head
F. E Noel Nfebe 5 months ago
committed by GitHub
parent
commit
49e35f111c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 28
      apps/files_sharing/lib/Capabilities.php
  2. 7
      apps/files_sharing/src/services/ConfigService.ts
  3. 8
      apps/files_sharing/src/views/SharingTab.vue
  4. 16
      apps/files_sharing/tests/CapabilitiesTest.php
  5. 2
      dist/2261-2261.js
  6. 1
      dist/2261-2261.js.map
  7. 1
      dist/2261-2261.js.map.license
  8. 2
      dist/9283-9283.js
  9. 0
      dist/9283-9283.js.license
  10. 1
      dist/9283-9283.js.map
  11. 1
      dist/9283-9283.js.map.license
  12. 4
      dist/files_sharing-files_sharing_tab.js
  13. 2
      dist/files_sharing-files_sharing_tab.js.map
  14. 4
      dist/files_sharing-init.js
  15. 2
      dist/files_sharing-init.js.map

28
apps/files_sharing/lib/Capabilities.php

@ -7,6 +7,7 @@
*/
namespace OCA\Files_Sharing;
use OCP\App\IAppManager;
use OCP\Capabilities\ICapability;
use OCP\Constants;
use OCP\IConfig;
@ -18,10 +19,10 @@ use OCP\Share\IManager;
* @package OCA\Files_Sharing
*/
class Capabilities implements ICapability {
public function __construct(
private IConfig $config,
private IManager $shareManager,
private IAppManager $appManager,
) {
}
@ -158,14 +159,23 @@ class Capabilities implements ICapability {
}
//Federated sharing
$res['federation'] = [
'outgoing' => $this->shareManager->outgoingServer2ServerSharesAllowed(),
'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes',
// old bogus one, expire_date was not working before, keeping for compatibility
'expire_date' => ['enabled' => true],
// the real deal, signifies that expiration date can be set on federated shares
'expire_date_supported' => ['enabled' => true],
];
if ($this->appManager->isEnabledForAnyone('federation')) {
$res['federation'] = [
'outgoing' => $this->shareManager->outgoingServer2ServerSharesAllowed(),
'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes',
// old bogus one, expire_date was not working before, keeping for compatibility
'expire_date' => ['enabled' => true],
// the real deal, signifies that expiration date can be set on federated shares
'expire_date_supported' => ['enabled' => true],
];
} else {
$res['federation'] = [
'outgoing' => false,
'incoming' => false,
'expire_date' => ['enabled' => false],
'expire_date_supported' => ['enabled' => false],
];
}
// Sharee searches
$res['sharee'] = [

7
apps/files_sharing/src/services/ConfigService.ts

@ -212,6 +212,13 @@ export default class Config {
return window.OC.appConfig.core.remoteShareAllowed === true
}
/**
* Is federation enabled ?
*/
get isFederationEnabled(): boolean {
return this._capabilities?.files_sharing?.federation?.outgoing === true
}
/**
* Is public sharing enabled ?
*/

8
apps/files_sharing/src/views/SharingTab.vue

@ -268,21 +268,20 @@ export default {
},
internalShareInputPlaceholder() {
return this.config.showFederatedSharesAsInternal
return this.config.showFederatedSharesAsInternal && this.config.isFederationEnabled
? t('files_sharing', 'Share with accounts, teams, federated cloud IDs')
: t('files_sharing', 'Share with accounts and teams')
},
externalShareInputPlaceholder() {
if (!this.isLinkSharingAllowed) {
return t('files_sharing', 'Federated cloud ID')
return this.config.isFederationEnabled ? t('files_sharing', 'Federated cloud ID') : ''
}
return this.config.showFederatedSharesAsInternal
return !this.config.showFederatedSharesAsInternal && !this.config.isFederationEnabled
? t('files_sharing', 'Email')
: t('files_sharing', 'Email, federated cloud ID')
},
},
methods: {
/**
* Update current fileInfo and fetch new data
@ -294,7 +293,6 @@ export default {
this.resetState()
this.getShares()
},
/**
* Get the existing shares infos
*/

16
apps/files_sharing/tests/CapabilitiesTest.php

@ -11,6 +11,7 @@ use OC\KnownUser\KnownUserService;
use OC\Share20\Manager;
use OC\Share20\ShareDisableChecker;
use OCA\Files_Sharing\Capabilities;
use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
@ -55,9 +56,11 @@ class CapabilitiesTest extends \Test\TestCase {
* @param (string[])[] $map Map of arguments to return types for the getAppValue function in the mock
* @return string[]
*/
private function getResults(array $map) {
private function getResults(array $map, bool $federationEnabled = true) {
$config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock();
$appManager = $this->getMockBuilder(IAppManager::class)->disableOriginalConstructor()->getMock();
$config->method('getAppValue')->willReturnMap($map);
$appManager->method('isEnabledForAnyone')->with('federation')->willReturn($federationEnabled);
$shareManager = new Manager(
$this->createMock(LoggerInterface::class),
$config,
@ -79,7 +82,7 @@ class CapabilitiesTest extends \Test\TestCase {
$this->createMock(IDateTimeZone::class),
$this->createMock(IAppConfig::class),
);
$cap = new Capabilities($config, $shareManager);
$cap = new Capabilities($config, $shareManager, $appManager);
$result = $this->getFilesSharingPart($cap->getCapabilities());
return $result;
}
@ -323,4 +326,13 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertEquals(['enabled' => true], $result['federation']['expire_date']);
$this->assertEquals(['enabled' => true], $result['federation']['expire_date_supported']);
}
public function testFederatedSharingDisabled(): void {
$result = $this->getResults([], false);
$this->assertArrayHasKey('federation', $result);
$this->assertFalse($result['federation']['incoming']);
$this->assertFalse($result['federation']['outgoing']);
$this->assertEquals(['enabled' => false], $result['federation']['expire_date']);
$this->assertEquals(['enabled' => false], $result['federation']['expire_date_supported']);
}
}

2
dist/2261-2261.js
File diff suppressed because it is too large
View File

1
dist/2261-2261.js.map
File diff suppressed because it is too large
View File

1
dist/2261-2261.js.map.license

@ -1 +0,0 @@
2261-2261.js.license

2
dist/9283-9283.js
File diff suppressed because it is too large
View File

0
dist/2261-2261.js.license → dist/9283-9283.js.license

1
dist/9283-9283.js.map
File diff suppressed because it is too large
View File

1
dist/9283-9283.js.map.license

@ -0,0 +1 @@
9283-9283.js.license

4
dist/files_sharing-files_sharing_tab.js
File diff suppressed because it is too large
View File

2
dist/files_sharing-files_sharing_tab.js.map
File diff suppressed because it is too large
View File

4
dist/files_sharing-init.js
File diff suppressed because it is too large
View File

2
dist/files_sharing-init.js.map
File diff suppressed because it is too large
View File

Loading…
Cancel
Save