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

[Resolver] model location.search in redux #76140

Merged

Conversation

oatkiller
Copy link
Contributor

@oatkiller oatkiller commented Aug 27, 2020

Read location.search from the redux store instead of a hook so that the entire view has a single (synchronized) source of truth.

Still works:
image

Still works in the test app as well:
image

Checklist

For maintainers

@oatkiller oatkiller requested review from a team as code owners August 27, 2020 19:16
@oatkiller oatkiller force-pushed the use-url-to-determine-what-panel-to-show branch from 6f44894 to 62a06bb Compare August 27, 2020 19:16
* The legacy `crumbEvent` and `crumbId` parameters.
* @deprecated
*/
export function breadcrumbParameters(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file will have the logic for getting values out of (and constructing new) URLSearchParams

@@ -75,7 +75,15 @@ interface AppReceivedNewExternalProperties {
* the `_id` of an ES document. This defines the origin of the Resolver graph.
*/
databaseDocumentID?: string;
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This action isn't specific to data at all so I'm going to move it to the top level Resolver actions file.

* The legacy `crumbEvent` and `crumbId` parameters.
* @deprecated
*/
export const breadcrumbParameters = composeSelectors(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

use this to get the query string parameters used by the panel

/**
* id of the currently "selected" tree node
*/
export const selectedNode = createSelector(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
I'm guessing this is another line-endings thing.

* The legacy `crumbEvent` and `crumbId` parameters.
* @deprecated
*/
export const breadcrumbParameters = createSelector(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function was added. the rest of the changes (except for import statements) are white space.

@@ -39,7 +39,9 @@ const PanelContent = memo(function PanelContent() {

const { timestamp } = useContext(SideEffectContext);

const { pushToQueryParams, queryParams } = useResolverQueryParams();
const queryParams = useSelector(selectors.breadcrumbParameters);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

use the selector to get the panel query params now

const { pushToQueryParams, queryParams } = useResolverQueryParams();
const queryParams = useSelector(selectors.breadcrumbParameters);

const pushToQueryParams = useReplaceBreadcrumbParameters();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed useResolverQueryParams to this. it no longer returns the query params.

useLayoutEffect(() => {
dispatch({
type: 'appReceivedNewExternalProperties',
payload: { databaseDocumentID, resolverComponentInstanceID },
payload: { databaseDocumentID, resolverComponentInstanceID, locationSearch },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

dispatch this action any time the location.search changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Having this action fire whenever location.search changes seems sort of overkill, why not just when the relevant params change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The app will need to read the entire query string. For example, we might need to show a link that causes our panel to open. In that case we'll want the link to include all query string values (not just ones relevant to this Resolver instance.)

@oatkiller oatkiller added release_note:skip Skip the PR/issue when compiling release notes v7.10.0 labels Aug 27, 2020
Copy link
Contributor

@kqualters-elastic kqualters-elastic left a comment

Choose a reason for hiding this comment

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

Since I had more or less the same logic just in a few different places, LGTM 👍 looks great to me!

oatkiller added 3 commits August 27, 2020 15:54
Begin reading `location.search` via redux so that all parts of the app
share a single source of truth about it
@oatkiller oatkiller force-pushed the use-url-to-determine-what-panel-to-show branch from ca58e92 to aee1ee4 Compare August 27, 2020 20:09
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
Seems like this file probably had DOS line endings. Hide whitespace so you can see what really changed.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
securitySolution 1926 +1 1925

async chunks size

id value diff baseline
securitySolution 9.5MB +1.7KB 9.5MB

distributable file count

id value diff baseline
total 53140 +1 53139

History

  • 💔 Build #71016 failed ca58e926ce2d30683569f7191f43419a17ce9941

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

@oatkiller oatkiller merged commit 3fc3f58 into elastic:master Aug 28, 2020
@oatkiller oatkiller deleted the use-url-to-determine-what-panel-to-show branch August 28, 2020 12:53
oatkiller pushed a commit to oatkiller/kibana that referenced this pull request Aug 28, 2020
Read location.search from the redux store instead of a hook so that the entire view has a single (synchronized) source of truth.

Also, no longer pass `pushToQueryParams` function to various components.
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 31, 2020
…s-for-710

* 'master' of github.com:elastic/kibana: (43 commits)
  [APM] Chart units don't update when toggling the chart legends (elastic#74931)
  [ILM] Add support for frozen phase in UI (elastic#75968)
  Hides advanced json for count metric (elastic#74636)
  add client-side feature usage API (elastic#75486)
  [Maps] add drilldown support map embeddable (elastic#75598)
  [Enterprise Search] Request handler refactors/enhancements + update existing routes to use shared handler (elastic#76106)
  [Resolver] model `location.search` in redux (elastic#76140)
  [APM] Prevent imports of public in server code (elastic#75979)
  fix eslint issue
  skip flaky suite (elastic#76223)
  [APM] Transaction duration anomaly alerting integration (elastic#75719)
  [Transforms] Avoid using "Are you sure" (elastic#75932)
  [Security Solution][Exceptions] - Fix bug of alerts not updating after closure from exceptions modal (elastic#76145)
  [plugin-helpers] improve 3rd party KP plugin support (elastic#75019)
  [docs/getting-started] link to yarn v1 specifically (elastic#76169)
  [Security_Solution][Resolver] Resolver loading and error state (elastic#75600)
  Fixes App Search documentation links (elastic#76133)
  Fix alerts unable to create / update when the name has trailing whitepace(s) (elastic#76079)
  [Resolver] Fix useSelector usage (elastic#76129)
  [Enterprise Search] Migrate util and components from ent-search (elastic#76051)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/node_allocation.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/services/policies/types.ts
#	x-pack/plugins/index_lifecycle_management/public/application/services/policies/warm_phase.ts
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Sep 1, 2020
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Sep 1, 2020
oatkiller pushed a commit that referenced this pull request Sep 1, 2020
Read location.search from the redux store instead of a hook so that the entire view has a single (synchronized) source of truth.

Also, no longer pass `pushToQueryParams` function to various components.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants