Skip to content

Commit 11eaa04

Browse files
committed
refactor(settings): use ConfigLexicon for user list preferences
Signed-off-by: Peter Ringelmann <[email protected]>
1 parent e7aaaff commit 11eaa04

File tree

5 files changed

+66
-18
lines changed

5 files changed

+66
-18
lines changed

apps/settings/lib/ConfigLexicon.php

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
namespace OCA\Settings;
1010

11-
use OCP\Config\IUserConfig;
1211
use OCP\Config\Lexicon\Entry;
1312
use OCP\Config\Lexicon\ILexicon;
1413
use OCP\Config\Lexicon\Strictness;
@@ -20,7 +19,12 @@
2019
* Please Add & Manage your Config Keys in that file and keep the Lexicon up to date!
2120
*/
2221
class ConfigLexicon implements ILexicon {
23-
public const USER_SETTINGS_EMAIL = 'email';
22+
public const USER_LIST_SHOW_STORAGE_PATH = 'user_list_show_storage_path';
23+
public const USER_LIST_SHOW_USER_BACKEND = 'user_list_show_user_backend';
24+
public const USER_LIST_SHOW_LAST_LOGIN = 'user_list_show_last_login';
25+
public const USER_LIST_SHOW_FIRST_LOGIN = 'user_list_show_first_login';
26+
public const USER_LIST_SHOW_NEW_USER_FORM = 'user_list_show_new_user_form';
27+
public const USER_LIST_SHOW_LANGUAGES = 'user_list_show_languages';
2428

2529
public function getStrictness(): Strictness {
2630
return Strictness::IGNORE;
@@ -32,7 +36,48 @@ public function getAppConfigs(): array {
3236

3337
public function getUserConfigs(): array {
3438
return [
35-
new Entry(key: self::USER_SETTINGS_EMAIL, type: ValueType::STRING, defaultRaw: '', definition: 'account mail address', flags: IUserConfig::FLAG_INDEXED),
39+
new Entry(
40+
key: self::USER_LIST_SHOW_STORAGE_PATH,
41+
type: ValueType::BOOL,
42+
defaultRaw: false,
43+
definition: 'Show storage path column in user list',
44+
lazy: true,
45+
),
46+
new Entry(
47+
key: self::USER_LIST_SHOW_USER_BACKEND,
48+
type: ValueType::BOOL,
49+
defaultRaw: false,
50+
definition: 'Show user account backend column in user list',
51+
lazy: true,
52+
),
53+
new Entry(
54+
key: self::USER_LIST_SHOW_LAST_LOGIN,
55+
type: ValueType::BOOL,
56+
defaultRaw: false,
57+
definition: 'Show last login date column in user list',
58+
lazy: true,
59+
),
60+
new Entry(
61+
key: self::USER_LIST_SHOW_FIRST_LOGIN,
62+
type: ValueType::BOOL,
63+
defaultRaw: false,
64+
definition: 'Show first login date column in user list',
65+
lazy: true,
66+
),
67+
new Entry(
68+
key: self::USER_LIST_SHOW_NEW_USER_FORM,
69+
type: ValueType::BOOL,
70+
defaultRaw: false,
71+
definition: 'Show new user form in user list',
72+
lazy: true,
73+
),
74+
new Entry(
75+
key: self::USER_LIST_SHOW_LANGUAGES,
76+
type: ValueType::BOOL,
77+
defaultRaw: false,
78+
definition: 'Show languages in user list',
79+
lazy: true,
80+
),
3681
];
3782
}
3883
}

apps/settings/lib/Controller/UsersController.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use OC\Security\IdentityProof\Manager;
2020
use OC\User\Manager as UserManager;
2121
use OCA\Settings\BackgroundJobs\VerifyUserData;
22+
use OCA\Settings\ConfigLexicon;
2223
use OCA\Settings\Events\BeforeTemplateRenderedEvent;
2324
use OCA\Settings\Settings\Admin\Users;
2425
use OCA\User_LDAP\User_Proxy;
@@ -62,12 +63,12 @@ class UsersController extends Controller {
6263
private const COUNT_LIMIT_FOR_SUBADMINS = 999;
6364

6465
public const ALLOWED_USER_PREFERENCES = [
65-
'user_list_show_storage_path',
66-
'user_list_show_user_backend',
67-
'user_list_show_first_login',
68-
'user_list_show_last_login',
69-
'user_list_show_new_user_form',
70-
'user_list_show_languages',
66+
ConfigLexicon::USER_LIST_SHOW_STORAGE_PATH,
67+
ConfigLexicon::USER_LIST_SHOW_USER_BACKEND,
68+
ConfigLexicon::USER_LIST_SHOW_FIRST_LOGIN,
69+
ConfigLexicon::USER_LIST_SHOW_LAST_LOGIN,
70+
ConfigLexicon::USER_LIST_SHOW_NEW_USER_FORM,
71+
ConfigLexicon::USER_LIST_SHOW_LANGUAGES,
7172
];
7273

7374
public function __construct(

apps/settings/tests/Controller/UsersControllerTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OC\Group\Manager;
1515
use OC\KnownUser\KnownUserService;
1616
use OC\User\Manager as UserManager;
17+
use OCA\Settings\ConfigLexicon;
1718
use OCA\Settings\Controller\UsersController;
1819
use OCP\Accounts\IAccount;
1920
use OCP\Accounts\IAccountManager;
@@ -1043,13 +1044,14 @@ public function testSetPreference(string $key, string $value, bool $isUserValue,
10431044
public static function dataSetPreference(): array {
10441045
return [
10451046
['newUser.sendEmail', 'yes', false, true, Http::STATUS_OK],
1047+
['newUser.sendEmail', 'no', false, true, Http::STATUS_OK],
10461048
['group.sortBy', '1', false, true, Http::STATUS_OK],
1047-
['user_list_show_storage_path', 'true', true, false, Http::STATUS_OK],
1048-
['user_list_show_user_backend', 'false', true, false, Http::STATUS_OK],
1049-
['user_list_show_first_login', 'true', true, false, Http::STATUS_OK],
1050-
['user_list_show_last_login', 'true', true, false, Http::STATUS_OK],
1051-
['user_list_show_new_user_form', 'true', true, false, Http::STATUS_OK],
1052-
['user_list_show_languages', 'true', true, false, Http::STATUS_OK],
1049+
[ConfigLexicon::USER_LIST_SHOW_STORAGE_PATH, 'true', true, false, Http::STATUS_OK],
1050+
[ConfigLexicon::USER_LIST_SHOW_USER_BACKEND, 'false', true, false, Http::STATUS_OK],
1051+
[ConfigLexicon::USER_LIST_SHOW_FIRST_LOGIN, 'true', true, false, Http::STATUS_OK],
1052+
[ConfigLexicon::USER_LIST_SHOW_LAST_LOGIN, 'true', true, false, Http::STATUS_OK],
1053+
[ConfigLexicon::USER_LIST_SHOW_NEW_USER_FORM, 'true', true, false, Http::STATUS_OK],
1054+
[ConfigLexicon::USER_LIST_SHOW_LANGUAGES, 'true', true, false, Http::STATUS_OK],
10531055
['invalidKey', 'value', false, false, Http::STATUS_FORBIDDEN],
10541056
];
10551057
}

dist/settings-vue-settings-apps-users-management.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-apps-users-management.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)