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

[Security Solution] [Endpoint] Search params are reset when opening flyout in policy details artifact tab #127718

Conversation

dasansol92
Copy link
Contributor

Summary

  • Before:
    reseted search params open flyout

  • After:
    reseted search params open flyout fixed

For maintainers

@dasansol92 dasansol92 added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.2.0 labels Mar 15, 2022
@dasansol92 dasansol92 changed the title [Security Solution] [Endpoint] Search params are reseted when opening flyout in policy details artifact tab [Security Solution] [Endpoint] Search params are reset when opening flyout in policy details artifact tab Mar 15, 2022
@dasansol92
Copy link
Contributor Author

@elasticmachine merge upstream

…ng_flyout_in_policy_details_artifact_tab-3318
@dasansol92
Copy link
Contributor Author

@elasticmachine merge upstream

kibanamachine and others added 5 commits March 15, 2022 11:27
…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(() => {
Copy link
Contributor Author

@dasansol92 dasansol92 Mar 17, 2022

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

Copy link
Contributor

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)

Copy link
Contributor Author

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?

@dasansol92 dasansol92 marked this pull request as ready for review March 17, 2022 09:26
@dasansol92 dasansol92 requested a review from a team as a code owner March 17, 2022 09:26
@elasticmachine
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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 :)

@dasansol92
Copy link
Contributor Author

@elasticmachine merge upstream

…ng_flyout_in_policy_details_artifact_tab-3318
Copy link
Contributor

@paul-tavares paul-tavares left a 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}`
Copy link
Contributor

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_indexby1sincepage 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
Copy link
Member

@joeypoon joeypoon left a comment

Choose a reason for hiding this comment

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

🚀 🚀

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 2944 2945 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 4.8MB 4.8MB +800.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dasansol92 dasansol92 merged commit bbb531a into elastic:main Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants