Skip to content

Commit

Permalink
UI: Move OIDC key header out of form component (#27848)
Browse files Browse the repository at this point in the history
* move pageheader to route template

* remove title assertions because no longer reliant on isNew logic

* change @model to this.model

* remove test selectors

* add keys base breadcrumb

* update assertion count
  • Loading branch information
hellobontempo authored Jul 23, 2024
1 parent b32231a commit 08b5d87
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
19 changes: 0 additions & 19 deletions ui/app/templates/components/oidc/key-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,6 @@
SPDX-License-Identifier: BUSL-1.1
~}}

<PageHeader as |p|>
<p.top>
<Hds::Breadcrumb>
{{#if @model.isNew}}
<Hds::Breadcrumb::Item @text="Keys" @route="vault.cluster.access.oidc.keys" />
{{else}}
<Hds::Breadcrumb::Item @text="Details" @route="vault.cluster.access.oidc.keys.key.details" @model={{@model.name}} />
{{/if}}
<Hds::Breadcrumb::Item @text="{{if @model.isNew 'Create' 'Edit'}} Key" @current={{true}} />
</Hds::Breadcrumb>
</p.top>
<p.levelLeft>
<h1 class="title is-3" data-test-oidc-key-title>
{{if @model.isNew "Create" "Edit"}}
Key
</h1>
</p.levelLeft>
</PageHeader>

<form {{on "submit" (perform this.save)}}>
<div class="box is-sideless is-fullwidth is-bottomless">
<MessageError @errorMessage={{this.errorBanner}} />
Expand Down
14 changes: 14 additions & 0 deletions ui/app/templates/vault/cluster/access/oidc/keys/create.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
SPDX-License-Identifier: BUSL-1.1
~}}

<PageHeader as |p|>
<p.top>
<Hds::Breadcrumb>
<Hds::Breadcrumb::Item @text="Keys" @route="vault.cluster.access.oidc.keys" />
<Hds::Breadcrumb::Item @text="Create Key" @current={{true}} />
</Hds::Breadcrumb>
</p.top>
<p.levelLeft>
<h1 class="title is-3">
Create Key
</h1>
</p.levelLeft>
</PageHeader>

<Oidc::KeyForm
@model={{this.model}}
@onCancel={{transition-to "vault.cluster.access.oidc.keys"}}
Expand Down
19 changes: 19 additions & 0 deletions ui/app/templates/vault/cluster/access/oidc/keys/key/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
SPDX-License-Identifier: BUSL-1.1
~}}

<PageHeader as |p|>
<p.top>
<Hds::Breadcrumb>
<Hds::Breadcrumb::Item @text="Keys" @route="vault.cluster.access.oidc.keys" />
<Hds::Breadcrumb::Item
@text="Details"
@route="vault.cluster.access.oidc.keys.key.details"
@model={{this.model.name}}
/>
<Hds::Breadcrumb::Item @text="Edit Key" @current={{true}} />
</Hds::Breadcrumb>
</p.top>
<p.levelLeft>
<h1 class="title is-3">
Edit Key
</h1>
</p.levelLeft>
</PageHeader>

<Oidc::KeyForm
@model={{this.model}}
@onCancel={{transition-to "vault.cluster.access.oidc.keys.key.details" this.model.name}}
Expand Down
6 changes: 2 additions & 4 deletions ui/tests/integration/components/oidc/key-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module('Integration | Component | oidc/key-form', function (hooks) {
});

test('it should save new key', async function (assert) {
assert.expect(9);
assert.expect(8);
this.server.post('/identity/oidc/key/test-key', (schema, req) => {
assert.ok(true, 'Request made to save key');
return JSON.parse(req.requestBody);
Expand All @@ -49,7 +49,6 @@ module('Integration | Component | oidc/key-form', function (hooks) {
/>
`);

assert.dom('[data-test-oidc-key-title]').hasText('Create Key', 'Form title renders correct text');
assert.dom(SELECTORS.keySaveButton).hasText('Create', 'Save button has correct text');
assert.dom('[data-test-input="algorithm"]').hasValue('RS256', 'default algorithm is correct');
assert.strictEqual(findAll('[data-test-field]').length, 4, 'renders all input fields');
Expand All @@ -70,7 +69,7 @@ module('Integration | Component | oidc/key-form', function (hooks) {
});

test('it should update key and limit access to selected applications', async function (assert) {
assert.expect(12);
assert.expect(11);

this.server.post('/identity/oidc/key/test-key', (schema, req) => {
assert.ok(true, 'Request made to update key');
Expand All @@ -94,7 +93,6 @@ module('Integration | Component | oidc/key-form', function (hooks) {
/>
`);

assert.dom('[data-test-oidc-key-title]').hasText('Edit Key', 'Title renders correct text');
assert.dom(SELECTORS.keySaveButton).hasText('Update', 'Save button has correct text');
assert.dom('[data-test-input="name"]').isDisabled('Name input is disabled when editing');
assert.dom('[data-test-input="name"]').hasValue('test-key', 'Name input is populated with model value');
Expand Down

0 comments on commit 08b5d87

Please sign in to comment.