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(GlobalFilters): RHINENG-6296 push correct params to url #1185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xmicha82
Copy link
Contributor

Description

Associated Jira ticket: # RHINENG-6296

Fixed pushing global filters to URL

How to test the PR

  1. Open Patch systems page
  2. Apply Global filters
  3. Global Filters should be added to the URL

Before the change

image

After the change

image

Checklist:

  • The commit message has the Jira ticket linked
  • PR has a short description
  • Screenshots before and after the change are added
  • Tests for the changes have been added
  • README.md is updated if necessary
  • Needs additional dependent work

@xmicha82 xmicha82 requested a review from a team as a code owner June 17, 2024 12:25
@codecov-commenter
Copy link

codecov-commenter commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 64.04%. Comparing base (fdcced0) to head (d164f1f).

Files Patch % Lines
src/SmartComponents/Systems/SystemsTable.js 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1185      +/-   ##
==========================================
+ Coverage   64.01%   64.04%   +0.02%     
==========================================
  Files         124      124              
  Lines        3235     3243       +8     
  Branches      831      833       +2     
==========================================
+ Hits         2071     2077       +6     
- Misses       1164     1166       +2     

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

@@ -27,9 +27,11 @@ const initStore = (state) => {
return mockStore(state);
};

const apply = () => {};
Copy link
Member

Choose a reason for hiding this comment

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

Explain.

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 apply is now used inside the SystemsTable (before, it was just passed along to other functions), the tests fail if apply is undefined. thus i'm just passing a plain function into the component

Copy link
Member

Choose a reason for hiding this comment

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

We will need to make this work even when no apply is provided.

@bastilian
Copy link
Member

Can you elaborate a bit more on what the issue was?

@xmicha82
Copy link
Contributor Author

basically, SystemsTable did not use the hook for managing URL params which is used in other places in patch. using this hook fixed the issue

@bastilian
Copy link
Member

@xmicha82 This doesn't feel like a fix, but a work around. We should also not need this firstMount state.

@xmicha82
Copy link
Contributor Author

@bastilian this change is consistent with other pages in patch, which also use the historyPusher. could you please explain why do you think it's not the right way to fix this issue?

@mkholjuraev mkholjuraev requested review from a team and bastilian June 25, 2024 11:58
@gkarat gkarat added the bug Something isn't working label Jul 16, 2024
@bastilian
Copy link
Member

@xmicha82 I took a quick look at this. I used master without any changes, but this in the SystemsTable:

    const location = useLocation();
    console.log('LOCATION CHANGE', location);

Here is what I saw:

patch_global_filter.mp4

If you pay attention to the console you will notice that, first of all, there are probably updates to the URL multiple times per render and re renders, and if you look that location after the global filter is set you'll see that at some point the hash is lost.

A proper fix for this issue will require us to take a closer look and see why, how and where changes to the URL happen when the SystemsTable loads and ensure that all of these places do not change the hash and preserve the global filter.

Ideally we would also look into reducing the amount of updates to just one update to the URL per filter change, but for now just making sure that the global filter hash is not lost should be fix enough.

@bastilian
Copy link
Member

bastilian commented Jul 23, 2024

A better place to start debugging might be the SystemsMainContent where we use useSearchParams. Adding this log output can give you an idea of how many times the URL is updated:

    const setSearchParams = (...args) => {
        console.log('SetSearch', ...args);
        setSearchParamsOrig(...args);
    };

The setSerachParams function provided by react router also allows navigate options as a second parameter, this might allow us to set the hash of the current location, that includes the global filter. No it doesn't help.

We might need to move those search param changes to use useNavigate instead.

@bastilian
Copy link
Member

@xmicha82 Have you had time to revise this issue? If you want we can debug this together and see where it starts loosing the hash property.

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.

4 participants