Skip to content

Commit

Permalink
UI/Remove spinner after token renew (hashicorp#12887)
Browse files Browse the repository at this point in the history
* fixes loading spinner

* adds changelog
  • Loading branch information
hellobontempo authored and Artem Alexandrov committed Feb 4, 2022
1 parent 18c7059 commit d77e30a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog/12887.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Remove spinner after token renew
```
5 changes: 3 additions & 2 deletions ui/app/components/auth-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export default class AuthInfoComponent extends Component {
renewToken() {
this.fakeRenew = true;
run.later(() => {
this.fakeRenew = false;
this.auth.renew();
this.auth.renew().then(() => {
this.fakeRenew = this.auth.isRenewing;
});
}, 200);
}

Expand Down
7 changes: 4 additions & 3 deletions ui/app/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default Service.extend({
namespaceService: service('namespace'),
IDLE_TIMEOUT: 3 * 60e3,
expirationCalcTS: null,
isRenewing: false,
init() {
this._super(...arguments);
this.checkForRootToken();
Expand Down Expand Up @@ -249,14 +250,14 @@ export default Service.extend({
if (currentlyRenewing) {
return;
}
this.set('isRenewing', true);
this.isRenewing = true;
return this.renewCurrentToken().then(
resp => {
this.set('isRenewing', false);
this.isRenewing = false;
return this.persistAuthData(tokenName, resp.data || resp.auth);
},
e => {
this.set('isRenewing', false);
this.isRenewing = false;
throw e;
}
);
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/auth-info.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{{#if (is-before (now interval=1000) this.auth.tokenExpirationDate)}}
{{#if this.auth.authData.renewable}}
<li class="action">
<button type="button" {{action "renewToken"}} class="link button {{if this.isRenewing 'is-loading'}}">
<button type="button" {{on "click" this.renewToken}} class="link button {{if this.isRenewing 'is-loading'}}">
Renew token
</button>
</li>
Expand Down

0 comments on commit d77e30a

Please sign in to comment.