diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index ca9ac80b9e28b..27379a0a62f7c 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -278,9 +278,10 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $this->initialState->provideInitialState('templates_path', $this->templateManager->hasTemplateDirectory() ? $this->templateManager->getTemplatePath() : false); $this->initialState->provideInitialState('templates', $this->templateManager->listCreators()); + $this->initialState->provideInitialState('disable_edit_locally', $this->config->getSystemValueBool('disable_edit_locally')); $params = [ - 'fileNotFound' => $fileNotFound ? 1 : 0 + 'fileNotFound' => $fileNotFound ? 1 : 0, ]; $response = new TemplateResponse( diff --git a/apps/files/src/actions/editLocallyAction.ts b/apps/files/src/actions/editLocallyAction.ts index f52f8191df87e..a90fdc17bdae0 100644 --- a/apps/files/src/actions/editLocallyAction.ts +++ b/apps/files/src/actions/editLocallyAction.ts @@ -23,12 +23,15 @@ import { encodePath } from '@nextcloud/paths' import { generateOcsUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' import { FileAction, Permission, type Node } from '@nextcloud/files' +import { loadState } from '@nextcloud/initial-state' import { showError } from '@nextcloud/dialogs' import { translate as t } from '@nextcloud/l10n' import axios from '@nextcloud/axios' import LaptopSvg from '@mdi/svg/svg/laptop.svg?raw' +let disableEditLocally = loadState('files', 'disable_edit_locally', false) + const openLocalClient = async function(path: string) { const link = generateOcsUrl('apps/files/api/v1') + '/openlocaleditor?format=json' @@ -51,6 +54,10 @@ export const action = new FileAction({ // Only works on single files enabled(nodes: Node[]) { + if (disableEditLocally) { + return false + } + // Only works on single node if (nodes.length !== 1) { return false diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index 1f8a609106fc2..460c8367ed205 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -168,7 +168,7 @@ public function testIndexWithRegularBrowser() { [$this->user->getUID(), 'files', 'crop_image_previews', true, true], [$this->user->getUID(), 'files', 'show_grid', true], ]); - + $baseFolderFiles = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->any()) diff --git a/config/config.sample.php b/config/config.sample.php index 39cb0adea9476..62c2b1574f007 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -2412,4 +2412,11 @@ * Defaults to ``true`` */ 'enable_non-accessible_features' => true, + +/** + * Disable "Edit locally" menu item in file viewer + * + * Defaults to ``false`` + */ +'disable_edit_locally' => false, ];