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

[ui/utils/query_string]: Remove unused methods & migrate apps to querystring lib #56957

Merged
merged 35 commits into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e0a0769
replace querystring (querystring-browser) -> query-string
alexwizp Feb 6, 2020
9e46ff9
QueryString remove encode/decode methods
alexwizp Feb 6, 2020
94fca78
remove query_string file
alexwizp Feb 6, 2020
f045669
remove querystring-browser from package.json
alexwizp Feb 6, 2020
afdf8ca
add kibana_utils\url module
alexwizp Feb 7, 2020
d673105
cleanup
alexwizp Feb 7, 2020
38abc36
update notice.txt
alexwizp Feb 7, 2020
d97d3a1
Merge remote-tracking branch 'upstream/master' into 56704
alexwizp Feb 7, 2020
466eddc
Merge branch 'master' into 56704
elasticmachine Feb 8, 2020
89aab80
Merge branch 'master' into 56704
elasticmachine Feb 9, 2020
261c76d
fix merge conflict
alexwizp Feb 9, 2020
2e81904
Merge remote-tracking branch 'upstream/master' into 56704
alexwizp Feb 10, 2020
b6a12a7
fix CI
alexwizp Feb 10, 2020
f1f14b9
Merge branch 'master' into 56704
elasticmachine Feb 10, 2020
d76a8e1
Merge branch 'master' into 56704
elasticmachine Feb 10, 2020
1b37328
fix wrong import
alexwizp Feb 10, 2020
bc7d360
fix CI
alexwizp Feb 10, 2020
6900b4d
Merge remote-tracking branch 'upstream/master' into 56704
alexwizp Feb 10, 2020
b5d6294
fix X-Pack firefox smoke test
alexwizp Feb 10, 2020
b2c1f1c
Merge remote-tracking branch 'upstream/master' into 56704
alexwizp Feb 10, 2020
7c1d1f2
remove urlUtils.parseUrlQuery
alexwizp Feb 11, 2020
b93b7bd
Merge remote-tracking branch 'upstream/master' into 56704-2
alexwizp Feb 11, 2020
46f6a48
remove url.stringifyUrlQuery
alexwizp Feb 11, 2020
8982bbd
Merge remote-tracking branch 'upstream/master' into 56704-2
alexwizp Feb 11, 2020
65aaa78
use url.encodeQuery
alexwizp Feb 11, 2020
5fef5a6
Merge remote-tracking branch 'upstream/master' into 56704
alexwizp Feb 11, 2020
c4dd31c
Merge branch 'master' into 56704
elasticmachine Feb 11, 2020
b272357
Record<string, any> -> ParsedQuery
alexwizp Feb 11, 2020
fc49fee
Merge remote-tracking branch 'upstream/master' into 56704
alexwizp Feb 11, 2020
293a121
Update src/plugins/console/public/application/containers/editor/legac…
alexwizp Feb 11, 2020
2cfb68b
Merge branch 'master' into 56704
elasticmachine Feb 12, 2020
b3c48e0
Merge branch 'master' into 56704
elasticmachine Feb 12, 2020
cc02970
Merge remote-tracking branch 'upstream/master' into 56704
alexwizp Feb 12, 2020
1211d3d
add more tests for APM
alexwizp Feb 12, 2020
76ec6dd
Merge remote-tracking branch 'upstream/master' into 56704
alexwizp Feb 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,7 @@ module.exports = {
settings: {
// instructs import/no-extraneous-dependencies to treat certain modules
// as core modules, even if they aren't listed in package.json
'import/core-modules': [
'plugins',
'legacy/ui',
'uiExports',
// TODO: Remove once https://github.com/benmosher/eslint-plugin-import/issues/1374 is fixed
'querystring',
],
'import/core-modules': ['plugins', 'legacy/ui', 'uiExports'],

'import/resolver': {
'@kbn/eslint-import-resolver-kibana': {
Expand Down
25 changes: 0 additions & 25 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,28 +218,3 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

---
This product includes code that was extracted from angular@1.3.
Original license:
The MIT License

Copyright (c) 2010-2014 Google, Inc. http://angularjs.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
"prop-types": "15.6.0",
"proxy-from-env": "1.0.0",
"pug": "^2.0.4",
"querystring-browser": "1.0.4",
"query-string": "6.10.1",
"raw-loader": "3.1.0",
"react": "^16.12.0",
"react-color": "^2.13.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ exports.getWebpackConfig = function(kibanaPath, projectRoot, config) {
// Kibana defaults https://github.com/elastic/kibana/blob/6998f074542e8c7b32955db159d15661aca253d7/src/legacy/ui/ui_bundler_env.js#L30-L36
ui: fromKibana('src/legacy/ui/public'),
test_harness: fromKibana('src/test_harness/public'),
querystring: 'querystring-browser',

// Dev defaults for test bundle https://github.com/elastic/kibana/blob/6998f074542e8c7b32955db159d15661aca253d7/src/core_plugins/tests_bundle/index.js#L73-L78
ng_mock$: fromKibana('src/test_utils/public/ng_mock'),
Expand Down
6 changes: 3 additions & 3 deletions src/core/server/http/http_server.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import { Request } from 'hapi';
import { merge } from 'lodash';
import { Socket } from 'net';

import querystring from 'querystring';
import { stringify } from 'query-string';

import { schema } from '@kbn/config-schema';

Expand Down Expand Up @@ -55,7 +54,8 @@ function createKibanaRequestMock({
socket = new Socket(),
routeTags,
}: RequestFixtureOptions = {}) {
const queryString = querystring.stringify(query);
const queryString = stringify(query, { sort: false });

return KibanaRequest.from(
createRawRequestMock({
headers,
Expand Down
5 changes: 2 additions & 3 deletions src/core/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

import { ParsedUrlQuery } from 'querystring';
import { ParsedQuery } from 'query-string';
import { format as formatUrl, parse as parseUrl, UrlObject } from 'url';

/**
Expand All @@ -33,7 +32,7 @@ export interface URLMeaningfulParts {
protocol?: string | null;
slashes?: boolean | null;
port?: string | null;
query: ParsedUrlQuery;
query: ParsedQuery;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/server/logging/log_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import Stream from 'stream';
import moment from 'moment-timezone';
import { get, _ } from 'lodash';
import queryString from 'query-string';
import numeral from '@elastic/numeral';
import chalk from 'chalk';
import stringify from 'json-stringify-safe';
import querystring from 'querystring';
import applyFiltersToKeys from './apply_filters_to_keys';
import { inspect } from 'util';
import { logWithMetadata } from './log_with_metadata';
Expand Down Expand Up @@ -108,7 +108,7 @@ export default class TransformObjStream extends Stream.Transform {
contentLength: contentLength,
};

const query = querystring.stringify(event.query);
const query = queryString.stringify(event.query, { sort: false });
if (query) data.req.url += '?' + query;

data.message = data.req.method.toUpperCase() + ' ';
Expand Down
5 changes: 0 additions & 5 deletions src/legacy/ui/public/state_management/global_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import { QueryString } from '../utils/query_string';
import { StateProvider } from './state';
import { uiModules } from '../modules';
import { createLegacyClass } from '../utils/legacy_class';
Expand All @@ -35,10 +34,6 @@ export function GlobalStateProvider(Private) {
// if the url param is missing, write it back
GlobalState.prototype._persistAcrossApps = true;

GlobalState.prototype.removeFromUrl = function(url) {
return QueryString.replaceParamInUrl(url, this._urlParam, null);
};

return new GlobalState();
}

Expand Down
129 changes: 0 additions & 129 deletions src/legacy/ui/public/utils/query_string.js

This file was deleted.

1 change: 0 additions & 1 deletion src/legacy/ui/ui_exports/ui_export_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const UI_EXPORT_DEFAULTS = {
ui: resolve(ROOT, 'src/legacy/ui/public'),
__kibanaCore__$: resolve(ROOT, 'src/core/public'),
test_harness: resolve(ROOT, 'src/test_harness/public'),
querystring: 'querystring-browser',
moment$: resolve(ROOT, 'webpackShims/moment'),
'moment-timezone$': resolve(ROOT, 'webpackShims/moment-timezone'),
},
Expand Down
1 change: 0 additions & 1 deletion src/legacy/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export { BinderBase } from './binder';
export { BinderFor } from './binder_for';
export { deepCloneWithBuffers } from './deep_clone_with_buffers';
export { unset } from './unset';
export { encodeQueryComponent } from './encode_query_component';
export { watchStdioForLine } from './watch_stdio_for_line';
export { IS_KIBANA_DISTRIBUTABLE } from './artifact_type';
export { IS_KIBANA_RELEASE } from './artifact_type';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ import React, { CSSProperties, useCallback, useEffect, useRef, useState } from '
import { EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { debounce } from 'lodash';

// Node v5 querystring for browser.
// @ts-ignore
import * as qs from 'querystring-browser';

import { parse } from 'query-string';
import { EuiIcon, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { useServicesContext, useEditorReadContext } from '../../../../contexts';
import { useUIAceKeyboardMode } from '../use_ui_ace_keyboard_mode';
Expand All @@ -51,6 +47,10 @@ export interface EditorProps {
initialTextValue: string;
}

interface QueryParams {
load_from: string;
}

const abs: CSSProperties = {
position: 'absolute',
top: '0',
Expand Down Expand Up @@ -98,7 +98,8 @@ function EditorUI({ initialTextValue }: EditorProps) {

const readQueryParams = () => {
const [, queryString] = (window.location.hash || '').split('?');
return qs.parse(queryString || '');

return parse(queryString || '', { sort: false }) as Required<QueryParams>;
};

const loadBufferFromRemote = (url: string) => {
Expand Down Expand Up @@ -138,6 +139,7 @@ function EditorUI({ initialTextValue }: EditorProps) {
window.addEventListener('hashchange', onHashChange);

const initialQueryParams = readQueryParams();

if (initialQueryParams.load_from) {
loadBufferFromRemote(initialQueryParams.load_from);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/console/public/lib/es/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import { stringify as formatQueryString } from 'querystring';
import $ from 'jquery';
import { stringify } from 'query-string';

const esVersion: string[] = [];

Expand All @@ -35,7 +35,7 @@ export function send(method: string, path: string, data: any) {
const wrappedDfd = $.Deferred(); // eslint-disable-line new-cap

const options: JQuery.AjaxSettings = {
url: '../api/console/proxy?' + formatQueryString({ path, method }),
url: '../api/console/proxy?' + stringify({ path, method }, { sort: false }),
data,
contentType: getContentType(data),
cache: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

import qs from 'querystring';
import { parse } from 'query-string';

export function parseQueryString() {
// window.location.search is an empty string
Expand All @@ -27,5 +26,5 @@ export function parseQueryString() {
return {};
}

return qs.parse(hrefSplit[1]);
return parse(hrefSplit[1], { sort: false });
}
1 change: 1 addition & 0 deletions src/plugins/kibana_utils/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export * from './state_containers';
export * from './typed_json';
export { createGetterSetter, Get, Set } from './create_getter_setter';
export { distinctUntilChangedWithInitialValue } from './distinct_until_changed_with_initial_value';
export { url } from './url';
Loading