Updated show lease with toggle ttl picker (#11256)

* Updated show lease with toggle ttl picker

For lease renewal, pass increment param instead of interval

* Fixed formatting

* Added changelog
This commit is contained in:
Arnav Palnitkar 2021-04-02 13:23:56 -07:00 committed by GitHub
parent f9ade25674
commit e598f6d5c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 8 deletions

3
changelog/11256.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: Fixed and updated lease renewal picker
```

View File

@ -14,12 +14,12 @@ export default ApplicationAdapter.extend({
return this.ajax(url, 'PUT');
},
renew(lease_id, interval) {
renew(lease_id, increment) {
let url = this.buildURL() + '/leases/renew';
return this.ajax(url, 'PUT', {
data: {
lease_id,
interval,
increment,
},
});
},

View File

@ -24,11 +24,11 @@ export default Controller.extend({
});
},
renewLease(model, interval) {
renewLease(model, increment) {
const adapter = model.store.adapterFor('lease');
const flash = this.flashMessages;
adapter
.renew(model.id, interval)
.renew(model.id, increment?.seconds)
.then(() => {
this.send('refreshModel');
// lol this is terrible, but there's no way to get the promise from the route refresh

View File

@ -52,16 +52,22 @@
{{model.expireTime}}
</code>
</InfoTableRow>
<InfoTableRow @label="Expires in" @value={{date-from-now model.expireTime interval=1000 hideSuffix=true}} />
<InfoTableRow @label="Expires in" @value={{date-from-now model.expireTime increment=1000 hideSuffix=true}} />
{{/if}}
<InfoTableRow @label="TTL" @value={{model.ttl}} />
</div>
{{#if (and (not model.isAuthLease) model.renewable capabilities.renew.canUpdate)}}
<div class="box is-shadowless" data-test-lease-renew-picker=true>
<h2 class="title is-6">Renew Lease</h2>
<form {{action "renewLease" model interval on="submit"}}>
<TtlPicker @labelText="Interval" @labelClass="is-label" @onChange={{action (mut interval)}} @outputSeconds={{true}} />
<div class="field">
<form {{action "renewLease" model increment on="submit"}}>
<TtlPicker2
@label="Increment"
@helperTextEnabled="Lease will expire after"
@helperTextDisabled="Vault will use the default lease duration"
@labelClass="is-label"
@onChange={{action (mut increment)}} @unit="s"
/>
<div class="field has-top-margin-s">
<div class="control">
<button
type="submit"