-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix workload overview status sorting #3486
Conversation
Signed-off-by: Alex Andreev <[email protected]>
Signed-off-by: Alex Andreev <[email protected]>
Signed-off-by: Alex Andreev <[email protected]>
@@ -80,7 +80,7 @@ export class PodsStore extends KubeObjectStore<Pod> { | |||
} | |||
|
|||
getStatuses(pods: Pod[]) { | |||
return countBy(pods.map(pod => pod.getStatus())); | |||
return countBy(pods.map(pod => pod.getStatus()).sort().reverse()); |
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.
This will automatically sort statuses in a needed order:
Succeeded -> Running -> Pending -> Failed -> Evicted
@@ -0,0 +1,115 @@ | |||
/** |
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.
All tests sit in parent /components/
folder until this #3481 won't be resolved. Otherwise it's hard run (read impossible) tests locally.
@@ -34,7 +34,7 @@ export class CronJobStore extends KubeObjectStore<CronJob> { | |||
} | |||
|
|||
getStatuses(cronJobs?: CronJob[]) { | |||
const status = { suspended: 0, scheduled: 0 }; |
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.
Why does the order matter?
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.
This is an object, so I think we should specify the order by extracting to an array. Or at least add a comment above all of these saying that the order is important.
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.
Since we're decided to put all "green" statuses on top (show them first), I've moved scheduled
to be first one since it's "green".
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.
I still think that should be something that is commented or specified somewhere else. Since objects are key/value structures which don't really have a conceptual ordering.
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.
Yes, objects didn't have conceptual ordering, but they're actually have an order for now. The results are always the same + we have tests now checking ordering.
Here's mentions about object ordering https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#objects_vs._maps
As an alternative, I've converted statuses to use Maps, but this looks more messy and verbose without visible benefits.
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.
Okay, I was thinking more of having a defined ordering in overview-workload-status.tsx
but that might be a bit too much. Maybe something for the future.
I don't particularly like the fact that this ordering is required to be static but I concur that should be for the future.
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.
LGTM
Running
,Succeeded
,Scheduled
goes on top).Before:
After:
Fixes #3423