-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Security Solution] [Endpoint] Search params are reset when opening flyout in policy details artifact tab #127718
Conversation
@elasticmachine merge upstream |
…ng_flyout_in_policy_details_artifact_tab-3318
@elasticmachine merge upstream |
…ng_flyout_in_policy_details_artifact_tab-3318
…ng_flyout_in_policy_details_artifact_tab-3318
…n_policy_details_artifact_tab-3318' of github.com:dasansol92/kibana into fix/olm-search_params_are_reseted_when_opening_flyout_in_policy_details_artifact_tab-3318
@@ -64,6 +64,20 @@ export const useUrlPagination = (): UrlPagination => { | |||
const location = useLocation(); | |||
const history = useHistory(); | |||
const { urlParams, toUrlParams } = useUrlParams(); | |||
|
|||
useEffect(() => { |
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.
@paul-tavares let me know your thoughts on this. I decided to put this at this level as can be useful when using this hook in other places when migrating the list pages
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.
@dasansol92 - Yeah, having it here would address the problem, but it feels really wrong (to me 😄 ) that we are doing a history.replace()
in a hook meant to "get" url params - especially when it is being done automatically.
Also, the migration below is from page_index
to page
, which may not be an accurate mapping - page_index
is usually 0
based, where we now want to start using page
as 1
based in order to provide better URL UX to the users. (ex. User clicks on page 2
, they see 2
in the url)
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.
That's totally right. Then we can create a specific hook for it and use it in the needed components or move this code directly to the specific component. Thoughts?
Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt) |
); | ||
} | ||
// Apply this only when on mount this hook | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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.
🤢 😆
can we avoid this eslint disable rule?
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.
Is there a way to have an empty hook deps without a eslint error? I'm trying to run this only when component mounts
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.
maybe pair it with isMounted()
and just allow it run on MOunt?
Another option is to use a useRef()
and set the reference.current
to a function, then use that here. but it is weir :)
…o adds a unit test for it
@elasticmachine merge upstream |
…ng_flyout_in_policy_details_artifact_tab-3318
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.
Looks good 👍
.replaceAll('page_size', 'pageSize') | ||
.replaceAll( | ||
`page_index=${urlParams.page_index}`, | ||
`page=${Number(urlParams.page_index) + 1}` |
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.
Maybe add this note to the JSDoc for this hook: **NOTE**: This hook will also increment the
page_indexby
1since
page is now one-based
…n_policy_details_artifact_tab-3318' of github.com:dasansol92/kibana into fix/olm-search_params_are_reseted_when_opening_flyout_in_policy_details_artifact_tab-3318
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.
🚀 🚀
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
Summary
Before:
After:
For maintainers