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: proper sorting resources by age column (#2182 followup) #2414

Merged
merged 3 commits into from
Apr 14, 2021

Conversation

MJ111
Copy link
Contributor

@MJ111 MJ111 commented Mar 30, 2021

Hello guys, thank you for the awesome project! I'm actively using lens in production.
I recently encountered this bug and searched #2182 PR was merged but omitted this part.
So, As followup, I added this PR.
If you have question, feel free to comment. Thanks.

Fixes:
sorting resources by age is broken (previously sorted by iso-string timestamp) in cluster-issues

AS-IS
Screen Shot 2021-03-30 at 8 04 31 PM

TO-BE
Screen Shot 2021-03-30 at 8 00 41 PM

@MJ111 MJ111 force-pushed the fix/cluster-issues-sort-by-age branch from 789773b to fd32f2e Compare March 30, 2021 11:32
@MJ111
Copy link
Contributor Author

MJ111 commented Mar 30, 2021

Don't know why Windows node_12.x test failed in Generate npm package job with the following error :(

Module not found: Error: Can't resolve '../isolated-hoist-non-react-statics-do-not-use-this-in-your-code/dist/emotion-react-isolated-hoist-non-react-statics-do-not-use-this-in-your-code.browser.esm.js' in 'D:\a\1\s\node_modules\@emotion\react\dist'

Could you guys help me?

@Nokel81
Copy link
Collaborator

Nokel81 commented Mar 30, 2021

@MJ111 I just noticed that on some other PRs. So I think CI is borked currently.

@Nokel81 Nokel81 requested a review from a team March 30, 2021 13:46
@Nokel81 Nokel81 added the bug Something isn't working label Mar 30, 2021
@Nokel81 Nokel81 added this to the 4.2.1 milestone Mar 30, 2021
Nokel81
Nokel81 previously approved these changes Mar 30, 2021
@Nokel81 Nokel81 requested a review from a team March 30, 2021 14:28
ixrock
ixrock previously approved these changes Mar 30, 2021
@Nokel81
Copy link
Collaborator

Nokel81 commented Mar 30, 2021

@MJ111 can you please rebase against master?

@@ -37,21 +38,22 @@ export class ClusterIssues extends React.Component<Props> {
private sortCallbacks = {
[sortBy.type]: (warning: IWarning) => warning.kind,
[sortBy.object]: (warning: IWarning) => warning.getName(),
[sortBy.age]: (warning: IWarning) => warning.age || "",
[sortBy.age]: (warning: IWarning) => warning.getTimeDiffFromNow(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't feel quite right, getTimeDiffFromNow() calls Date.now(), which means that for sorting a different "now" is used each time this is called. Could cause problems? Just use a static timeDiffFromNow in IWarning? Or we really just need something that converts the age string to a number (and done when warnings is populated)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So age is getAge() which calls getTimeDiffFromNow() anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but it was not getting called during sorting. And also that means we shouldn't need to use getTimeDiffFromNow() directly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair good point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Though we also don't want it use a different "now" when creating it. So probably the best solution would be to have a warning.getTimeDiffFrom(firstLoad) where this.firstLoad = Date.now() is called in the componentDidMount method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably beyond the scope of this PR.
If this PR is in line with what we do elsewhere then it's OK. Though I think it could be changed easily enough so that it is using a pre-calculated timeDiffFromNow value in the sort callback.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed as out of scope, though it shouldn't change the sorting order (too much).

@MJ111 MJ111 dismissed stale reviews from ixrock and Nokel81 via 545dd86 March 31, 2021 11:48
@MJ111 MJ111 force-pushed the fix/cluster-issues-sort-by-age branch from fd32f2e to 545dd86 Compare March 31, 2021 11:48
@MJ111
Copy link
Contributor Author

MJ111 commented Mar 31, 2021

@Nokel81 sorry for the late response. I rebased the branch.

@Nokel81 Nokel81 changed the base branch from master to release/v4.2 April 6, 2021 14:20
@Nokel81 Nokel81 added the merge/master This PR will need to be merged to master after merged to target. Using cherry-pick. label Apr 6, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Apr 6, 2021

This pull request has conflicts, please resolve those before we can evaluate the pull request.

sorting resources by age in cluster-issues is broken (previously sorted by iso-string timestamp)

Signed-off-by: MinJeong Kim <min7859@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Apr 6, 2021

Conflicts have been resolved. A maintainer will review the pull request shortly.

@Nokel81 Nokel81 modified the milestones: 4.2.1, 4.2.2 Apr 9, 2021
Copy link
Contributor

@jim-docker jim-docker left a comment

Choose a reason for hiding this comment

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

Can we do these changes at least?

src/renderer/components/+cluster/cluster-issues.tsx Outdated Show resolved Hide resolved
src/renderer/components/+cluster/cluster-issues.tsx Outdated Show resolved Hide resolved
src/renderer/components/+cluster/cluster-issues.tsx Outdated Show resolved Hide resolved
src/renderer/components/+cluster/cluster-issues.tsx Outdated Show resolved Hide resolved
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
fix lint

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
@Nokel81 Nokel81 merged commit 4e231e5 into lensapp:release/v4.2 Apr 14, 2021
@Nokel81 Nokel81 mentioned this pull request Apr 15, 2021
Nokel81 pushed a commit that referenced this pull request Apr 16, 2021
Co-authored-by: Jim Ehrismann <40840436+jim-docker@users.noreply.github.com>
@Nokel81 Nokel81 removed the merge/master This PR will need to be merged to master after merged to target. Using cherry-pick. label Apr 16, 2021
Nokel81 pushed a commit that referenced this pull request Apr 19, 2021
Co-authored-by: Jim Ehrismann <40840436+jim-docker@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants