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

[Logs UI] Replace dependencies in the infra bundle #91503

Merged
merged 4 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pageLoadAssetSize:
indexLifecycleManagement: 107090
indexManagement: 140608
indexPatternManagement: 28222
infra: 204800
infra: 184320
fleet: 415829
ingestPipelines: 58003
inputControlVis: 172675
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/infra/common/formatters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import Mustache from 'mustache';
import { createBytesFormatter } from './bytes';
import { formatNumber } from './number';
import { formatPercent } from './percent';
Expand Down Expand Up @@ -34,5 +33,5 @@ export const createFormatter = (format: InventoryFormatterType, template: string
}
const fmtFn = FORMATTERS[format];
const value = fmtFn(Number(val));
return Mustache.render(template, { value });
return template.replace(/{{value}}/g, value);
Copy link
Member

Choose a reason for hiding this comment

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

💭 Too bad replaceAll() is not yet available in our node version. It would allow us to avoid constructing a regex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep :( I initially used that but the CI crashed

};
10 changes: 4 additions & 6 deletions x-pack/plugins/infra/public/apps/legacy_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { AppMountParameters } from 'kibana/public';
import React from 'react';
import ReactDOM from 'react-dom';
import { Route, RouteProps, Router, Switch } from 'react-router-dom';
import url from 'url';

// This exists purely to facilitate legacy app/infra URL redirects.
// It will be removed in 8.0.0.
Expand Down Expand Up @@ -79,11 +78,10 @@ const LegacyApp: React.FunctionComponent<{ history: History<unknown> }> = ({ his
nextPath = nextPathParts[0];
nextSearch = nextPathParts[1] ? nextPathParts[1] : undefined;

let nextUrl = url.format({
pathname: `${nextBasePath}/${nextPath}`,
hash: undefined,
search: nextSearch,
});
const builtPathname = `${nextBasePath}/${nextPath}`;
const builtSearch = nextSearch ? `?${nextSearch}` : '';

let nextUrl = `${builtPathname}${builtSearch}`;

nextUrl = nextUrl.replace('//', '/');

Expand Down
11 changes: 5 additions & 6 deletions x-pack/plugins/infra/public/hooks/use_link_props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { useMemo } from 'react';
import { stringify } from 'query-string';
import url from 'url';
import { url as urlUtils } from '../../../../../src/plugins/kibana_utils/public';
import { usePrefixPathWithBasepath } from './use_prefix_path_with_basepath';
import { useKibana } from '../../../../../src/plugins/kibana_react/public';
Expand Down Expand Up @@ -58,11 +57,11 @@ export const useLinkProps = (
}, [pathname, encodedSearch]);

const href = useMemo(() => {
const link = url.format({
pathname,
hash: mergedHash,
search: !hash ? encodedSearch : undefined,
});
const builtPathname = pathname ?? '';
const builtHash = mergedHash ? `#${mergedHash}` : '';
const builtSearch = !hash ? (encodedSearch ? `?${encodedSearch}` : '') : '';

const link = `${builtPathname}${builtSearch}${builtHash}`;

return prefixer(app, link);
}, [mergedHash, hash, encodedSearch, pathname, prefixer, app]);
Expand Down