2019-10-14 18:46:33 +02:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
|
|
*/
|
|
|
|
|
2020-11-10 14:31:04 +01:00
|
|
|
import { keyBy } from 'lodash';
|
|
|
|
import { IndexPatternField, IndexPatternPrivateState } from './types';
|
2019-10-14 18:46:33 +02:00
|
|
|
|
|
|
|
export function fieldExists(
|
|
|
|
existingFields: IndexPatternPrivateState['existingFields'],
|
|
|
|
indexPatternTitle: string,
|
|
|
|
fieldName: string
|
|
|
|
) {
|
|
|
|
return existingFields[indexPatternTitle] && existingFields[indexPatternTitle][fieldName];
|
|
|
|
}
|
2020-11-10 14:31:04 +01:00
|
|
|
|
|
|
|
export function getFieldByNameFactory(newFields: IndexPatternField[]) {
|
|
|
|
const fieldsLookup = keyBy(newFields, 'name');
|
|
|
|
return (name: string) => fieldsLookup[name];
|
|
|
|
}
|