mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
Merge pull request #54369 from nextcloud/backport/54310/stable31
[stable31] fix(files_sharing): Implement conditional federation placeholder
This commit is contained in:
commit
c1a6a3b4ce
15 changed files with 52 additions and 25 deletions
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
namespace OCA\Files_Sharing;
|
||||
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\Capabilities\ICapability;
|
||||
use OCP\Constants;
|
||||
use OCP\IConfig;
|
||||
|
|
@ -17,10 +18,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,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -157,14 +158,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->isInstalled('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'] = [
|
||||
|
|
|
|||
|
|
@ -212,6 +212,13 @@ export default class Config {
|
|||
return window.OC.appConfig.core.remoteShareAllowed === true
|
||||
}
|
||||
|
||||
/**
|
||||
* Is federation enabled ?
|
||||
*/
|
||||
get isFederationEnabled(): boolean {
|
||||
return this._capabilities?.files_sharing?.federation?.outgoing === true
|
||||
}
|
||||
|
||||
/**
|
||||
* Is public sharing enabled ?
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -272,14 +272,13 @@ export default {
|
|||
|
||||
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
|
||||
|
|
@ -291,7 +290,6 @@ export default {
|
|||
this.resetState()
|
||||
this.getShares()
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the existing shares infos
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -10,6 +10,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;
|
||||
|
|
@ -54,9 +55,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('isInstalled')->with('federation')->willReturn($federationEnabled);
|
||||
$shareManager = new Manager(
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$config,
|
||||
|
|
@ -78,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;
|
||||
}
|
||||
|
|
@ -322,4 +325,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']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
dist/3265-3265.js
vendored
Normal file
2
dist/3265-3265.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/3265-3265.js.map
vendored
Normal file
1
dist/3265-3265.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/3265-3265.js.map.license
vendored
Symbolic link
1
dist/3265-3265.js.map.license
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
3265-3265.js.license
|
||||
2
dist/8723-8723.js
vendored
2
dist/8723-8723.js
vendored
File diff suppressed because one or more lines are too long
1
dist/8723-8723.js.map
vendored
1
dist/8723-8723.js.map
vendored
File diff suppressed because one or more lines are too long
1
dist/8723-8723.js.map.license
vendored
1
dist/8723-8723.js.map.license
vendored
|
|
@ -1 +0,0 @@
|
|||
8723-8723.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