mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
bump query-string version to remove manual type definitions (#78143)
* bump query-string version to remove manual type definitions * remove manual type declaration * fix cypress tests * add )
This commit is contained in:
parent
3f2e9f7705
commit
8ba60a4004
17 changed files with 80 additions and 220 deletions
|
@ -195,7 +195,7 @@
|
|||
"p-map": "^4.0.0",
|
||||
"pegjs": "0.10.0",
|
||||
"proxy-from-env": "1.0.0",
|
||||
"query-string": "5.1.1",
|
||||
"query-string": "^6.13.2",
|
||||
"re2": "^1.15.4",
|
||||
"react": "^16.12.0",
|
||||
"react-color": "^2.13.8",
|
||||
|
|
|
@ -24,6 +24,6 @@ export { mapToObject } from './map_to_object';
|
|||
export { merge } from './merge';
|
||||
export { pick } from './pick';
|
||||
export { withTimeout } from './promise';
|
||||
export { isRelativeUrl, modifyUrl, URLMeaningfulParts, ParsedQuery } from './url';
|
||||
export { isRelativeUrl, modifyUrl, URLMeaningfulParts } from './url';
|
||||
export { unset } from './unset';
|
||||
export { getFlattenedObject } from './get_flattened_object';
|
||||
|
|
|
@ -18,11 +18,7 @@
|
|||
*/
|
||||
|
||||
import { format as formatUrl, parse as parseUrl, UrlObject } from 'url';
|
||||
|
||||
// duplicate type from 'query-string' to avoid adding the d.ts file to all packages depending on kbn-std
|
||||
export interface ParsedQuery<T = string> {
|
||||
[key: string]: T | T[] | null | undefined;
|
||||
}
|
||||
import type { ParsedQuery } from 'query-string';
|
||||
|
||||
/**
|
||||
* We define our own typings because the current version of @types/node
|
||||
|
|
|
@ -17,34 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
declare module 'query-string' {
|
||||
type ArrayFormat = 'bracket' | 'index' | 'none';
|
||||
|
||||
export interface ParseOptions {
|
||||
arrayFormat?: ArrayFormat;
|
||||
sort: ((itemLeft: string, itemRight: string) => number) | false;
|
||||
}
|
||||
|
||||
export interface ParsedQuery<T = string> {
|
||||
[key: string]: T | T[] | null | undefined;
|
||||
}
|
||||
|
||||
export function parse(str: string, options?: ParseOptions): ParsedQuery;
|
||||
|
||||
export function parseUrl(str: string, options?: ParseOptions): { url: string; query: any };
|
||||
|
||||
export interface StringifyOptions {
|
||||
strict?: boolean;
|
||||
encode?: boolean;
|
||||
arrayFormat?: ArrayFormat;
|
||||
sort: ((itemLeft: string, itemRight: string) => number) | false;
|
||||
}
|
||||
|
||||
export function stringify(obj: object, options?: StringifyOptions): string;
|
||||
|
||||
export function extract(str: string): string;
|
||||
}
|
||||
|
||||
type DeeplyMockedKeys<T> = {
|
||||
[P in keyof T]: T[P] extends (...args: any[]) => any
|
||||
? jest.MockInstance<ReturnType<T[P]>, Parameters<T[P]>>
|
||||
|
|
|
@ -24,16 +24,17 @@ describe('', () => {
|
|||
const id = '123eb456cd';
|
||||
const url =
|
||||
"/pep/app/dashboards#/create?_g=(refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_a=(description:'',filters:!())";
|
||||
expect(addEmbeddableToDashboardUrl(url, id, 'visualization')).toEqual(
|
||||
`/pep/app/dashboards#/create?_a=%28description%3A%27%27%2Cfilters%3A%21%28%29%29&_g=%28refreshInterval%3A%28pause%3A%21t%2Cvalue%3A0%29%2Ctime%3A%28from%3Anow-15m%2Cto%3Anow%29%29&addEmbeddableId=${id}&addEmbeddableType=visualization`
|
||||
|
||||
expect(addEmbeddableToDashboardUrl(url, id, 'visualization')).toBe(
|
||||
'/pep/app/dashboards?addEmbeddableId=123eb456cd&addEmbeddableType=visualization#%2Fcreate%3F_g%3D%28refreshInterval%3A%28pause%3A%21t%2Cvalue%3A0%29%2Ctime%3A%28from%3Anow-15m%2Cto%3Anow%29%29%26_a%3D%28description%3A%27%27%2Cfilters%3A%21%28%29%29'
|
||||
);
|
||||
});
|
||||
it('addEmbeddableToDashboardUrl when dashboard is saved', () => {
|
||||
const id = '123eb456cd';
|
||||
const url =
|
||||
"/pep/app/dashboards#/view/9b780cd0-3dd3-11e8-b2b9-5d5dc1715159?_g=(refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_a=(description:'',filters:!())";
|
||||
expect(addEmbeddableToDashboardUrl(url, id, 'visualization')).toEqual(
|
||||
`/pep/app/dashboards#/view/9b780cd0-3dd3-11e8-b2b9-5d5dc1715159?_a=%28description%3A%27%27%2Cfilters%3A%21%28%29%29&_g=%28refreshInterval%3A%28pause%3A%21t%2Cvalue%3A0%29%2Ctime%3A%28from%3Anow-15m%2Cto%3Anow%29%29&addEmbeddableId=${id}&addEmbeddableType=visualization`
|
||||
expect(addEmbeddableToDashboardUrl(url, id, 'visualization')).toBe(
|
||||
'/pep/app/dashboards?addEmbeddableId=123eb456cd&addEmbeddableType=visualization#%2Fview%2F9b780cd0-3dd3-11e8-b2b9-5d5dc1715159%3F_g%3D%28refreshInterval%3A%28pause%3A%21t%2Cvalue%3A0%29%2Ctime%3A%28from%3Anow-15m%2Cto%3Anow%29%29%26_a%3D%28description%3A%27%27%2Cfilters%3A%21%28%29%29'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { parseUrl, stringify } from 'query-string';
|
||||
import { parseUrl, stringifyUrl } from 'query-string';
|
||||
import { DashboardConstants } from '../index';
|
||||
|
||||
/** *
|
||||
|
@ -34,12 +34,14 @@ export function addEmbeddableToDashboardUrl(
|
|||
embeddableId: string,
|
||||
embeddableType: string
|
||||
) {
|
||||
const { url, query } = parseUrl(dashboardUrl);
|
||||
const { url, query, fragmentIdentifier } = parseUrl(dashboardUrl, {
|
||||
parseFragmentIdentifier: true,
|
||||
});
|
||||
|
||||
if (embeddableId) {
|
||||
query[DashboardConstants.ADD_EMBEDDABLE_TYPE] = embeddableType;
|
||||
query[DashboardConstants.ADD_EMBEDDABLE_ID] = embeddableId;
|
||||
}
|
||||
|
||||
return `${url}?${stringify(query)}`;
|
||||
return stringifyUrl({ url, query, fragmentIdentifier });
|
||||
}
|
||||
|
|
46
test/typings/query_string.d.ts
vendored
46
test/typings/query_string.d.ts
vendored
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
declare module 'query-string' {
|
||||
type ArrayFormat = 'bracket' | 'index' | 'none';
|
||||
|
||||
export interface ParseOptions {
|
||||
arrayFormat?: ArrayFormat;
|
||||
sort: ((itemLeft: string, itemRight: string) => number) | false;
|
||||
}
|
||||
|
||||
export interface ParsedQuery<T = string> {
|
||||
[key: string]: T | T[] | null | undefined;
|
||||
}
|
||||
|
||||
export function parse(str: string, options?: ParseOptions): ParsedQuery;
|
||||
|
||||
export function parseUrl(str: string, options?: ParseOptions): { url: string; query: any };
|
||||
|
||||
export interface StringifyOptions {
|
||||
strict?: boolean;
|
||||
encode?: boolean;
|
||||
arrayFormat?: ArrayFormat;
|
||||
sort: ((itemLeft: string, itemRight: string) => number) | false;
|
||||
}
|
||||
|
||||
export function stringify(obj: object, options?: StringifyOptions): string;
|
||||
|
||||
export function extract(str: string): string;
|
||||
}
|
46
typings/query_string.d.ts
vendored
46
typings/query_string.d.ts
vendored
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
declare module 'query-string' {
|
||||
type ArrayFormat = 'bracket' | 'index' | 'none';
|
||||
|
||||
export interface ParseOptions {
|
||||
arrayFormat?: ArrayFormat;
|
||||
sort: ((itemLeft: string, itemRight: string) => number) | false;
|
||||
}
|
||||
|
||||
export interface ParsedQuery<T = string> {
|
||||
[key: string]: T | T[] | null | undefined;
|
||||
}
|
||||
|
||||
export function parse(str: string, options?: ParseOptions): ParsedQuery;
|
||||
|
||||
export function parseUrl(str: string, options?: ParseOptions): { url: string; query: any };
|
||||
|
||||
export interface StringifyOptions {
|
||||
strict?: boolean;
|
||||
encode?: boolean;
|
||||
arrayFormat?: ArrayFormat;
|
||||
sort: ((itemLeft: string, itemRight: string) => number) | false;
|
||||
}
|
||||
|
||||
export function stringify(obj: object, options?: StringifyOptions): string;
|
||||
|
||||
export function extract(str: string): string;
|
||||
}
|
|
@ -361,7 +361,7 @@
|
|||
"proper-lockfile": "^3.2.0",
|
||||
"puid": "1.0.7",
|
||||
"puppeteer-core": "^1.19.0",
|
||||
"query-string": "5.1.1",
|
||||
"query-string": "^6.13.2",
|
||||
"raw-loader": "3.1.0",
|
||||
"react": "^16.12.0",
|
||||
"react-datetime": "^2.14.0",
|
||||
|
|
|
@ -19,7 +19,7 @@ describe('RedirectToLogs component', () => {
|
|||
|
||||
expect(component).toMatchInlineSnapshot(`
|
||||
<Redirect
|
||||
to="/stream?logPosition=(end:'2019-02-20T14:58:09.404Z',position:(tiebreaker:0,time:1550671089404),start:'2019-02-20T12:58:09.404Z',streamLive:!f)&sourceId=default&logFilter=(expression:'',kind:kuery)"
|
||||
to="/stream?sourceId=default&logPosition=(end:'2019-02-20T14:58:09.404Z',position:(tiebreaker:0,time:1550671089404),start:'2019-02-20T12:58:09.404Z',streamLive:!f)&logFilter=(expression:'',kind:kuery)"
|
||||
/>
|
||||
`);
|
||||
});
|
||||
|
@ -33,7 +33,7 @@ describe('RedirectToLogs component', () => {
|
|||
|
||||
expect(component).toMatchInlineSnapshot(`
|
||||
<Redirect
|
||||
to="/stream?logPosition=(end:'2019-02-20T14:58:09.404Z',position:(tiebreaker:0,time:1550671089404),start:'2019-02-20T12:58:09.404Z',streamLive:!f)&sourceId=default&logFilter=(expression:'FILTER_FIELD:FILTER_VALUE',kind:kuery)"
|
||||
to="/stream?sourceId=default&logPosition=(end:'2019-02-20T14:58:09.404Z',position:(tiebreaker:0,time:1550671089404),start:'2019-02-20T12:58:09.404Z',streamLive:!f)&logFilter=(expression:'FILTER_FIELD:FILTER_VALUE',kind:kuery)"
|
||||
/>
|
||||
`);
|
||||
});
|
||||
|
|
|
@ -156,16 +156,14 @@ export const replaceStateKeyInQueryString = <UrlState extends any>(
|
|||
urlState: UrlState | undefined
|
||||
) => (queryString: string) => {
|
||||
const previousQueryValues = parse(queryString, { sort: false });
|
||||
const encodedUrlState =
|
||||
typeof urlState !== 'undefined' ? encodeRisonUrlState(urlState) : undefined;
|
||||
|
||||
return stringify(
|
||||
url.encodeQuery({
|
||||
...previousQueryValues,
|
||||
[stateKey]: encodedUrlState,
|
||||
}),
|
||||
{ sort: false, encode: false }
|
||||
);
|
||||
const newValue =
|
||||
typeof urlState === 'undefined'
|
||||
? previousQueryValues
|
||||
: {
|
||||
...previousQueryValues,
|
||||
[stateKey]: encodeRisonUrlState(urlState),
|
||||
};
|
||||
return stringify(url.encodeQuery(newValue), { sort: false, encode: false });
|
||||
};
|
||||
|
||||
const replaceQueryStringInLocation = (location: Location, queryString: string): Location => {
|
||||
|
|
|
@ -111,16 +111,15 @@ export const replaceStateKeyInQueryString = <UrlState extends any>(
|
|||
urlState: UrlState | undefined
|
||||
) => (queryString: string) => {
|
||||
const previousQueryValues = parse(queryString, { sort: false });
|
||||
const encodedUrlState =
|
||||
typeof urlState !== 'undefined' ? encodeRisonUrlState(urlState) : undefined;
|
||||
const newValue =
|
||||
typeof urlState === 'undefined'
|
||||
? previousQueryValues
|
||||
: {
|
||||
...previousQueryValues,
|
||||
[stateKey]: encodeRisonUrlState(urlState),
|
||||
};
|
||||
|
||||
return stringify(
|
||||
url.encodeQuery({
|
||||
...previousQueryValues,
|
||||
[stateKey]: encodedUrlState,
|
||||
}),
|
||||
{ sort: false, encode: false }
|
||||
);
|
||||
return stringify(url.encodeQuery(newValue), { sort: false, encode: false });
|
||||
};
|
||||
|
||||
const replaceQueryStringInLocation = (location: Location, queryString: string): Location => {
|
||||
|
|
|
@ -94,7 +94,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlNetworkSingleIpNullKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/network/ip/127.0.0.1/source?sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))'
|
||||
'app/security/network/ip/127.0.0.1/source?timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -102,7 +102,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlNetworkSingleIpKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/network/ip/127.0.0.1/source?query=(language:kuery,query:%27(process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22)%27)&sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))'
|
||||
'/app/security/network/ip/127.0.0.1/source?query=(language:kuery,query:%27(process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22)%27)&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -110,7 +110,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlNetworkMultipleIpNullKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'app/security/network/flows?query=(language:kuery,query:%27((source.ip:%20%22127.0.0.1%22%20or%20destination.ip:%20%22127.0.0.1%22)%20or%20(source.ip:%20%22127.0.0.2%22%20or%20destination.ip:%20%22127.0.0.2%22))%27)&sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27))'
|
||||
'app/security/network/flows?query=(language:kuery,query:%27((source.ip:%20%22127.0.0.1%22%20or%20destination.ip:%20%22127.0.0.1%22)%20or%20(source.ip:%20%22127.0.0.2%22%20or%20destination.ip:%20%22127.0.0.2%22))%27)&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -118,7 +118,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlNetworkMultipleIpKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/network/flows?query=(language:kuery,query:%27((source.ip:%20%22127.0.0.1%22%20or%20destination.ip:%20%22127.0.0.1%22)%20or%20(source.ip:%20%22127.0.0.2%22%20or%20destination.ip:%20%22127.0.0.2%22))%20and%20((process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22))%27)&sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))'
|
||||
'/app/security/network/flows?query=(language:kuery,query:%27((source.ip:%20%22127.0.0.1%22%20or%20destination.ip:%20%22127.0.0.1%22)%20or%20(source.ip:%20%22127.0.0.2%22%20or%20destination.ip:%20%22127.0.0.2%22))%20and%20((process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22))%27)&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -126,7 +126,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlNetworkNullKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/network/flows?sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))'
|
||||
'/app/security/network/flows?timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -134,7 +134,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlNetworkKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/network/flows?query=(language:kuery,query:%27(process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22)%27)&sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))'
|
||||
'/app/security/network/flows?query=(language:kuery,query:%27(process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22)%27)&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-08-28T11:00:00.000Z%27,kind:absolute,to:%272019-08-28T13:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -142,7 +142,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlHostSingleHostNullKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/hosts/siem-windows/anomalies?sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))'
|
||||
'/app/security/hosts/siem-windows/anomalies?timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -150,7 +150,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlHostSingleHostKqlQueryVariable);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/hosts/siem-windows/anomalies?sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))'
|
||||
'/app/security/hosts/siem-windows/anomalies?timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -158,7 +158,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlHostSingleHostKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/hosts/siem-windows/anomalies?query=(language:kuery,query:%27(process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22)%27)&sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))'
|
||||
'/app/security/hosts/siem-windows/anomalies?query=(language:kuery,query:%27(process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22)%27)&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -166,7 +166,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlHostMultiHostNullKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/hosts/anomalies?query=(language:kuery,query:%27(host.name:%20%22siem-windows%22%20or%20host.name:%20%22siem-suricata%22)%27)&sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))'
|
||||
'/app/security/hosts/anomalies?query=(language:kuery,query:%27(host.name:%20%22siem-windows%22%20or%20host.name:%20%22siem-suricata%22)%27)&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -174,7 +174,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlHostMultiHostKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/hosts/anomalies?query=(language:kuery,query:%27(host.name:%20%22siem-windows%22%20or%20host.name:%20%22siem-suricata%22)%20and%20((process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22))%27)&sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))'
|
||||
'/app/security/hosts/anomalies?query=(language:kuery,query:%27(host.name:%20%22siem-windows%22%20or%20host.name:%20%22siem-suricata%22)%20and%20((process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22))%27)&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -182,7 +182,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlHostVariableHostNullKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/hosts/anomalies?sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))'
|
||||
'/app/security/hosts/anomalies?timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -190,7 +190,7 @@ describe('ml conditional links', () => {
|
|||
loginAndWaitForPageWithoutDateRange(mlHostVariableHostKqlQuery);
|
||||
cy.url().should(
|
||||
'include',
|
||||
'/app/security/hosts/anomalies?query=(language:kuery,query:%27(process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22)%27)&sourcerer=(default:!(%27auditbeat-*%27))&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))'
|
||||
'/app/security/hosts/anomalies?query=(language:kuery,query:%27(process.name:%20%22conhost.exe%22%20or%20process.name:%20%22sc.exe%22)%27)&timerange=(global:(linkTo:!(timeline),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)),timeline:(linkTo:!(global),timerange:(from:%272019-06-06T06:00:00.000Z%27,kind:absolute,to:%272019-06-07T05:59:59.999Z%27)))&sourcerer=(default:!(%27auditbeat-*%27))'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -60,16 +60,14 @@ export const replaceStateKeyInQueryString = <T>(stateKey: string, urlState: T) =
|
|||
|
||||
// ಠ_ಠ Code was copied from x-pack/legacy/plugins/infra/public/utils/url_state.tsx ಠ_ಠ
|
||||
// Remove this if these utilities are promoted to kibana core
|
||||
const encodedUrlState =
|
||||
typeof urlState !== 'undefined' ? encodeRisonUrlState(urlState) : undefined;
|
||||
|
||||
return stringify(
|
||||
url.encodeQuery({
|
||||
...previousQueryValues,
|
||||
[stateKey]: encodedUrlState,
|
||||
}),
|
||||
{ sort: false, encode: false }
|
||||
);
|
||||
const newValue =
|
||||
typeof urlState === 'undefined'
|
||||
? previousQueryValues
|
||||
: {
|
||||
...previousQueryValues,
|
||||
[stateKey]: encodeRisonUrlState(urlState),
|
||||
};
|
||||
return stringify(url.encodeQuery(newValue), { sort: false, encode: false });
|
||||
};
|
||||
|
||||
export const replaceQueryStringInLocation = (
|
||||
|
|
|
@ -121,7 +121,7 @@ describe('useUrlParams', () => {
|
|||
|
||||
expect(history.push).toHaveBeenCalledWith({
|
||||
pathname: '/',
|
||||
search: 'dateRangeEnd=now&dateRangeStart=now-12&g=%22%22',
|
||||
search: 'g=%22%22&dateRangeStart=now-12&dateRangeEnd=now',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
33
x-pack/typings/query_string.d.ts
vendored
33
x-pack/typings/query_string.d.ts
vendored
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare module 'query-string' {
|
||||
type ArrayFormat = 'bracket' | 'index' | 'none';
|
||||
|
||||
export interface ParseOptions {
|
||||
arrayFormat?: ArrayFormat;
|
||||
sort?: ((itemLeft: string, itemRight: string) => number) | false;
|
||||
}
|
||||
|
||||
export interface ParsedQuery<T = string> {
|
||||
[key: string]: T | T[] | null | undefined;
|
||||
}
|
||||
|
||||
export function parse(str: string, options?: ParseOptions): ParsedQuery;
|
||||
|
||||
export function parseUrl(str: string, options?: ParseOptions): { url: string; query: any };
|
||||
|
||||
export interface StringifyOptions {
|
||||
strict?: boolean;
|
||||
encode?: boolean;
|
||||
arrayFormat?: ArrayFormat;
|
||||
sort?: ((itemLeft: string, itemRight: string) => number) | false;
|
||||
}
|
||||
|
||||
export function stringify(obj: object, options?: StringifyOptions): string;
|
||||
|
||||
export function extract(str: string): string;
|
||||
}
|
33
yarn.lock
33
yarn.lock
|
@ -23251,7 +23251,15 @@ qs@^6.6.0:
|
|||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.8.0.tgz#87b763f0d37ca54200334cd57bb2ef8f68a1d081"
|
||||
integrity sha512-tPSkj8y92PfZVbinY1n84i1Qdx75lZjMQYx9WZhnkofyxzw2r7Ho39G3/aEvSUdebxpnnM4LZJCtvE/Aq3+s9w==
|
||||
|
||||
query-string@5.1.1, query-string@^5.0.1:
|
||||
query-string@^4.1.0, query-string@^4.2.2:
|
||||
version "4.3.4"
|
||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.3.4.tgz#bbb693b9ca915c232515b228b1a02b609043dbeb"
|
||||
integrity sha1-u7aTucqRXCMlFbIosaArYJBD2+s=
|
||||
dependencies:
|
||||
object-assign "^4.1.0"
|
||||
strict-uri-encode "^1.0.0"
|
||||
|
||||
query-string@^5.0.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb"
|
||||
integrity sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==
|
||||
|
@ -23260,13 +23268,14 @@ query-string@5.1.1, query-string@^5.0.1:
|
|||
object-assign "^4.1.0"
|
||||
strict-uri-encode "^1.0.0"
|
||||
|
||||
query-string@^4.1.0, query-string@^4.2.2:
|
||||
version "4.3.4"
|
||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.3.4.tgz#bbb693b9ca915c232515b228b1a02b609043dbeb"
|
||||
integrity sha1-u7aTucqRXCMlFbIosaArYJBD2+s=
|
||||
query-string@^6.13.2:
|
||||
version "6.13.2"
|
||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.2.tgz#3585aa9412c957cbd358fd5eaca7466f05586dda"
|
||||
integrity sha512-BMmDaUiLDFU1hlM38jTFcRt7HYiGP/zt1sRzrIWm5zpeEuO1rkbPS0ELI3uehoLuuhHDCS8u8lhFN3fEN4JzPQ==
|
||||
dependencies:
|
||||
object-assign "^4.1.0"
|
||||
strict-uri-encode "^1.0.0"
|
||||
decode-uri-component "^0.2.0"
|
||||
split-on-first "^1.0.0"
|
||||
strict-uri-encode "^2.0.0"
|
||||
|
||||
querystring-es3@^0.2.0:
|
||||
version "0.2.1"
|
||||
|
@ -26594,6 +26603,11 @@ spdy@^4.0.2:
|
|||
select-hose "^2.0.0"
|
||||
spdy-transport "^3.0.0"
|
||||
|
||||
split-on-first@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f"
|
||||
integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==
|
||||
|
||||
split-string@^3.0.1, split-string@^3.0.2:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
|
||||
|
@ -26863,6 +26877,11 @@ strict-uri-encode@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
|
||||
integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=
|
||||
|
||||
strict-uri-encode@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
|
||||
integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY=
|
||||
|
||||
string-length@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/string-length/-/string-length-1.0.1.tgz#56970fb1c38558e9e70b728bf3de269ac45adfac"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue