Skip to content

Commit 9d9d372

Browse files
pboguslawskisusnux
authored andcommitted
feat(files): added parameter to disable web UI integration with local client
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent d1fbf3d commit 9d9d372

4 files changed

Lines changed: 23 additions & 7 deletions

File tree

apps/files/lib/ConfigLexicon.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ConfigLexicon implements ILexicon {
2626
public const GROUP_RECENT_FILES = 'group_recent_files';
2727
public const RECENT_FILES_GROUP_MIME_TYPES = 'recent_files_group_mime_types';
2828
public const RECENT_FILES_GROUP_TIMESPAN_MINUTES = 'recent_files_group_timespan_minutes';
29+
public const LOCAL_CLIENT_INTEGRATION = 'local_client_integration';
2930

3031
#[\Override]
3132
public function getStrictness(): Strictness {
@@ -71,6 +72,13 @@ public function getAppConfigs(): array {
7172
definition: 'Time window in minutes to group files uploaded close together in the recent files list',
7273
lazy: false,
7374
),
75+
new Entry(
76+
self::LOCAL_CLIENT_INTEGRATION,
77+
ValueType::BOOL,
78+
defaultRaw: true,
79+
definition: 'Whether to enable local client integration',
80+
lazy: false,
81+
),
7482
];
7583
}
7684

apps/files/lib/Controller/ViewController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/**
44
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
55
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
6+
* SPDX-FileCopyrightText: 2025 Informatyka Boguslawski sp. z o.o. sp.k.
67
* SPDX-License-Identifier: AGPL-3.0-only
78
*/
89

@@ -205,6 +206,7 @@ public function index($dir = '', $view = '', $fileid = null) {
205206
$this->initialState->provideInitialState('templates_enabled', true);
206207
$this->initialState->provideInitialState('templates_path', $this->templateManager->hasTemplateDirectory() ? $this->templateManager->getTemplatePath() : false);
207208
$this->initialState->provideInitialState('templates', $this->templateManager->listCreators());
209+
$this->initialState->provideInitialState('localClientEnabled', $this->appConfig->getAppValueBool(ConfigLexicon::LOCAL_CLIENT_INTEGRATION));
208210

209211
$isTwoFactorEnabled = false;
210212
foreach ($this->twoFactorRegistry->getProviderStates($user) as $providerId => $providerState) {

apps/files/src/actions/openLocallyAction.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*!
22
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-FileCopyrightText: 2025 Informatyka Boguslawski sp. z o.o. sp.k.
34
* SPDX-License-Identifier: AGPL-3.0-or-later
45
*/
56

@@ -10,13 +11,16 @@ import IconWeb from '@mdi/svg/svg/web.svg?raw'
1011
import { getCurrentUser } from '@nextcloud/auth'
1112
import axios from '@nextcloud/axios'
1213
import { DialogBuilder, showError } from '@nextcloud/dialogs'
14+
import { loadState } from '@nextcloud/initial-state'
1315
import { translate as t } from '@nextcloud/l10n'
1416
import { encodePath } from '@nextcloud/paths'
1517
import { generateOcsUrl } from '@nextcloud/router'
1618
import { isPublicShare } from '@nextcloud/sharing/public'
1719
import { logger } from '../utils/logger.ts'
1820
import { isSyncable } from '../utils/permissions.ts'
1921

22+
const localClientEnabled = loadState('files', 'localClientEnabled', true)
23+
2024
export const action: IFileAction = {
2125
id: 'edit-locally',
2226
displayName: () => t('files', 'Open locally'),
@@ -34,6 +38,10 @@ export const action: IFileAction = {
3438
return false
3539
}
3640

41+
if (!localClientEnabled) {
42+
return false
43+
}
44+
3745
return isSyncable(nodes[0]!)
3846
},
3947

apps/files/tests/Controller/ViewControllerTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,11 @@ public function testTwoFactorAuthEnabled(): void {
307307
'backup_codes' => true,
308308
]);
309309

310-
$invokedCountProvideInitialState = $this->exactly(13);
311-
$this->initialState->expects($invokedCountProvideInitialState)
310+
$initialStates = [];
311+
$this->initialState->expects(self::atLeast(13))
312312
->method('provideInitialState')
313-
->willReturnCallback(function ($key, $data) use ($invokedCountProvideInitialState): void {
314-
if ($invokedCountProvideInitialState->numberOfInvocations() === 13) {
315-
$this->assertEquals('isTwoFactorEnabled', $key);
316-
$this->assertTrue($data);
317-
}
313+
->willReturnCallback(function ($key, $data) use (&$initialStates): void {
314+
$initialStates[$key] = $data;
318315
});
319316

320317
$this->config
@@ -324,5 +321,6 @@ public function testTwoFactorAuthEnabled(): void {
324321
]);
325322

326323
$this->viewController->index('', '', null);
324+
$this->assertTrue($initialStates['isTwoFactorEnabled'] ?? false);
327325
}
328326
}

0 commit comments

Comments
 (0)