aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/lib/Capabilities.php28
-rw-r--r--apps/files_sharing/src/services/ConfigService.ts7
-rw-r--r--apps/files_sharing/src/views/SharingTab.vue8
-rw-r--r--apps/files_sharing/tests/CapabilitiesTest.php4
4 files changed, 32 insertions, 15 deletions
diff --git a/apps/files_sharing/lib/Capabilities.php b/apps/files_sharing/lib/Capabilities.php
index b4fe5a1bb73..cbb9b5cd2f2 100644
--- a/apps/files_sharing/lib/Capabilities.php
+++ b/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'] = [
diff --git a/apps/files_sharing/src/services/ConfigService.ts b/apps/files_sharing/src/services/ConfigService.ts
index f75f34c7936..547038f362d 100644
--- a/apps/files_sharing/src/services/ConfigService.ts
+++ b/apps/files_sharing/src/services/ConfigService.ts
@@ -213,6 +213,13 @@ export default class Config {
}
/**
+ * Is federation enabled ?
+ */
+ get isFederationEnabled(): boolean {
+ return this._capabilities?.files_sharing?.federation?.outgoing === true
+ }
+
+ /**
* Is public sharing enabled ?
*/
get isPublicShareAllowed(): boolean {
diff --git a/apps/files_sharing/src/views/SharingTab.vue b/apps/files_sharing/src/views/SharingTab.vue
index dc200c61df4..9900d6c562d 100644
--- a/apps/files_sharing/src/views/SharingTab.vue
+++ b/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
*/
diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php
index 2600bd9d925..aab905fef29 100644
--- a/apps/files_sharing/tests/CapabilitiesTest.php
+++ b/apps/files_sharing/tests/CapabilitiesTest.php
@@ -15,6 +15,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
use OCP\IAppConfig;
+use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\IDateTimeZone;
use OCP\IGroupManager;
@@ -57,6 +58,7 @@ class CapabilitiesTest extends \Test\TestCase {
*/
private function getResults(array $map) {
$config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock();
+ $appManager = $this->getMockBuilder(IAppManager::class)->disableOriginalConstructor()->getMock();
$config->method('getAppValue')->willReturnMap($map);
$shareManager = new Manager(
$this->createMock(LoggerInterface::class),
@@ -79,7 +81,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;
}