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(RHINENG-3106): properly apply default filters in CVEs and SystemsCVEs pages #2124

Merged
merged 8 commits into from
Jul 16, 2024

Conversation

mkholjuraev
Copy link
Contributor

@mkholjuraev mkholjuraev commented Jul 2, 2024

This fixes the preserving the state of default filters after refresh. The solution is to add the default filters only when user navigates to CVEs or SystemCVEs page by using navigations that have no active filter URL. In this case, default filters are added. In case, there are already default filters applied, the default filter are not applied, URL state dictates the table filtering.

@mkholjuraev mkholjuraev requested a review from a team as a code owner July 2, 2024 15:42
Copy link

jira-linking bot commented Jul 2, 2024

Commits missing Jira IDs:
bc327e4
7cd2565
c656c06
71bcd6c
88144c8
0d49c07
Referenced Jiras:
https://issues.redhat.com/browse/RHINENG-3106

@mkholjuraev mkholjuraev marked this pull request as draft July 2, 2024 15:42
@mkholjuraev mkholjuraev marked this pull request as ready for review July 2, 2024 19:24
@codecov-commenter
Copy link

codecov-commenter commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 82.92683% with 7 lines in your changes missing coverage. Please review.

Project coverage is 67.07%. Comparing base (2890b7a) to head (0d49c07).
Report is 2 commits behind head on master.

Files Patch % Lines
src/Components/SmartComponents/CVEs/CVEsAssets.js 77.27% 5 Missing ⚠️
src/Components/SmartComponents/CVEs/CVEs.js 92.30% 1 Missing ⚠️
...omponents/SmartComponents/CVEs/CVEsTableToolbar.js 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2124      +/-   ##
==========================================
+ Coverage   66.73%   67.07%   +0.34%     
==========================================
  Files         128      128              
  Lines        3445     3432      -13     
  Branches     1069     1064       -5     
==========================================
+ Hits         2299     2302       +3     
+ Misses       1146     1130      -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gkarat gkarat added the bug Something isn't working label Jul 9, 2024
src/Components/SmartComponents/CVEs/CVEs.js Outdated Show resolved Hide resolved
Comment on lines 131 to 134
apply({
...(Object.keys(urlParameters).length === 0 ? { advisory_available: 'true' } : {}),
...urlParameters
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be also rewritten in my opinion. Please see the previous comment

@@ -93,7 +93,7 @@ export const CVEs = ({ rbac }) => {
};

apply(filtersOnLoad);
}, [shouldUseHybridSystemFilter]);
}, [shouldUseHybridSystemFilter. urlParameters]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why urlParameters are needed here in the dependencies list? This useEffect deals with the first load and it seems to me that we should leave it empty completely, or am I wrong?

Comment on lines +234 to 237
<ComponentWithContext store={ store } renderOptions={{ initialEntries: ['?affecting=rpmdnf%2Cedge&advisory_available=true']}}>
<CVEs />
</TestWrapper>
</ComponentWithContext>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like TestWrapper and ComponentWithContext both deal with the same problem: render a component with the necessary providers and contexts. We have to stop duplicating these two components and just stick to only one. I see that TestWrapper doesn't support initialEntries: let's perhaps extend it and keep the usage of it here in this test file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would remove TestWrapper. Because ComponentWithContext follows the conventions that we have in other apps as well. That is why, I replaced TestWrapper with ComponentWithContext. Let's proceed with the review of this PR, I will, first of all, push the component into FEC so that we can share it among apps, and then adopt it in the vuln app in the next PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree that TestWrapper is the better name for the component rather than ComponentWithContext . While pushing to FEC, I will keep this in mind.

@mkholjuraev
Copy link
Contributor Author

@gkarat thank you for the review and nice suggestions. I have applied your suggestions. Have another look!

@mkholjuraev mkholjuraev requested review from gkarat and a team July 11, 2024 10:38
@mkholjuraev
Copy link
Contributor Author

mkholjuraev commented Jul 12, 2024

The last commit fixes the issue in the ticket comments by @mtclinton :

I have also noticed that if CVEs without Errata is disabled and I click the modal to "Show CVEs without Errata" the table and filters are not updated to reflect this. I have to manually refresh the page to display the advisory filter and have the table filter correct results.

It also has a large amount test cases and improvements.

Copy link
Contributor

@gkarat gkarat left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @mkholjuraev, but please take a look at the tests and ideally apply the suggestions before we merge

@mkholjuraev mkholjuraev merged commit bafe7f7 into RedHatInsights:master Jul 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants