Skip to content

Commit 70955fb

Browse files
authored
Merge pull request #54191 from nextcloud/master-IB#1156402
Added parameter to disable web UI integration with local client
2 parents d1fbf3d + c8c3f58 commit 70955fb

6 files changed

Lines changed: 24 additions & 10 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public function index($dir = '', $view = '', $fileid = null) {
205205
$this->initialState->provideInitialState('templates_enabled', true);
206206
$this->initialState->provideInitialState('templates_path', $this->templateManager->hasTemplateDirectory() ? $this->templateManager->getTemplatePath() : false);
207207
$this->initialState->provideInitialState('templates', $this->templateManager->listCreators());
208+
$this->initialState->provideInitialState('localClientEnabled', $this->appConfig->getAppValueBool(ConfigLexicon::LOCAL_CLIENT_INTEGRATION));
208209

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

apps/files/src/actions/openLocallyAction.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import IconWeb from '@mdi/svg/svg/web.svg?raw'
1010
import { getCurrentUser } from '@nextcloud/auth'
1111
import axios from '@nextcloud/axios'
1212
import { DialogBuilder, showError } from '@nextcloud/dialogs'
13+
import { loadState } from '@nextcloud/initial-state'
1314
import { translate as t } from '@nextcloud/l10n'
1415
import { encodePath } from '@nextcloud/paths'
1516
import { generateOcsUrl } from '@nextcloud/router'
1617
import { isPublicShare } from '@nextcloud/sharing/public'
1718
import { logger } from '../utils/logger.ts'
1819
import { isSyncable } from '../utils/permissions.ts'
1920

21+
const localClientEnabled = loadState('files', 'localClientEnabled', true)
22+
2023
export const action: IFileAction = {
2124
id: 'edit-locally',
2225
displayName: () => t('files', 'Open locally'),
@@ -34,6 +37,10 @@ export const action: IFileAction = {
3437
return false
3538
}
3639

40+
if (!localClientEnabled) {
41+
return false
42+
}
43+
3744
return isSyncable(nodes[0]!)
3845
},
3946

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
}

dist/files-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)