-
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
[Resolver] model location.search
in redux
#76140
Changes from 5 commits
302aa15
ff0b3fb
94d171d
aee1ee4
952346d
8f40cd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
/** | ||
* The legacy `crumbEvent` and `crumbId` parameters. | ||
* @deprecated | ||
*/ | ||
export function breadcrumbParameters( | ||
locationSearch: string, | ||
resolverComponentInstanceID: string | ||
): { crumbEvent: string; crumbId: string } { | ||
const urlSearchParams = new URLSearchParams(locationSearch); | ||
const { eventKey, idKey } = parameterNames(resolverComponentInstanceID); | ||
return { | ||
// Use `''` for backwards compatibility with deprecated code. | ||
crumbEvent: urlSearchParams.get(eventKey) ?? '', | ||
crumbId: urlSearchParams.get(idKey) ?? '', | ||
}; | ||
} | ||
|
||
/** | ||
* Parameter names based on the `resolverComponentInstanceID`. | ||
*/ | ||
function parameterNames( | ||
resolverComponentInstanceID: string | ||
): { | ||
idKey: string; | ||
eventKey: string; | ||
} { | ||
const idKey: string = `resolver-${resolverComponentInstanceID}-id`; | ||
const eventKey: string = `resolver-${resolverComponentInstanceID}-event`; | ||
return { | ||
idKey, | ||
eventKey, | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -301,6 +301,15 @@ export const ariaFlowtoNodeID: ( | |
} | ||
); | ||
|
||
/** | ||
* The legacy `crumbEvent` and `crumbId` parameters. | ||
* @deprecated | ||
*/ | ||
export const breadcrumbParameters = composeSelectors( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use this to get the query string parameters used by the panel |
||
uiStateSelector, | ||
uiSelectors.breadcrumbParameters | ||
); | ||
|
||
/** | ||
* Calls the `secondSelector` with the result of the `selector`. Use this when re-exporting a | ||
* concern-specific selector. `selector` should return the concern-specific state. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { createSelector } from 'reselect'; | ||
import { ResolverUIState } from '../../types'; | ||
|
||
/** | ||
* id of the "current" tree node (fake-focused) | ||
*/ | ||
export const ariaActiveDescendant = createSelector( | ||
(uiState: ResolverUIState) => uiState, | ||
/* eslint-disable no-shadow */ | ||
({ ariaActiveDescendant }) => { | ||
return ariaActiveDescendant; | ||
} | ||
); | ||
|
||
/** | ||
* id of the currently "selected" tree node | ||
*/ | ||
export const selectedNode = createSelector( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
(uiState: ResolverUIState) => uiState, | ||
/* eslint-disable no-shadow */ | ||
({ selectedNode }: ResolverUIState) => { | ||
return selectedNode; | ||
} | ||
); | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { createSelector } from 'reselect'; | ||
import { ResolverUIState } from '../../types'; | ||
import * as locationSearchModel from '../../models/location_search'; | ||
|
||
/** | ||
* id of the "current" tree node (fake-focused) | ||
*/ | ||
export const ariaActiveDescendant = createSelector( | ||
(uiState: ResolverUIState) => uiState, | ||
/* eslint-disable no-shadow */ | ||
({ ariaActiveDescendant }) => { | ||
return ariaActiveDescendant; | ||
} | ||
); | ||
|
||
/** | ||
* id of the currently "selected" tree node | ||
*/ | ||
export const selectedNode = createSelector( | ||
(uiState: ResolverUIState) => uiState, | ||
/* eslint-disable no-shadow */ | ||
({ selectedNode }: ResolverUIState) => { | ||
return selectedNode; | ||
} | ||
); | ||
|
||
/** | ||
* The legacy `crumbEvent` and `crumbId` parameters. | ||
* @deprecated | ||
*/ | ||
export const breadcrumbParameters = createSelector( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
(state: ResolverUIState) => state.locationSearch, | ||
(state: ResolverUIState) => state.resolverComponentInstanceID, | ||
(locationSearch, resolverComponentInstanceID) => { | ||
if (locationSearch === undefined || resolverComponentInstanceID === undefined) { | ||
// Equivalent to `null` | ||
return { | ||
crumbId: '', | ||
crumbEvent: '', | ||
}; | ||
} | ||
return locationSearchModel.breadcrumbParameters(locationSearch, resolverComponentInstanceID); | ||
} | ||
); |
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.
This file will have the logic for getting values out of (and constructing new) URLSearchParams