From 1c50329fdbfb2c2fcfc4997c2283326c5c76bf1b Mon Sep 17 00:00:00 2001 From: nfebe Date: Mon, 28 Apr 2025 18:17:24 +0100 Subject: feat(files_sharing): Add toggle for federated share display area Signed-off-by: nfebe --- apps/files_sharing/src/components/SharingInput.vue | 13 +++++------ apps/files_sharing/src/services/ConfigService.ts | 11 +++++++++ apps/files_sharing/src/views/SharingTab.vue | 27 +++++++++++++++++++--- 3 files changed, 41 insertions(+), 10 deletions(-) (limited to 'apps/files_sharing/src') diff --git a/apps/files_sharing/src/components/SharingInput.vue b/apps/files_sharing/src/components/SharingInput.vue index 49a39915e5e..a7d5ed73eaf 100644 --- a/apps/files_sharing/src/components/SharingInput.vue +++ b/apps/files_sharing/src/components/SharingInput.vue @@ -194,11 +194,11 @@ export default { let shareType = [] + const remoteTypes = [ShareType.Remote, ShareType.RemoteGroup] + if (this.isExternal) { - shareType.push(ShareType.Remote) - shareType.push(ShareType.RemoteGroup) + shareType.push(...remoteTypes) } else { - // Merge shareType array shareType = shareType.concat([ ShareType.User, ShareType.Group, @@ -209,10 +209,9 @@ export default { ShareType.ScienceMesh, ]) - } - - if (getCapabilities().files_sharing.public.enabled === true && this.isExternal) { - shareType.push(ShareType.Email) + if (this.config.showFederatedSharesAsInternal) { + shareType.push(...remoteTypes) + } } let request = null diff --git a/apps/files_sharing/src/services/ConfigService.ts b/apps/files_sharing/src/services/ConfigService.ts index 09fdca13598..b92887d18b6 100644 --- a/apps/files_sharing/src/services/ConfigService.ts +++ b/apps/files_sharing/src/services/ConfigService.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ import { getCapabilities } from '@nextcloud/capabilities' +import { loadState } from '@nextcloud/initial-state' type PasswordPolicyCapabilities = { enforceNonCommonPassword: boolean @@ -306,4 +307,14 @@ export default class Config { return this._capabilities?.files_sharing?.public?.custom_tokens } + /** + * Show federated shares as internal shares + * @return {boolean} + */ + get showFederatedSharesAsInternal(): boolean { + const showFederatedSharesAsInternal = loadState('files_sharing', 'showFederatedSharesAsInternal', false) + + return !!showFederatedSharesAsInternal + } + } diff --git a/apps/files_sharing/src/views/SharingTab.vue b/apps/files_sharing/src/views/SharingTab.vue index e9e068a7c1d..f9b7737f1ef 100644 --- a/apps/files_sharing/src/views/SharingTab.vue +++ b/apps/files_sharing/src/views/SharingTab.vue @@ -50,7 +50,7 @@ :link-shares="linkShares" :reshare="reshare" :shares="shares" - :placeholder="t('files_sharing', 'Share with accounts and teams')" + :placeholder="internalShareInputPlaceholder" @open-sharing-details="toggleShareDetailsView" /> @@ -90,7 +90,7 @@ :file-info="fileInfo" :link-shares="linkShares" :is-external="true" - :placeholder="t('files_sharing', 'Email, federated cloud id')" + :placeholder="externalShareInputPlaceholder" :reshare="reshare" :shares="shares" @open-sharing-details="toggleShareDetailsView" /> @@ -249,6 +249,18 @@ export default { return !!(this.fileInfo.permissions & OC.PERMISSION_SHARE) || !!(this.reshare && this.reshare.hasSharePermission && this.config.isResharingAllowed) }, + + internalShareInputPlaceholder() { + return this.config.showFederatedSharesAsInternal + ? t('files_sharing', 'Share with accounts, teams, federated cloud id') + : t('files_sharing', 'Share with accounts and teams') + }, + + externalShareInputPlaceholder() { + return this.config.showFederatedSharesAsInternal + ? t('files_sharing', 'Email') + : t('files_sharing', 'Email, federated cloud id') + }, }, methods: { @@ -369,7 +381,11 @@ export default { if ([ShareType.Link, ShareType.Email].includes(share.type)) { this.linkShares.push(share) } else if ([ShareType.Remote, ShareType.RemoteGroup].includes(share.type)) { - this.externalShares.push(share) + if (this.config.showFederatedSharesAsInternal) { + this.shares.push(share) + } else { + this.externalShares.push(share) + } } else { this.shares.push(share) } @@ -439,6 +455,11 @@ export default { if (share.type === ShareType.Email) { this.linkShares.unshift(share) } else if ([ShareType.Remote, ShareType.RemoteGroup].includes(share.type)) { + if (this.config.showFederatedSharesAsInternal) { + this.shares.unshift(share) + } else { + this.externalShares.unshift(share) + } this.externalShares.unshift(share) } else { this.shares.unshift(share) -- cgit v1.2.3 From f471bd292fa70937050f971cba3b07e8ca3ae9d2 Mon Sep 17 00:00:00 2001 From: nfebe Date: Sat, 3 May 2025 10:34:21 +0100 Subject: fix(files_sharing): Move `ConfigLexicon` to Config dir, update sharing input - Fix autoloading for new `ConfigLexicon` - Ensure that sharing input in sharing tab respect `show-federated-shares-as-internal`: This is important, because when federated shares are shown as internal the users should add them from the internal shares section Signed-off-by: nfebe --- .../composer/composer/autoload_classmap.php | 1 + .../composer/composer/autoload_static.php | 1 + apps/files_sharing/lib/AppInfo/Application.php | 6 +--- apps/files_sharing/lib/AppInfo/ConfigLexicon.php | 39 ---------------------- apps/files_sharing/lib/Config/ConfigLexicon.php | 39 ++++++++++++++++++++++ .../lib/Listener/LoadSidebarListener.php | 5 +++ apps/files_sharing/src/components/SharingInput.vue | 6 +++- apps/files_sharing/src/services/ConfigService.ts | 4 +-- apps/files_sharing/src/views/SharingTab.vue | 1 - 9 files changed, 53 insertions(+), 49 deletions(-) delete mode 100644 apps/files_sharing/lib/AppInfo/ConfigLexicon.php create mode 100644 apps/files_sharing/lib/Config/ConfigLexicon.php (limited to 'apps/files_sharing/src') diff --git a/apps/files_sharing/composer/composer/autoload_classmap.php b/apps/files_sharing/composer/composer/autoload_classmap.php index 8682fd5f238..92751ead730 100644 --- a/apps/files_sharing/composer/composer/autoload_classmap.php +++ b/apps/files_sharing/composer/composer/autoload_classmap.php @@ -29,6 +29,7 @@ return array( 'OCA\\Files_Sharing\\Command\\ExiprationNotification' => $baseDir . '/../lib/Command/ExiprationNotification.php', 'OCA\\Files_Sharing\\Command\\FixShareOwners' => $baseDir . '/../lib/Command/FixShareOwners.php', 'OCA\\Files_Sharing\\Command\\ListShares' => $baseDir . '/../lib/Command/ListShares.php', + 'OCA\\Files_Sharing\\Config\\ConfigLexicon' => $baseDir . '/../lib/Config/ConfigLexicon.php', 'OCA\\Files_Sharing\\Controller\\AcceptController' => $baseDir . '/../lib/Controller/AcceptController.php', 'OCA\\Files_Sharing\\Controller\\DeletedShareAPIController' => $baseDir . '/../lib/Controller/DeletedShareAPIController.php', 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => $baseDir . '/../lib/Controller/ExternalSharesController.php', diff --git a/apps/files_sharing/composer/composer/autoload_static.php b/apps/files_sharing/composer/composer/autoload_static.php index 3bf5bcdffda..6ca952007a1 100644 --- a/apps/files_sharing/composer/composer/autoload_static.php +++ b/apps/files_sharing/composer/composer/autoload_static.php @@ -44,6 +44,7 @@ class ComposerStaticInitFiles_Sharing 'OCA\\Files_Sharing\\Command\\ExiprationNotification' => __DIR__ . '/..' . '/../lib/Command/ExiprationNotification.php', 'OCA\\Files_Sharing\\Command\\FixShareOwners' => __DIR__ . '/..' . '/../lib/Command/FixShareOwners.php', 'OCA\\Files_Sharing\\Command\\ListShares' => __DIR__ . '/..' . '/../lib/Command/ListShares.php', + 'OCA\\Files_Sharing\\Config\\ConfigLexicon' => __DIR__ . '/..' . '/../lib/Config/ConfigLexicon.php', 'OCA\\Files_Sharing\\Controller\\AcceptController' => __DIR__ . '/..' . '/../lib/Controller/AcceptController.php', 'OCA\\Files_Sharing\\Controller\\DeletedShareAPIController' => __DIR__ . '/..' . '/../lib/Controller/DeletedShareAPIController.php', 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => __DIR__ . '/..' . '/../lib/Controller/ExternalSharesController.php', diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 1fdd042869f..8ddb3afaf33 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -13,6 +13,7 @@ use OC\User\DisplayNameCache; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadSidebar; use OCA\Files_Sharing\Capabilities; +use OCA\Files_Sharing\Config\ConfigLexicon; use OCA\Files_Sharing\External\Manager; use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider; use OCA\Files_Sharing\Helper; @@ -38,7 +39,6 @@ use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; -use OCP\AppFramework\Services\IInitialState; use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent as ResourcesLoadAdditionalScriptsEvent; use OCP\EventDispatcher\IEventDispatcher; use OCP\Federation\ICloudIdManager; @@ -49,7 +49,6 @@ use OCP\Files\Events\Node\BeforeNodeReadEvent; use OCP\Group\Events\GroupChangedEvent; use OCP\Group\Events\GroupDeletedEvent; use OCP\Group\Events\UserAddedEvent; -use OCP\IAppConfig; use OCP\IDBConnection; use OCP\IGroup; use OCP\Share\Events\ShareCreatedEvent; @@ -116,9 +115,6 @@ class Application extends App implements IBootstrap { public function boot(IBootContext $context): void { $context->injectFn([$this, 'registerMountProviders']); $context->injectFn([$this, 'registerEventsScripts']); - $context->injectFn(function (IInitialState $initialState, IAppConfig $appConfig) { - $initialState->provideInitialState('showFederatedSharesAsInternal', $appConfig->getValueBool(self::APP_ID, ConfigLexicon::SHOW_FEDERATED_AS_INTERNAL)); - }); Helper::registerHooks(); diff --git a/apps/files_sharing/lib/AppInfo/ConfigLexicon.php b/apps/files_sharing/lib/AppInfo/ConfigLexicon.php deleted file mode 100644 index 90739fac633..00000000000 --- a/apps/files_sharing/lib/AppInfo/ConfigLexicon.php +++ /dev/null @@ -1,39 +0,0 @@ -initialState->provideInitialState('showFederatedSharesAsInternal', $appConfig->getValueBool('files_sharing', ConfigLexicon::SHOW_FEDERATED_AS_INTERNAL)); Util::addScript(Application::APP_ID, 'files_sharing_tab', 'files'); } } diff --git a/apps/files_sharing/src/components/SharingInput.vue b/apps/files_sharing/src/components/SharingInput.vue index a7d5ed73eaf..b886ba95a17 100644 --- a/apps/files_sharing/src/components/SharingInput.vue +++ b/apps/files_sharing/src/components/SharingInput.vue @@ -196,7 +196,7 @@ export default { const remoteTypes = [ShareType.Remote, ShareType.RemoteGroup] - if (this.isExternal) { + if (this.isExternal && !this.config.showFederatedSharesAsInternal) { shareType.push(...remoteTypes) } else { shareType = shareType.concat([ @@ -214,6 +214,10 @@ export default { } } + if (getCapabilities().files_sharing.public.enabled === true && this.isExternal) { + shareType.push(ShareType.Email) + } + let request = null try { request = await axios.get(generateOcsUrl('apps/files_sharing/api/v1/sharees'), { diff --git a/apps/files_sharing/src/services/ConfigService.ts b/apps/files_sharing/src/services/ConfigService.ts index b92887d18b6..2114e2d1bae 100644 --- a/apps/files_sharing/src/services/ConfigService.ts +++ b/apps/files_sharing/src/services/ConfigService.ts @@ -312,9 +312,7 @@ export default class Config { * @return {boolean} */ get showFederatedSharesAsInternal(): boolean { - const showFederatedSharesAsInternal = loadState('files_sharing', 'showFederatedSharesAsInternal', false) - - return !!showFederatedSharesAsInternal + return loadState('files_sharing', 'showFederatedSharesAsInternal', false) } } diff --git a/apps/files_sharing/src/views/SharingTab.vue b/apps/files_sharing/src/views/SharingTab.vue index f9b7737f1ef..1b5275bcf7e 100644 --- a/apps/files_sharing/src/views/SharingTab.vue +++ b/apps/files_sharing/src/views/SharingTab.vue @@ -460,7 +460,6 @@ export default { } else { this.externalShares.unshift(share) } - this.externalShares.unshift(share) } else { this.shares.unshift(share) } -- cgit v1.2.3