mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 06:37:56 -04:00
Merge pull request #52498 from nextcloud/backport/52423/stable31
[stable31] fix(files_sharing): Show remote shares as external
This commit is contained in:
commit
36cd949586
20 changed files with 120 additions and 24 deletions
|
|
@ -14,10 +14,7 @@ if (PHP_VERSION_ID < 50600) {
|
|||
echo $err;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
$err,
|
||||
E_USER_ERROR
|
||||
);
|
||||
throw new RuntimeException($err);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ return array(
|
|||
'OCA\\Files_Sharing\\Command\\DeleteOrphanShares' => $baseDir . '/../lib/Command/DeleteOrphanShares.php',
|
||||
'OCA\\Files_Sharing\\Command\\ExiprationNotification' => $baseDir . '/../lib/Command/ExiprationNotification.php',
|
||||
'OCA\\Files_Sharing\\Command\\FixShareOwners' => $baseDir . '/../lib/Command/FixShareOwners.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',
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class ComposerStaticInitFiles_Sharing
|
|||
'OCA\\Files_Sharing\\Command\\DeleteOrphanShares' => __DIR__ . '/..' . '/../lib/Command/DeleteOrphanShares.php',
|
||||
'OCA\\Files_Sharing\\Command\\ExiprationNotification' => __DIR__ . '/..' . '/../lib/Command/ExiprationNotification.php',
|
||||
'OCA\\Files_Sharing\\Command\\FixShareOwners' => __DIR__ . '/..' . '/../lib/Command/FixShareOwners.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',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -12,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;
|
||||
|
|
@ -106,6 +108,8 @@ class Application extends App implements IBootstrap {
|
|||
|
||||
// File request auth
|
||||
$context->registerEventListener(BeforeTemplateRenderedEvent::class, LoadPublicFileRequestAuthListener::class);
|
||||
|
||||
$context->registerConfigLexicon(ConfigLexicon::class);
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
|
|
|
|||
39
apps/files_sharing/lib/Config/ConfigLexicon.php
Normal file
39
apps/files_sharing/lib/Config/ConfigLexicon.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Files_Sharing\Config;
|
||||
|
||||
use NCU\Config\Lexicon\ConfigLexiconEntry;
|
||||
use NCU\Config\Lexicon\ConfigLexiconStrictness;
|
||||
use NCU\Config\Lexicon\IConfigLexicon;
|
||||
use NCU\Config\ValueType;
|
||||
|
||||
/**
|
||||
* Config Lexicon for files_sharing.
|
||||
*
|
||||
* Please Add & Manage your Config Keys in that file and keep the Lexicon up to date!
|
||||
*
|
||||
* {@see IConfigLexicon}
|
||||
*/
|
||||
class ConfigLexicon implements IConfigLexicon {
|
||||
public const SHOW_FEDERATED_AS_INTERNAL = 'show_federated_shares_as_internal';
|
||||
|
||||
public function getStrictness(): ConfigLexiconStrictness {
|
||||
return ConfigLexiconStrictness::IGNORE;
|
||||
}
|
||||
|
||||
public function getAppConfigs(): array {
|
||||
return [
|
||||
new ConfigLexiconEntry(self::SHOW_FEDERATED_AS_INTERNAL, ValueType::BOOL, false, 'shows federated shares as internal shares', true),
|
||||
];
|
||||
}
|
||||
|
||||
public function getUserConfigs(): array {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -11,9 +11,12 @@ namespace OCA\Files_Sharing\Listener;
|
|||
|
||||
use OCA\Files\Event\LoadSidebar;
|
||||
use OCA\Files_Sharing\AppInfo\Application;
|
||||
use OCA\Files_Sharing\Config\ConfigLexicon;
|
||||
use OCP\AppFramework\Services\IInitialState;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\Server;
|
||||
use OCP\Share\IManager;
|
||||
use OCP\Util;
|
||||
|
||||
|
|
@ -33,6 +36,8 @@ class LoadSidebarListener implements IEventListener {
|
|||
return;
|
||||
}
|
||||
|
||||
$appConfig = Server::get(IAppConfig::class);
|
||||
$this->initialState->provideInitialState('showFederatedSharesAsInternal', $appConfig->getValueBool('files_sharing', ConfigLexicon::SHOW_FEDERATED_AS_INTERNAL));
|
||||
Util::addScript(Application::APP_ID, 'files_sharing_tab', 'files');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,11 +194,11 @@ export default {
|
|||
|
||||
let shareType = []
|
||||
|
||||
if (this.isExternal) {
|
||||
shareType.push(ShareType.Remote)
|
||||
shareType.push(ShareType.RemoteGroup)
|
||||
const remoteTypes = [ShareType.Remote, ShareType.RemoteGroup]
|
||||
|
||||
if (this.isExternal && !this.config.showFederatedSharesAsInternal) {
|
||||
shareType.push(...remoteTypes)
|
||||
} else {
|
||||
// Merge shareType array
|
||||
shareType = shareType.concat([
|
||||
ShareType.User,
|
||||
ShareType.Group,
|
||||
|
|
@ -209,6 +209,9 @@ export default {
|
|||
ShareType.ScienceMesh,
|
||||
])
|
||||
|
||||
if (this.config.showFederatedSharesAsInternal) {
|
||||
shareType.push(...remoteTypes)
|
||||
}
|
||||
}
|
||||
|
||||
if (getCapabilities().files_sharing.public.enabled === true && this.isExternal) {
|
||||
|
|
|
|||
|
|
@ -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,12 @@ export default class Config {
|
|||
return this._capabilities?.files_sharing?.public?.custom_tokens
|
||||
}
|
||||
|
||||
/**
|
||||
* Show federated shares as internal shares
|
||||
* @return {boolean}
|
||||
*/
|
||||
get showFederatedSharesAsInternal(): boolean {
|
||||
return loadState('files_sharing', 'showFederatedSharesAsInternal', false)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 -->
|
||||
|
|
@ -90,10 +90,15 @@
|
|||
: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" />
|
||||
<!-- Non link external shares list -->
|
||||
<SharingList v-if="!loading"
|
||||
:shares="externalShares"
|
||||
:file-info="fileInfo"
|
||||
@open-sharing-details="toggleShareDetailsView" />
|
||||
<!-- link shares list -->
|
||||
<SharingLinkList v-if="!loading"
|
||||
ref="linkShareList"
|
||||
|
|
@ -180,6 +185,7 @@ import SharingList from './SharingList.vue'
|
|||
import SharingDetailsTab from './SharingDetailsTab.vue'
|
||||
|
||||
import ShareDetails from '../mixins/ShareDetails.js'
|
||||
import logger from '../services/logger.ts'
|
||||
|
||||
export default {
|
||||
name: 'SharingTab',
|
||||
|
|
@ -215,6 +221,7 @@ export default {
|
|||
sharedWithMe: {},
|
||||
shares: [],
|
||||
linkShares: [],
|
||||
externalShares: [],
|
||||
|
||||
sections: OCA.Sharing.ShareTabSections.getSections(),
|
||||
projectsEnabled: loadState('core', 'projects_enabled', false),
|
||||
|
|
@ -242,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: {
|
||||
|
|
@ -358,11 +377,23 @@ export default {
|
|||
],
|
||||
)
|
||||
|
||||
this.linkShares = shares.filter(share => share.type === ShareType.Link || share.type === ShareType.Email)
|
||||
this.shares = shares.filter(share => share.type !== ShareType.Link && share.type !== ShareType.Email)
|
||||
for (const share of shares) {
|
||||
if ([ShareType.Link, ShareType.Email].includes(share.type)) {
|
||||
this.linkShares.push(share)
|
||||
} else if ([ShareType.Remote, ShareType.RemoteGroup].includes(share.type)) {
|
||||
if (this.config.showFederatedSharesAsInternal) {
|
||||
this.shares.push(share)
|
||||
} else {
|
||||
this.externalShares.push(share)
|
||||
}
|
||||
} else {
|
||||
this.shares.push(share)
|
||||
}
|
||||
}
|
||||
|
||||
console.debug('Processed', this.linkShares.length, 'link share(s)')
|
||||
console.debug('Processed', this.shares.length, 'share(s)')
|
||||
logger.debug(`Processed ${this.linkShares.length} link share(s)`)
|
||||
logger.debug(`Processed ${this.shares.length} share(s)`)
|
||||
logger.debug(`Processed ${this.externalShares.length} external share(s)`)
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -423,6 +454,12 @@ export default {
|
|||
// meaning: not from the ShareInput
|
||||
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)
|
||||
}
|
||||
} else {
|
||||
this.shares.unshift(share)
|
||||
}
|
||||
|
|
|
|||
2
dist/3421-3421.js
vendored
Normal file
2
dist/3421-3421.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/3421-3421.js.map
vendored
Normal file
1
dist/3421-3421.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/3421-3421.js.map.license
vendored
Symbolic link
1
dist/3421-3421.js.map.license
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
3421-3421.js.license
|
||||
2
dist/4477-4477.js
vendored
2
dist/4477-4477.js
vendored
File diff suppressed because one or more lines are too long
1
dist/4477-4477.js.map
vendored
1
dist/4477-4477.js.map
vendored
File diff suppressed because one or more lines are too long
1
dist/4477-4477.js.map.license
vendored
1
dist/4477-4477.js.map.license
vendored
|
|
@ -1 +0,0 @@
|
|||
4477-4477.js.license
|
||||
4
dist/files_sharing-files_sharing_tab.js
vendored
4
dist/files_sharing-files_sharing_tab.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files_sharing-files_sharing_tab.js.map
vendored
2
dist/files_sharing-files_sharing_tab.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/files_sharing-init.js
vendored
4
dist/files_sharing-init.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files_sharing-init.js.map
vendored
2
dist/files_sharing-init.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue