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 <molodchick@gmail.com>
  • Loading branch information
Koc committed Nov 17, 2023
1 parent 4fa2749 commit a683aeb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
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),

Check failure on line 284 in apps/files/lib/Controller/ViewController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidScalarArgument

apps/files/lib/Controller/ViewController.php:284:88: InvalidScalarArgument: Argument 2 of OCP\IConfig::getSystemValueString expects string, but 0 provided (see https://psalm.dev/012)

Check failure

Code scanning / Psalm

InvalidScalarArgument Error

Argument 2 of OCP\IConfig::getSystemValueString expects string, but 0 provided
];

$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']); ?>" />

0 comments on commit a683aeb

Please sign in to comment.