Skip to content

Commit

Permalink
fix(ui): return an empty fragment from rendering when the user/cluste…
Browse files Browse the repository at this point in the history
…r isn't known (#462)

* Return an empty fragment from rendering when the user/cluster isn't known
* Remove the unused `callback` argument to `getCurrentUser`
  • Loading branch information
ankon authored Oct 21, 2020
1 parent c89c0b7 commit 3ebfd4b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/src/utils/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Routes extends Root {
});
};

getCurrentUser(callback = () => {}) {
getCurrentUser() {
sessionStorage.setItem('user', '');
this.getApi(uriCurrentUser())
.then(res => {
Expand All @@ -83,7 +83,6 @@ class Routes extends Root {
}
}
this.setState({ loading: false });
callback();
})
.catch(err => {
console.error('Error:', err);
Expand Down Expand Up @@ -111,13 +110,15 @@ class Routes extends Root {

if (this.state.user.length <= 0) {
this.getCurrentUser();
return <></>;
}

if (
(clusterId.length <= 0 || clusterId === '401') &&
(sessionStorage.getItem('login') === 'true' || this.state.user === 'default')
) {
this.getClusters();
return <></>;
}

if (!clusters.find(el => el.id === this.state.clusterId) && clusterId !== '401') {
Expand Down

0 comments on commit 3ebfd4b

Please sign in to comment.