Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 1.9.x: Form field component ttl picker not initially enabling (#13177) #13220

Merged
merged 2 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/13177.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixes issue with automate secret deletion value not displaying initially if set in secret metadata edit view
```
19 changes: 11 additions & 8 deletions ui/lib/core/addon/templates/components/form-field.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,17 @@
{{else if (eq attr.options.editType "ttl")}}
{{!-- TTL Picker --}}
<div class="field">
<TtlPicker2
@onChange={{action (action "setAndBroadcastTtl" valuePath)}}
@label={{labelString}}
@helperTextDisabled={{or attr.options.helperTextDisabled "Vault will use the default lease duration."}}
@helperTextEnabled={{or attr.options.helperTextEnabled "Lease will expire after"}}
@description={{attr.helpText}}
@initialValue={{or (get model valuePath) attr.options.setDefault}}
/>
{{#let (or (get model valuePath) attr.options.setDefault) as |initialValue|}}
<TtlPicker2
@onChange={{action (action "setAndBroadcastTtl" valuePath)}}
@label={{labelString}}
@helperTextDisabled={{or attr.options.helperTextDisabled "Vault will use the default lease duration."}}
@helperTextEnabled={{or attr.options.helperTextEnabled "Lease will expire after"}}
@description={{attr.helpText}}
@initialValue={{initialValue}}
@initialEnabled={{if (eq initialValue "0s") false initialValue}}
/>
{{/let}}
</div>
{{else if (eq attr.options.editType "regex")}}
{{!-- Regex Validated Input --}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module('Acceptance | settings/configure/secrets/pki/crl', function(hooks) {
await page.visit({ backend: path, section: 'crl' });
await settled();
assert.equal(currentRouteName(), 'vault.cluster.settings.configure-secret-backend.section');
await page.form.enableTtl();
await page.form.fillInUnit('h');
await page.form.fillInValue(3);
await page.form.submit();
Expand Down
30 changes: 30 additions & 0 deletions ui/tests/integration/components/form-field-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,34 @@ module('Integration | Component | form field', function(hooks) {
await component.tooltipTrigger();
assert.ok(component.hasTooltip, 'renders the tooltip component');
});

test('it should not expand and toggle ttl when default 0s value is present', async function(assert) {
assert.expect(2);

this.setProperties({
model: EmberObject.create({ foo: '0s' }),
attr: createAttr('foo', null, { editType: 'ttl' }),
onChange: () => {},
});

await render(hbs`{{form-field attr=attr model=model onChange=onChange}}`);
assert
.dom('[data-test-toggle-input="Foo"]')
.isNotChecked('Toggle is initially unchecked when given default value');
assert.dom('[data-test-ttl-picker-group="Foo"]').doesNotExist('Ttl input is hidden');
});

test('it should toggle and expand ttl when initial non default value is provided', async function(assert) {
assert.expect(2);

this.setProperties({
model: EmberObject.create({ foo: '1s' }),
attr: createAttr('foo', null, { editType: 'ttl' }),
onChange: () => {},
});

await render(hbs`{{form-field attr=attr model=model onChange=onChange}}`);
assert.dom('[data-test-toggle-input="Foo"]').isChecked('Toggle is initially checked when given value');
assert.dom('[data-test-ttl-value="Foo"]').hasValue('1', 'Ttl input displays with correct value');
});
});