Skip to content

Commit

Permalink
[Logs UI] Replace dependencies in the infra bundle (#91503)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Fernández Gómez authored Feb 19, 2021
1 parent 8b909ce commit 4d34a13
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
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);
};
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

0 comments on commit 4d34a13

Please sign in to comment.