aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/Capabilities.php28
-rw-r--r--apps/files_sharing/lib/Listener/LoadSidebarListener.php12
-rw-r--r--apps/files_sharing/src/components/SharingEntry.vue15
-rw-r--r--apps/files_sharing/src/components/SharingInput.vue44
-rw-r--r--apps/files_sharing/src/services/ConfigService.ts7
-rw-r--r--apps/files_sharing/src/views/SharingDetailsTab.vue5
-rw-r--r--apps/files_sharing/src/views/SharingTab.vue8
-rw-r--r--apps/files_sharing/tests/CapabilitiesTest.php16
8 files changed, 88 insertions, 47 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/lib/Listener/LoadSidebarListener.php b/apps/files_sharing/lib/Listener/LoadSidebarListener.php
index 88c39f38545..17fee71978f 100644
--- a/apps/files_sharing/lib/Listener/LoadSidebarListener.php
+++ b/apps/files_sharing/lib/Listener/LoadSidebarListener.php
@@ -15,6 +15,7 @@ use OCA\Files_Sharing\Config\ConfigLexicon;
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
+use OCP\GlobalScale\IConfig;
use OCP\IAppConfig;
use OCP\Server;
use OCP\Share\IManager;
@@ -35,10 +36,15 @@ class LoadSidebarListener implements IEventListener {
if (!($event instanceof LoadSidebar)) {
return;
}
+ Util::addScript(Application::APP_ID, 'files_sharing_tab', 'files');
$appConfig = Server::get(IAppConfig::class);
- $this->initialState->provideInitialState('showFederatedSharesAsInternal', $appConfig->getValueBool('files_sharing', ConfigLexicon::SHOW_FEDERATED_AS_INTERNAL));
- $this->initialState->provideInitialState('showFederatedSharesToTrustedServersAsInternal', $appConfig->getValueBool('files_sharing', ConfigLexicon::SHOW_FEDERATED_TO_TRUSTED_AS_INTERNAL));
- Util::addScript(Application::APP_ID, 'files_sharing_tab', 'files');
+ $gsConfig = Server::get(IConfig::class);
+ $showFederatedToTrustedAsInternal = $gsConfig->isGlobalScaleEnabled() || $appConfig->getValueBool('files_sharing', ConfigLexicon::SHOW_FEDERATED_TO_TRUSTED_AS_INTERNAL);
+ $showFederatedAsInternal = ($gsConfig->isGlobalScaleEnabled() && $gsConfig->onlyInternalFederation())
+ || $appConfig->getValueBool('files_sharing', ConfigLexicon::SHOW_FEDERATED_AS_INTERNAL);
+
+ $this->initialState->provideInitialState('showFederatedSharesAsInternal', $showFederatedAsInternal);
+ $this->initialState->provideInitialState('showFederatedSharesToTrustedServersAsInternal', $showFederatedToTrustedAsInternal);
}
}
diff --git a/apps/files_sharing/src/components/SharingEntry.vue b/apps/files_sharing/src/components/SharingEntry.vue
index 1fbe740cb11..342b40ce384 100644
--- a/apps/files_sharing/src/components/SharingEntry.vue
+++ b/apps/files_sharing/src/components/SharingEntry.vue
@@ -19,8 +19,9 @@
:href="share.shareWithLink"
class="sharing-entry__summary__desc">
<span>{{ title }}
- <span v-if="!isUnique" class="sharing-entry__summary__desc-unique"> ({{
- share.shareWithDisplayNameUnique }})</span>
+ <span v-if="!isUnique" class="sharing-entry__summary__desc-unique">
+ ({{ share.shareWithDisplayNameUnique }})
+ </span>
<small v-if="hasStatus && share.status.message">({{ share.status.message }})</small>
</span>
</component>
@@ -73,13 +74,17 @@ export default {
computed: {
title() {
let title = this.share.shareWithDisplayName
- if (this.share.type === ShareType.Group) {
+
+ const showAsInternal = this.config.showFederatedSharesAsInternal
+ || (this.share.isTrustedServer && this.config.showFederatedSharesToTrustedServersAsInternal)
+
+ if (this.share.type === ShareType.Group || (this.share.type === ShareType.RemoteGroup && showAsInternal)) {
title += ` (${t('files_sharing', 'group')})`
} else if (this.share.type === ShareType.Room) {
title += ` (${t('files_sharing', 'conversation')})`
- } else if (this.share.type === ShareType.Remote && !this.share.isTrustedServer) {
+ } else if (this.share.type === ShareType.Remote && !showAsInternal) {
title += ` (${t('files_sharing', 'remote')})`
- } else if (this.share.type === ShareType.RemoteGroup && !this.share.isTrustedServer) {
+ } else if (this.share.type === ShareType.RemoteGroup) {
title += ` (${t('files_sharing', 'remote group')})`
} else if (this.share.type === ShareType.Guest) {
title += ` (${t('files_sharing', 'guest')})`
diff --git a/apps/files_sharing/src/components/SharingInput.vue b/apps/files_sharing/src/components/SharingInput.vue
index f50dc96fc08..46bacef0c6c 100644
--- a/apps/files_sharing/src/components/SharingInput.vue
+++ b/apps/files_sharing/src/components/SharingInput.vue
@@ -195,17 +195,15 @@ export default {
const remoteTypes = [ShareType.Remote, ShareType.RemoteGroup]
const shareType = []
- const showFederatedAsInternal
- = this.config.showFederatedSharesAsInternal
- || this.config.showFederatedSharesToTrustedServersAsInternal
-
- const shouldAddRemoteTypes
- // For internal users, add remote types if config says to show them as internal
- = (!this.isExternal && showFederatedAsInternal)
- // For external users, add them if config *doesn't* say to show them as internal
- || (this.isExternal && !showFederatedAsInternal)
- // Edge case: federated-to-trusted is a separate "add" trigger for external users
- || (this.isExternal && this.config.showFederatedSharesToTrustedServersAsInternal)
+ const showFederatedAsInternal = this.config.showFederatedSharesAsInternal
+ || this.config.showFederatedSharesToTrustedServersAsInternal
+
+ // For internal users, add remote types if config says to show them as internal
+ const shouldAddRemoteTypes = (!this.isExternal && showFederatedAsInternal)
+ // For external users, add them if config *doesn't* say to show them as internal
+ || (this.isExternal && !showFederatedAsInternal)
+ // Edge case: federated-to-trusted is a separate "add" trigger for external users
+ || (this.isExternal && this.config.showFederatedSharesToTrustedServersAsInternal)
if (this.isExternal) {
if (getCapabilities().files_sharing.public.enabled === true) {
@@ -244,13 +242,10 @@ export default {
return
}
- const data = request.data.ocs.data
- const exact = request.data.ocs.data.exact
- data.exact = [] // removing exact from general results
-
+ const { exact, ...data } = request.data.ocs.data
// flatten array of arrays
- const rawExactSuggestions = Object.values(exact).reduce((arr, elem) => arr.concat(elem), [])
- const rawSuggestions = Object.values(data).reduce((arr, elem) => arr.concat(elem), [])
+ const rawExactSuggestions = Object.values(exact).flat()
+ const rawSuggestions = Object.values(data).flat()
// remove invalid data and format to user-select layout
const exactSuggestions = this.filterOutExistingShares(rawExactSuggestions)
@@ -470,14 +465,19 @@ export default {
*/
formatForMultiselect(result) {
let subname
+ let displayName = result.name || result.label
+
if (result.value.shareType === ShareType.User && this.config.shouldAlwaysShowUnique) {
subname = result.shareWithDisplayNameUnique ?? ''
- } else if ((result.value.shareType === ShareType.Remote
- || result.value.shareType === ShareType.RemoteGroup
- ) && result.value.server) {
- subname = t('files_sharing', 'on {server}', { server: result.value.server })
} else if (result.value.shareType === ShareType.Email) {
subname = result.value.shareWith
+ } else if (result.value.shareType === ShareType.Remote || result.value.shareType === ShareType.RemoteGroup) {
+ if (this.config.showFederatedSharesAsInternal) {
+ subname = result.extra?.email?.value ?? ''
+ displayName = result.extra?.name?.value ?? displayName
+ } else if (result.value.server) {
+ subname = t('files_sharing', 'on {server}', { server: result.value.server })
+ }
} else {
subname = result.shareWithDescription ?? ''
}
@@ -487,7 +487,7 @@ export default {
shareType: result.value.shareType,
user: result.uuid || result.value.shareWith,
isNoUser: result.value.shareType !== ShareType.User,
- displayName: result.name || result.label,
+ displayName,
subname,
shareWithDisplayNameUnique: result.shareWithDisplayNameUnique || '',
...this.shareTypeToIcon(result.value.shareType),
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/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue
index ee902a24c8a..b3a3b95d92e 100644
--- a/apps/files_sharing/src/views/SharingDetailsTab.vue
+++ b/apps/files_sharing/src/views/SharingDetailsTab.vue
@@ -373,7 +373,7 @@ export default {
title() {
switch (this.share.type) {
case ShareType.User:
- return t('files_sharing', 'Share with {userName}', { userName: this.share.shareWithDisplayName })
+ return t('files_sharing', 'Share with {user}', { user: this.share.shareWithDisplayName })
case ShareType.Email:
return t('files_sharing', 'Share with email {email}', { email: this.share.shareWith })
case ShareType.Link:
@@ -384,6 +384,9 @@ export default {
return t('files_sharing', 'Share in conversation')
case ShareType.Remote: {
const [user, server] = this.share.shareWith.split('@')
+ if (this.config.showFederatedSharesAsInternal) {
+ return t('files_sharing', 'Share with {user}', { user })
+ }
return t('files_sharing', 'Share with {user} on remote server {server}', { user, server })
}
case ShareType.RemoteGroup:
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..2fe221703a5 100644
--- a/apps/files_sharing/tests/CapabilitiesTest.php
+++ b/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']);
+ }
}