Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions apps/files_sharing/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
namespace OCA\Files_Sharing;

use OCP\App\IAppManager;
use OCP\Capabilities\ICapability;
use OCP\Constants;
use OCP\IConfig;
Expand All @@ -17,10 +18,10 @@
* @package OCA\Files_Sharing
*/
class Capabilities implements ICapability {

public function __construct(
private IConfig $config,
private IManager $shareManager,
private IAppManager $appManager,
) {
}

Expand Down Expand Up @@ -157,14 +158,23 @@ public function getCapabilities() {
}

//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->isInstalled('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'] = [
Expand Down
7 changes: 7 additions & 0 deletions apps/files_sharing/src/services/ConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
*/
Expand Down
6 changes: 2 additions & 4 deletions apps/files_sharing/src/views/SharingTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,13 @@ export default {

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
Expand All @@ -291,7 +290,6 @@ export default {
this.resetState()
this.getShares()
},

/**
* Get the existing shares infos
*/
Expand Down
16 changes: 14 additions & 2 deletions apps/files_sharing/tests/CapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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;
Expand Down Expand Up @@ -54,9 +55,11 @@ private function getFilesSharingPart(array $data) {
* @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('isInstalled')->with('federation')->willReturn($federationEnabled);
$shareManager = new Manager(
$this->createMock(LoggerInterface::class),
$config,
Expand All @@ -78,7 +81,7 @@ private function getResults(array $map) {
$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;
}
Expand Down Expand Up @@ -322,4 +325,13 @@ public function testFederatedSharingExpirationDate(): void {
$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 changes: 2 additions & 0 deletions dist/3265-3265.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/3265-3265.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/3265-3265.js.map.license
2 changes: 0 additions & 2 deletions dist/8723-8723.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/8723-8723.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/8723-8723.js.map.license

This file was deleted.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-init.js.map

Large diffs are not rendered by default.

Loading