Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions apps/files/src/actions/editLocallyAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/files/tests/Controller/ViewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
7 changes: 7 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];