UI: Fix login settings list view if names include an underscore (#31150)

* revert api service use in login settings list view

* add changelog

* update list view

* update error text assertion

* restart tests
This commit is contained in:
claire bontempo 2025-07-01 09:30:04 -07:00 committed by GitHub
parent 571786f425
commit ab830995b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 20 additions and 8 deletions

3
changelog/31150.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: Fixes UI login settings list page which was not rendering rules with an underscore in the name.
```

View File

@ -24,6 +24,7 @@ export default class App extends Application {
'version',
'custom-messages',
'api',
'store',
'capabilities',
],
},

View File

@ -29,9 +29,9 @@
{{rule.name}}
</Hds::Text::Display>
<div class="has-top-margin-m">
{{rule.namespacePath}}
{{rule.namespace_path}}
<Hds::Badge
@text="Inheritance {{if rule.disableInheritance 'disabled' 'enabled'}}"
@text="Inheritance {{if rule.disable_inheritance 'disabled' 'enabled'}}"
class="has-left-margin-xxs"
/>
</div>

View File

@ -25,6 +25,7 @@ export default class ConfigUiEngine extends Engine {
'version',
'custom-messages',
'api',
'store',
'capabilities',
],
};

View File

@ -8,20 +8,23 @@ import { service } from '@ember/service';
export default class LoginSettingsRoute extends Route {
@service api;
@service store;
async model() {
const adapter = this.store.adapterFor('application');
try {
const res = await this.api.sys.uiLoginDefaultAuthList(true);
const loginRules = this.api.keyInfoToArray({ keyInfo: res.keyInfo, keys: res.keys });
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 });
return { loginRules };
} catch (e) {
const error = await this.api.parseError(e);
if (error.status === 404) {
if (e.httpStatus === 404) {
// If no login settings exist, return an empty array to render the empty state
return { loginRules: [] };
}
// Otherwise fallback to the standard error template
throw error;
throw e;
}
}
}

View File

@ -47,7 +47,11 @@ module('Acceptance | Enterprise | config-ui/login-settings', function (hooks) {
test('it falls back error template if no permission', async function (assert) {
this.server.get('/sys/config/ui/login/default-auth', () => overrideResponse(403));
await visit('vault/config-ui/login-settings');
assert.dom(GENERAL.pageError.error).hasText('Error permission denied');
assert
.dom(GENERAL.pageError.error)
.hasText(
'Not authorized You are not authorized to access content at /v1/sys/config/ui/login/default-auth.'
);
});
module('list, read and delete', function (hooks) {