updates login settings api vars to snake_case (#31336)

This commit is contained in:
Jordan Reimer 2025-07-18 12:09:28 -06:00 committed by GitHub
parent 8700becc45
commit 4a76fdce59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 10 deletions

View file

@ -221,13 +221,13 @@ export default class ApiService extends Service {
// accepts a list response as { keyInfo, keys } and returns a flat array of the keyInfo datum
// to preserve the keys (unique identifiers) the value will be set on the datum as id
keyInfoToArray(response: unknown = {}) {
const { keyInfo, keys } = response as { keyInfo?: Record<string, unknown>; keys?: string[] };
if (!keyInfo || !keys) {
const { key_info, keys } = response as { key_info?: Record<string, unknown>; keys?: string[] };
if (!key_info || !keys) {
return [];
}
return keys.reduce(
(arr, key) => {
const datum = keyInfo[key];
const datum = key_info[key];
if (datum) {
arr.push({ id: key, ...datum });
}

View file

@ -31,16 +31,16 @@ export default class LoginSettingsRuleDetails extends Component {
@tracked showConfirmModal = false;
displayFields = {
defaultAuthType: 'Default method',
backupAuthTypes: 'Backup methods',
disableInheritance: 'Inheritance enabled',
namespacePath: 'Namespace the rule applies to',
default_auth_type: 'Default method',
backup_auth_types: 'Backup methods',
disable_inheritance: 'Inheritance enabled',
namespace_path: 'Namespace the rule applies to',
};
displayValue = (key) => {
const value = this.args.rule[key];
// flip boolean for disable inheritance so template reads "Inheritance enabled: Yes/No"
return key === 'disableInheritance' ? !value : value;
return key === 'disable_inheritance' ? !value : value;
};
@action

View file

@ -16,7 +16,7 @@ export default class LoginSettingsRoute extends Route {
const { data } = await adapter.ajax('/v1/sys/config/ui/login/default-auth', 'GET', {
data: { list: true },
});
const loginRules = this.api.keyInfoToArray({ keyInfo: data.key_info, keys: data.keys });
const loginRules = this.api.keyInfoToArray(data);
return { loginRules };
} catch (e) {
if (e.httpStatus === 404) {

View file

@ -195,7 +195,7 @@ module('Unit | Service | api', function (hooks) {
test('it should map list response to array', async function (assert) {
const response = {
keyInfo: {
key_info: {
key1: { title: 'Title 1' },
key2: { title: 'Title 2' },
},