Skip to content

Commit 64e261d

Browse files
pboguslawskibackportbot[bot]
authored andcommitted
fix: Hide "Create templates folder" option if templates are disabled in configuration
When both `skeletondirectory` and `templatedirectory` are set to empty strings in configuration, templates folder creation should be disabled and no Create templates folder option should be present in new folder menu. Related: #39266 Related: #46455 Author-Change-Id: IB#1156403 Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl> Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent 62a74d8 commit 64e261d

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

apps/files/lib/Controller/ViewController.php

+1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
194194
$this->eventDispatcher->dispatchTyped(new LoadViewer());
195195
}
196196

197+
$this->initialState->provideInitialState('templates_enabled', ($this->config->getSystemValueString('skeletondirectory', '') !== '') || ($this->config->getSystemValueString('templatedirectory', '') !== ''));
197198
$this->initialState->provideInitialState('templates_path', $this->templateManager->hasTemplateDirectory() ? $this->templateManager->getTemplatePath() : false);
198199
$this->initialState->provideInitialState('templates', $this->templateManager->listCreators());
199200

apps/files/src/newMenu/newTemplatesFolder.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import PlusSvg from '@mdi/svg/svg/plus.svg?raw'
1717
import axios from '@nextcloud/axios'
1818
import logger from '../logger.ts'
1919

20+
const templatesEnabled = loadState<boolean>('files', 'templates_enabled', true)
2021
let templatesPath = loadState<string|false>('files', 'templates_path', false)
22+
logger.debug('Templates folder enabled', { templatesEnabled })
2123
logger.debug('Initial templates folder', { templatesPath })
2224

2325
/**
@@ -57,8 +59,8 @@ export const entry = {
5759
iconSvgInline: PlusSvg,
5860
order: 30,
5961
enabled(context: Folder): boolean {
60-
// Templates folder already initialized
61-
if (templatesPath) {
62+
// Templates disabled or templates folder already initialized
63+
if (!templatesEnabled || templatesPath) {
6264
return false
6365
}
6466
// Allow creation on your own folders only

config/config.sample.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,9 @@
288288

289289
/**
290290
* The directory where the skeleton files are located. These files will be
291-
* copied to the data directory of new users. Leave empty to not copy any
292-
* skeleton files.
291+
* copied to the data directory of new users. Set empty string to not copy any
292+
* skeleton files. If unset and templatedirectory is empty string, shipped
293+
* templates will be used to create a template directory for the user.
293294
* ``{lang}`` can be used as a placeholder for the language of the user.
294295
* If the directory does not exist, it falls back to non dialect (from ``de_DE``
295296
* to ``de``). If that does not exist either, it falls back to ``default``
@@ -298,18 +299,16 @@
298299
*/
299300
'skeletondirectory' => '/path/to/nextcloud/core/skeleton',
300301

301-
302302
/**
303303
* The directory where the template files are located. These files will be
304-
* copied to the template directory of new users. Leave empty to not copy any
304+
* copied to the template directory of new users. Set empty string to not copy any
305305
* template files.
306306
* ``{lang}`` can be used as a placeholder for the language of the user.
307307
* If the directory does not exist, it falls back to non dialect (from ``de_DE``
308308
* to ``de``). If that does not exist either, it falls back to ``default``
309309
*
310-
* If this is not set creating a template directory will only happen if no custom
311-
* ``skeletondirectory`` is defined, otherwise the shipped templates will be used
312-
* to create a template directory for the user.
310+
* To disable creating a template directory, set both skeletondirectory and
311+
* templatedirectory to empty strings.
313312
*/
314313
'templatedirectory' => '/path/to/nextcloud/templates',
315314

0 commit comments

Comments
 (0)