Skip to content
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

Merged
merged 3 commits into from
Jul 26, 2021
Merged

Conversation

aleksfront
Copy link
Contributor

  1. Sorting workload statuses in same manner (Running, Succeeded, Scheduled goes on top).
  2. Fixed badge alignment styles.

Before:
misaligned badges

After:
aligned badges

Fixes #3423

@aleksfront aleksfront added bug Something isn't working area/ui labels Jul 22, 2021
@aleksfront aleksfront added this to the 5.2.0 milestone Jul 22, 2021
@aleksfront aleksfront requested a review from a team as a code owner July 22, 2021 14:02
@aleksfront aleksfront requested review from nevalla and Nokel81 and removed request for a team July 22, 2021 14:02
@@ -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());
Copy link
Contributor Author

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 @@
/**
Copy link
Contributor Author

@aleksfront aleksfront Jul 22, 2021

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 };
Copy link
Collaborator

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

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".

Copy link
Collaborator

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.

Copy link
Contributor Author

@aleksfront aleksfront Jul 23, 2021

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.

Copy link
Collaborator

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.

Copy link
Contributor

@jakolehm jakolehm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aleksfront aleksfront merged commit 8966210 into master Jul 26, 2021
@aleksfront aleksfront deleted the fix-workload-status-sorting branch July 26, 2021 06:33
@Nokel81 Nokel81 mentioned this pull request Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alignment of counters for Workloads/Overview
3 participants