Skip to content

Commit

Permalink
Added option to disable EditLocally menu option
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Myakshin <[email protected]>
  • Loading branch information
Koc committed Nov 20, 2023
1 parent 4bc45a7 commit 8fb985e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
$this->initialState->provideInitialState('templates', $this->templateManager->listCreators());

$params = [
'fileNotFound' => $fileNotFound ? 1 : 0
'fileNotFound' => $fileNotFound ? 1 : 0,
'disableEditLocally' => $this->config->getSystemValueString('disable_edit_locally', '0'),
];

$response = new TemplateResponse(
Expand Down
4 changes: 4 additions & 0 deletions apps/files/src/actions/editLocallyAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export const action = new FileAction({

// Only works on single files
enabled(nodes: Node[]) {
if ($('#disableEditLocally').val() === "1") {
return false
}

// Only works on single node
if (nodes.length !== 1) {
return false
Expand Down
1 change: 1 addition & 0 deletions apps/files/templates/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
<!-- config hints for javascript -->
<input type="hidden" name="filesApp" id="filesApp" value="1" />
<input type="hidden" name="fileNotFound" id="fileNotFound" value="<?php p($_['fileNotFound']); ?>" />
<input type="hidden" name="disableEditLocally" id="disableEditLocally" value="<?php p($_['disableEditLocally']); ?>" />
3 changes: 2 additions & 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 All @@ -186,6 +186,7 @@ public function testIndexWithRegularBrowser() {
'index',
[
'fileNotFound' => 0,
'disableEditLocally' => '',
]
);
$policy = new Http\ContentSecurityPolicy();
Expand Down

0 comments on commit 8fb985e

Please sign in to comment.