Skip to content

Commit fc2f57e

Browse files
authored
[NP] Use local helper shortenDottedString for discover (#60271) (#60478)
* Move shortenDottedString into kibana_utils * Move helper back to data utils * Use local helper for discover * Clean up
1 parent bc0c696 commit fc2f57e

File tree

5 files changed

+5
-25
lines changed

5 files changed

+5
-25
lines changed

src/legacy/core_plugins/kibana/public/discover/kibana_services.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ export { wrapInI18nContext } from 'ui/i18n';
5353
import { search } from '../../../../../plugins/data/public';
5454
export const { getRequestInspectorStats, getResponseInspectorStats, tabifyAggResponse } = search;
5555
// @ts-ignore
56-
export { shortenDottedString } from '../../common/utils/shorten_dotted_string';
57-
// @ts-ignore
5856
export { intervalOptions } from 'ui/agg_types';
5957
export { subscribeWithScope } from '../../../../../plugins/kibana_legacy/public';
6058
// @ts-ignore

src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/field_name/field_name.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import classNames from 'classnames';
2121
import { EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';
2222

2323
import { FieldIcon, FieldIconProps } from '../../../../../../../../../plugins/kibana_react/public';
24-
import { shortenDottedString } from '../../../../kibana_services';
24+
import { shortenDottedString } from '../../../helpers';
2525
import { getFieldTypeName } from './field_type_name';
2626

2727
// property field is provided at discover's field chooser

src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/components/table_header/helpers.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import { IndexPattern, shortenDottedString } from '../../../../../kibana_services';
19+
import { IndexPattern } from '../../../../../kibana_services';
20+
import { shortenDottedString } from '../../../../helpers';
2021

2122
export type SortOrder = [string, string];
2223
export interface ColumnProps {

src/legacy/core_plugins/kibana/common/utils/__tests__/shorten_dotted_string.js renamed to src/legacy/core_plugins/kibana/public/discover/np_ready/helpers/index.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,4 @@
1717
* under the License.
1818
*/
1919

20-
import expect from '@kbn/expect';
21-
import { shortenDottedString } from '../shorten_dotted_string';
22-
23-
describe('shortenDottedString', () => {
24-
it('Convert a dot.notated.string into a short string', () => {
25-
expect(shortenDottedString('dot.notated.string')).to.equal('d.n.string');
26-
});
27-
28-
it('Ignores non-string values', () => {
29-
expect(shortenDottedString(true)).to.equal(true);
30-
expect(shortenDottedString(123)).to.equal(123);
31-
const obj = { key: 'val' };
32-
expect(shortenDottedString(obj)).to.equal(obj);
33-
});
34-
});
20+
export { shortenDottedString } from './shorten_dotted_string';

src/legacy/core_plugins/kibana/common/utils/shorten_dotted_string.js renamed to src/legacy/core_plugins/kibana/public/discover/np_ready/helpers/shorten_dotted_string.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,5 @@ const DOT_PREFIX_RE = /(.).+?\./g;
2222
/**
2323
* Convert a dot.notated.string into a short
2424
* version (d.n.string)
25-
*
26-
* @param {string} str - the long string to convert
27-
* @return {string}
2825
*/
29-
export function shortenDottedString(input) {
30-
return typeof input !== 'string' ? input : input.replace(DOT_PREFIX_RE, '$1.');
31-
}
26+
export const shortenDottedString = (input: string) => input.replace(DOT_PREFIX_RE, '$1.');

0 commit comments

Comments
 (0)