Skip to content

Commit 9b513c1

Browse files
committed
refactor(settings): rename user preference keys to snake_case
Signed-off-by: Peter Ringelmann <[email protected]>
1 parent 00002fc commit 9b513c1

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

apps/settings/lib/Controller/UsersController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ class UsersController extends Controller {
5959
/** Limit for counting users for subadmins, to avoid spending too much time */
6060
private const COUNT_LIMIT_FOR_SUBADMINS = 999;
6161

62-
private const ALLOWED_USER_PREFERENCES = [
63-
'userList.showStoragePath',
64-
'userList.showUserBackend',
65-
'userList.showFirstLogin',
66-
'userList.showLastLogin',
67-
'userList.showNewUserForm',
68-
'userList.showLanguages',
62+
public const ALLOWED_USER_PREFERENCES = [
63+
'user_list_show_storage_path',
64+
'user_list_show_user_backend',
65+
'user_list_show_first_login',
66+
'user_list_show_last_login',
67+
'user_list_show_new_user_form',
68+
'user_list_show_languages',
6969
];
7070

7171
public function __construct(

apps/settings/src/store/users.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ const state = {
4444
disabledUsersLimit: 25,
4545
userCount: usersSettings.userCount ?? 0,
4646
showConfig: {
47-
showStoragePath: usersSettings.showConfig['userList.showStoragePath'],
48-
showUserBackend: usersSettings.showConfig['userList.showUserBackend'],
49-
showFirstLogin: usersSettings.showConfig['userList.showFirstLogin'],
50-
showLastLogin: usersSettings.showConfig['userList.showLastLogin'],
51-
showNewUserForm: usersSettings.showConfig['userList.showNewUserForm'],
52-
showLanguages: usersSettings.showConfig['userList.showLanguages'],
47+
showStoragePath: usersSettings.showConfig.user_list_show_storage_path,
48+
showUserBackend: usersSettings.showConfig.user_list_show_user_backend,
49+
showFirstLogin: usersSettings.showConfig.user_list_show_first_login,
50+
showLastLogin: usersSettings.showConfig.user_list_show_last_login,
51+
showNewUserForm: usersSettings.showConfig.user_list_show_new_user_form,
52+
showLanguages: usersSettings.showConfig.user_list_show_languages,
5353
},
5454
}
5555

@@ -807,7 +807,15 @@ const actions = {
807807
*/
808808
setShowConfig(context, { key, value }) {
809809
context.commit('setShowConfig', { key, value })
810-
axios.post(generateUrl(`settings/users/preferences/userList.${key}`), { value: value ? 'true' : 'false' })
810+
const keyMap = {
811+
showStoragePath: 'user_list_show_storage_path',
812+
showUserBackend: 'user_list_show_user_backend',
813+
showFirstLogin: 'user_list_show_first_login',
814+
showLastLogin: 'user_list_show_last_login',
815+
showNewUserForm: 'user_list_show_new_user_form',
816+
showLanguages: 'user_list_show_languages',
817+
}
818+
axios.post(generateUrl(`settings/users/preferences/${keyMap[key]}`), { value: value ? 'true' : 'false' })
811819
.catch((error) => logger.error(`Could not update ${key} preference`, { error }))
812820
},
813821
}

apps/settings/tests/Controller/UsersControllerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,12 +1024,12 @@ public static function dataSetPreference(): array {
10241024
return [
10251025
['newUser.sendEmail', 'yes', false, true, Http::STATUS_OK],
10261026
['group.sortBy', '1', false, true, Http::STATUS_OK],
1027-
['userList.showStoragePath', 'true', true, false, Http::STATUS_OK],
1028-
['userList.showUserBackend', 'false', true, false, Http::STATUS_OK],
1029-
['userList.showFirstLogin', 'true', true, false, Http::STATUS_OK],
1030-
['userList.showLastLogin', 'true', true, false, Http::STATUS_OK],
1031-
['userList.showNewUserForm', 'true', true, false, Http::STATUS_OK],
1032-
['userList.showLanguages', 'true', true, false, Http::STATUS_OK],
1027+
['user_list_show_storage_path', 'true', true, false, Http::STATUS_OK],
1028+
['user_list_show_user_backend', 'false', true, false, Http::STATUS_OK],
1029+
['user_list_show_first_login', 'true', true, false, Http::STATUS_OK],
1030+
['user_list_show_last_login', 'true', true, false, Http::STATUS_OK],
1031+
['user_list_show_new_user_form', 'true', true, false, Http::STATUS_OK],
1032+
['user_list_show_languages', 'true', true, false, Http::STATUS_OK],
10331033
['invalidKey', 'value', false, false, Http::STATUS_FORBIDDEN],
10341034
];
10351035
}

0 commit comments

Comments
 (0)