-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update cluster status partial to component (#11680)
* Update cluster status partial to component * Added changelog * Close menu when link is clicked * Upgraded to glimmer components * Fixed indentations Added back activeCluster Updated changelog
- Loading branch information
Showing
8 changed files
with
128 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
ui: Update partials to components | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,54 @@ | ||
import Component from '@glimmer/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { or, alias } from '@ember/object/computed'; | ||
import Component from '@ember/component'; | ||
import { run } from '@ember/runloop'; | ||
|
||
export default Component.extend({ | ||
auth: service(), | ||
wizard: service(), | ||
router: service(), | ||
version: service(), | ||
|
||
transitionToRoute: function() { | ||
import { action } from '@ember/object'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
/** | ||
* @module AuthInfo | ||
* | ||
* @example | ||
* ```js | ||
* <AuthInfo @activeClusterName={{cluster.name}} @onLinkClick={{action "onLinkClick"}} /> | ||
* ``` | ||
* | ||
* @param {string} activeClusterName - name of the current cluster, passed from the parent. | ||
* @param {Function} onLinkClick - parent action which determines the behavior on link click | ||
*/ | ||
export default class AuthInfoComponent extends Component { | ||
@service auth; | ||
@service wizard; | ||
@service router; | ||
|
||
@tracked | ||
fakeRenew = false; | ||
|
||
get isRenewing() { | ||
return this.fakeRenew || this.auth.isRenewing; | ||
} | ||
|
||
transitionToRoute() { | ||
this.router.transitionTo(...arguments); | ||
}, | ||
|
||
classNames: 'user-menu auth-info', | ||
|
||
isRenewing: or('fakeRenew', 'auth.isRenewing'), | ||
|
||
canExpire: alias('auth.allowExpiration'), | ||
|
||
isOSS: alias('version.isOSS'), | ||
|
||
actions: { | ||
restartGuide() { | ||
this.wizard.restartGuide(); | ||
}, | ||
renewToken() { | ||
this.set('fakeRenew', true); | ||
run.later(() => { | ||
this.set('fakeRenew', false); | ||
this.auth.renew(); | ||
}, 200); | ||
}, | ||
|
||
revokeToken() { | ||
this.auth.revokeCurrentToken().then(() => { | ||
this.transitionToRoute('vault.cluster.logout'); | ||
}); | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
@action | ||
restartGuide() { | ||
this.wizard.restartGuide(); | ||
} | ||
|
||
@action | ||
renewToken() { | ||
this.fakeRenew = true; | ||
run.later(() => { | ||
this.fakeRenew = false; | ||
this.auth.renew(); | ||
}, 200); | ||
} | ||
|
||
@action | ||
revokeToken() { | ||
this.auth.revokeCurrentToken().then(() => { | ||
this.transitionToRoute('vault.cluster.logout'); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
|
||
/** | ||
* @module ClusterInfo | ||
* | ||
* @example | ||
* ```js | ||
* <ClusterInfo @cluster={{cluster}} @onLinkClick={{action}} /> | ||
* ``` | ||
* | ||
* @param {object} cluster - details of the current cluster, passed from the parent. | ||
* @param {Function} onLinkClick - parent action which determines the behavior on link click | ||
*/ | ||
export default class ClusterInfoComponent extends Component { | ||
@service auth; | ||
@service store; | ||
@service version; | ||
|
||
get activeCluster() { | ||
return this.store.peekRecord('cluster', this.auth.activeCluster); | ||
} | ||
|
||
transitionToRoute() { | ||
this.router.transitionTo(...arguments); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,20 @@ | ||
import { inject as service } from '@ember/service'; | ||
import { alias, reads } from '@ember/object/computed'; | ||
import { alias } from '@ember/object/computed'; | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
|
||
export default Component.extend({ | ||
currentCluster: service('current-cluster'), | ||
cluster: alias('currentCluster.cluster'), | ||
auth: service(), | ||
store: service(), | ||
media: service(), | ||
version: service(), | ||
type: 'cluster', | ||
itemTag: null, | ||
partialName: computed('type', function() { | ||
return `partials/status/${this.type}`; | ||
}), | ||
glyphName: computed('type', function() { | ||
const glyphs = { | ||
cluster: 'status-indicator', | ||
user: 'user-square-outline', | ||
}; | ||
return glyphs[this.type]; | ||
}), | ||
activeCluster: computed('auth.activeCluster', function() { | ||
return this.store.peekRecord('cluster', this.auth.activeCluster); | ||
}), | ||
currentToken: reads('auth.currentToken'), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.