Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat(files_sharing): Add toggle for federated share display area
Signed-off-by: nfebe <[email protected]>
  • Loading branch information
nfebe committed May 6, 2025
commit 67ef7e1653911fb558fd6b5ea8b4d053f1abf2c3
6 changes: 6 additions & 0 deletions apps/files_sharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down Expand Up @@ -37,6 +38,7 @@
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;
Expand All @@ -47,6 +49,7 @@
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;
Expand Down Expand Up @@ -111,6 +114,9 @@ function () use ($c) {
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, 'show_federated_shares_as_internal', false));
});

Helper::registerHooks();

Expand Down
13 changes: 6 additions & 7 deletions apps/files_sharing/src/components/SharingInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions apps/files_sharing/src/services/ConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

}
27 changes: 24 additions & 3 deletions apps/files_sharing/src/views/SharingTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<!-- other shares list -->
Expand Down Expand Up @@ -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" />
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down