-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[ui] Show ALL regions' leaders when viewing servers route #24723
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
ui: add leadership status for servers in other regions | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,6 @@ import classic from 'ember-classic-decorator'; | |
@classic | ||
export default class ClientsRoute extends Route.extend(WithForbiddenState) { | ||
@service store; | ||
@service system; | ||
|
||
beforeModel() { | ||
return this.get('system.leader'); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As best as I can tell, this was accidentally left in here by copying the servers route page ~9 years ago. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
model() { | ||
return RSVP.hash({ | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -12,27 +12,23 @@ import { namespace } from '../adapters/application'; | |||
import jsonWithDefault from '../utils/json-with-default'; | ||||
import classic from 'ember-classic-decorator'; | ||||
import { task } from 'ember-concurrency'; | ||||
|
||||
@classic | ||||
export default class SystemService extends Service { | ||||
@service token; | ||||
@service store; | ||||
|
||||
@computed('activeRegion') | ||||
get leader() { | ||||
const token = this.token; | ||||
|
||||
return PromiseObject.create({ | ||||
promise: token | ||||
.authorizedRequest(`/${namespace}/status/leader`) | ||||
.then((res) => res.json()) | ||||
.then((rpcAddr) => ({ rpcAddr })) | ||||
.then((leader) => { | ||||
// Dirty self so leader can be used as a dependent key | ||||
this.notifyPropertyChange('leader.rpcAddr'); | ||||
return leader; | ||||
}), | ||||
}); | ||||
/** | ||||
* Iterates over all regions and returns a list of leaders' rpcAddrs | ||||
*/ | ||||
@computed('regions.[]') | ||||
get leaders() { | ||||
return Promise.all( | ||||
this.regions.map((region) => { | ||||
return this.token | ||||
.authorizedRequest(`/${namespace}/status/leader?region=${region}`) | ||||
.then((res) => res.json()); | ||||
}) | ||||
); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best as I can tell, the only thing that uses system.leader was the servers page, which is now using .leaders instead. Removed the old one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, It imports from nomad/ui/app/adapters/application.js Line 15 in 0324e78
|
||||
} | ||||
|
||||
@computed | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
~}} | ||
|
||
<td data-test-server-name | ||
{{keyboard-shortcut | ||
{{keyboard-shortcut | ||
enumerated=true | ||
action=(action this.goToAgent) | ||
}} | ||
|
@@ -17,13 +17,20 @@ | |
/> | ||
</span></td> | ||
<td data-test-server-is-leader> | ||
|
||
<Hds::Badge | ||
@text={{if this.agent.isLeader "True" "False"}} | ||
@icon={{if this.agent.isLeader "check-circle" ""}} | ||
@color={{if this.agent.isLeader "success" "neutral"}} | ||
@size="large" | ||
/> | ||
<Hds::Badge | ||
@text={{if | ||
this.agent.isLeader | ||
(if | ||
this.agent.system.shouldShowRegions | ||
(concat "True" " (" this.agent.region ")") | ||
"True" | ||
) | ||
"False" | ||
}} | ||
Comment on lines
+21
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Funky formatting, but:
|
||
@icon={{if this.agent.isLeader "check-circle" ""}} | ||
@color={{if this.agent.isLeader "success" "neutral"}} | ||
@size="large" | ||
/> | ||
</td> | ||
<td data-test-server-address class="is-200px is-truncatable">{{this.agent.address}}</td> | ||
<td data-test-server-port>{{this.agent.serfPort}}</td> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using
tracked
is more idiomatic than the isLeader getter in Ember Octane. And since service getters (likethis.get('system.leader....)
was the thing holding it back as a classic model, removed the@classic
tag as well.