feat(files): Allow toggling folder tree

Signed-off-by: Christopher Ng <chrng8@gmail.com>
pull/46596/head
Christopher Ng 2024-07-30 18:19:55 +07:00
parent 5812a3422f
commit 0def7fa71c
3 changed files with 18 additions and 1 deletions

@ -42,6 +42,12 @@ class UserConfig {
'default' => false,
'allowed' => [true, false],
],
[
// Whether to show the folder tree
'key' => 'folder_tree',
'default' => true,
'allowed' => [true, false],
],
];
protected IConfig $config;
@ -108,7 +114,7 @@ class UserConfig {
if (!in_array($key, $this->getAllowedConfigKeys())) {
throw new \InvalidArgumentException('Unknown config key');
}
if (!in_array($value, $this->getAllowedConfigValues($key))) {
throw new \InvalidArgumentException('Invalid config value');
}

@ -35,6 +35,11 @@
@update:checked="setConfig('grid_view', $event)">
{{ t('files', 'Enable the grid view') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch data-cy-files-settings-setting="folder_tree"
:checked="userConfig.folder_tree"
@update:checked="setConfig('folder_tree', $event)">
{{ t('files', 'Enable folder tree') }}
</NcCheckboxRadioSwitch>
</NcAppSettingsSection>
<!-- Settings API-->

@ -9,6 +9,7 @@ import { Folder, Node, View, getNavigation } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import { subscribe } from '@nextcloud/event-bus'
import { isSamePath } from '@nextcloud/paths'
import { loadState } from '@nextcloud/initial-state'
import FolderSvg from '@mdi/svg/svg/folder.svg?raw'
import FolderMultipleSvg from '@mdi/svg/svg/folder-multiple.svg?raw'
@ -24,6 +25,8 @@ import {
sourceRoot,
} from '../services/FolderTree.ts'
const isFolderTreeEnabled = loadState('files', 'config', { folder_tree: true }).folder_tree
const Navigation = getNavigation()
const registerTreeNodeView = (node: TreeNode) => {
@ -142,6 +145,9 @@ const registerFolderTreeChildren = async () => {
}
export const registerFolderTreeView = async () => {
if (!isFolderTreeEnabled) {
return
}
registerFolderTreeRoot()
await registerFolderTreeChildren()
}