From 4a76fdce592836166b1d3234c6af98f5fd2622ba Mon Sep 17 00:00:00 2001 From: Jordan Reimer Date: Fri, 18 Jul 2025 12:09:28 -0600 Subject: [PATCH] updates login settings api vars to snake_case (#31336) --- ui/app/services/api.ts | 6 +++--- .../addon/components/login-settings/page/details.js | 10 +++++----- ui/lib/config-ui/addon/routes/login-settings/index.js | 2 +- ui/tests/unit/services/api-test.js | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ui/app/services/api.ts b/ui/app/services/api.ts index 9c705295df..913c8b1aa1 100644 --- a/ui/app/services/api.ts +++ b/ui/app/services/api.ts @@ -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; keys?: string[] }; - if (!keyInfo || !keys) { + const { key_info, keys } = response as { key_info?: Record; 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 }); } diff --git a/ui/lib/config-ui/addon/components/login-settings/page/details.js b/ui/lib/config-ui/addon/components/login-settings/page/details.js index 7b461f6acf..945ad4298d 100644 --- a/ui/lib/config-ui/addon/components/login-settings/page/details.js +++ b/ui/lib/config-ui/addon/components/login-settings/page/details.js @@ -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 diff --git a/ui/lib/config-ui/addon/routes/login-settings/index.js b/ui/lib/config-ui/addon/routes/login-settings/index.js index 1c9f065804..d3230ed48b 100644 --- a/ui/lib/config-ui/addon/routes/login-settings/index.js +++ b/ui/lib/config-ui/addon/routes/login-settings/index.js @@ -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) { diff --git a/ui/tests/unit/services/api-test.js b/ui/tests/unit/services/api-test.js index 5b9e341f00..59ac9719c6 100644 --- a/ui/tests/unit/services/api-test.js +++ b/ui/tests/unit/services/api-test.js @@ -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' }, },