Skip to content

Commit 8598f8b

Browse files
authored
Merge pull request #58908 from nextcloud/feat/1701/recent-files-img-grouping
feat(recent-files): allow configuring image grouping
2 parents 3f72e33 + 8f2cfe5 commit 8598f8b

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

apps/files/lib/ConfigLexicon.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
class ConfigLexicon implements ILexicon {
2424
public const OVERWRITES_HOME_FOLDERS = 'overwrites_home_folders';
2525
public const RECENT_LIMIT = 'recent_limit';
26+
public const GROUP_RECENT_FILES = 'group_recent_files';
27+
public const RECENT_FILES_GROUP_MIME_TYPES = 'recent_files_group_mime_types';
28+
public const RECENT_FILES_GROUP_TIMESPAN_MINUTES = 'recent_files_group_timespan_minutes';
2629

2730
public function getStrictness(): Strictness {
2831
return Strictness::IGNORE;
@@ -45,6 +48,27 @@ public function getAppConfigs(): array {
4548
definition: 'Maximum number of files to display on recent files view',
4649
lazy: false,
4750
),
51+
new Entry(
52+
self::GROUP_RECENT_FILES,
53+
ValueType::BOOL,
54+
defaultRaw: false,
55+
definition: 'Whether to group recent files by MIME type or not',
56+
lazy: false,
57+
),
58+
new Entry(
59+
self::RECENT_FILES_GROUP_MIME_TYPES,
60+
ValueType::ARRAY,
61+
defaultRaw: [],
62+
definition: 'Which MIME types to group in the recent files list',
63+
lazy: false,
64+
),
65+
new Entry(
66+
self::RECENT_FILES_GROUP_TIMESPAN_MINUTES,
67+
ValueType::INT,
68+
defaultRaw: 2,
69+
definition: 'Time window in minutes to group files uploaded close together in the recent files list',
70+
lazy: false,
71+
),
4872
];
4973
}
5074

apps/files/lib/Controller/ViewController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ public function index($dir = '', $view = '', $fileid = null) {
178178
$this->initialState->provideInitialState('config', $this->userConfig->getConfigs());
179179
$this->initialState->provideInitialState('viewConfigs', $this->viewConfig->getConfigs());
180180
$this->initialState->provideInitialState('recent_limit', $this->appConfig->getAppValueInt(ConfigLexicon::RECENT_LIMIT, 100));
181+
// Not yet consumed by the frontend, provided for future implementation
182+
$this->initialState->provideInitialState('group_recent_files', $this->appConfig->getAppValueBool(ConfigLexicon::GROUP_RECENT_FILES, false));
183+
$this->initialState->provideInitialState('recent_files_group_mime_types', $this->appConfig->getAppValueArray(ConfigLexicon::RECENT_FILES_GROUP_MIME_TYPES, []));
184+
$this->initialState->provideInitialState('recent_files_group_timespan_minutes', $this->appConfig->getAppValueInt(ConfigLexicon::RECENT_FILES_GROUP_TIMESPAN_MINUTES, 2));
181185

182186
// File sorting user config
183187
$filesSortingConfig = json_decode($this->config->getUserValue($userId, 'files', 'files_sorting_configs', '{}'), true);

apps/files/tests/Controller/ViewControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@ public function testTwoFactorAuthEnabled(): void {
302302
'backup_codes' => true,
303303
]);
304304

305-
$invokedCountProvideInitialState = $this->exactly(10);
305+
$invokedCountProvideInitialState = $this->exactly(13);
306306
$this->initialState->expects($invokedCountProvideInitialState)
307307
->method('provideInitialState')
308308
->willReturnCallback(function ($key, $data) use ($invokedCountProvideInitialState): void {
309-
if ($invokedCountProvideInitialState->numberOfInvocations() === 10) {
309+
if ($invokedCountProvideInitialState->numberOfInvocations() === 13) {
310310
$this->assertEquals('isTwoFactorEnabled', $key);
311311
$this->assertTrue($data);
312312
}

0 commit comments

Comments
 (0)