Skip to content

Commit

Permalink
[NP] Use local helper shortenDottedString for discover (elastic#60271)
Browse files Browse the repository at this point in the history
* Move shortenDottedString into kibana_utils

* Move  helper back to data utils

* Use local helper for discover

* Clean up
  • Loading branch information
sulemanof committed Mar 18, 2020
1 parent bc0c696 commit da0876d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export { wrapInI18nContext } from 'ui/i18n';
import { search } from '../../../../../plugins/data/public';
export const { getRequestInspectorStats, getResponseInspectorStats, tabifyAggResponse } = search;
// @ts-ignore
export { shortenDottedString } from '../../common/utils/shorten_dotted_string';
// @ts-ignore
export { intervalOptions } from 'ui/agg_types';
export { subscribeWithScope } from '../../../../../plugins/kibana_legacy/public';
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import classNames from 'classnames';
import { EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';

import { FieldIcon, FieldIconProps } from '../../../../../../../../../plugins/kibana_react/public';
import { shortenDottedString } from '../../../../kibana_services';
import { shortenDottedString } from '../../../helpers';
import { getFieldTypeName } from './field_type_name';

// property field is provided at discover's field chooser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import { IndexPattern, shortenDottedString } from '../../../../../kibana_services';
import { IndexPattern } from '../../../../../kibana_services';
import { shortenDottedString } from '../../../../helpers';

export type SortOrder = [string, string];
export interface ColumnProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,4 @@
* under the License.
*/

import expect from '@kbn/expect';
import { shortenDottedString } from '../shorten_dotted_string';

describe('shortenDottedString', () => {
it('Convert a dot.notated.string into a short string', () => {
expect(shortenDottedString('dot.notated.string')).to.equal('d.n.string');
});

it('Ignores non-string values', () => {
expect(shortenDottedString(true)).to.equal(true);
expect(shortenDottedString(123)).to.equal(123);
const obj = { key: 'val' };
expect(shortenDottedString(obj)).to.equal(obj);
});
});
export { shortenDottedString } from './shorten_dotted_string';
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,5 @@ const DOT_PREFIX_RE = /(.).+?\./g;
/**
* Convert a dot.notated.string into a short
* version (d.n.string)
*
* @param {string} str - the long string to convert
* @return {string}
*/
export function shortenDottedString(input) {
return typeof input !== 'string' ? input : input.replace(DOT_PREFIX_RE, '$1.');
}
export const shortenDottedString = (input: string) => input.replace(DOT_PREFIX_RE, '$1.');

0 comments on commit da0876d

Please sign in to comment.