mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
parent
87d1018517
commit
8be5e991fd
4 changed files with 13 additions and 3 deletions
|
@ -8,7 +8,7 @@
|
|||
import _ from 'lodash';
|
||||
import { DatasourceDimensionDropProps } from '../../types';
|
||||
import { OperationType } from '../indexpattern';
|
||||
import { getAvailableOperationsByMetadata } from '../operations';
|
||||
import { memoizedGetAvailableOperationsByMetadata } from '../operations';
|
||||
import { IndexPatternPrivateState } from '../types';
|
||||
|
||||
export interface OperationSupportMatrix {
|
||||
|
@ -30,7 +30,7 @@ export const getOperationSupportMatrix = (props: Props): OperationSupportMatrix
|
|||
const layerId = props.layerId;
|
||||
const currentIndexPattern = props.state.indexPatterns[props.state.layers[layerId].indexPatternId];
|
||||
|
||||
const filteredOperationsByMetadata = getAvailableOperationsByMetadata(
|
||||
const filteredOperationsByMetadata = memoizedGetAvailableOperationsByMetadata(
|
||||
currentIndexPattern
|
||||
).filter((operation) => props.filterOperations(operation.operationMetaData));
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import { VisualizeFieldContext } from '../../../../../src/plugins/ui_actions/pub
|
|||
import { documentField } from './document_field';
|
||||
import { readFromStorage, writeToStorage } from '../settings_storage';
|
||||
import { getFieldByNameFactory } from './pure_helpers';
|
||||
import { memoizedGetAvailableOperationsByMetadata } from './operations';
|
||||
|
||||
type SetState = StateSetter<IndexPatternPrivateState>;
|
||||
type SavedObjectsClient = Pick<SavedObjectsClientContract, 'find'>;
|
||||
|
@ -50,6 +51,12 @@ export async function loadIndexPatterns({
|
|||
}
|
||||
|
||||
const indexPatterns = await Promise.all(missingIds.map((id) => indexPatternsService.get(id)));
|
||||
|
||||
if (memoizedGetAvailableOperationsByMetadata.cache.clear) {
|
||||
// clear operations meta data cache because index pattern reference may change
|
||||
memoizedGetAvailableOperationsByMetadata.cache.clear();
|
||||
}
|
||||
|
||||
const indexPatternsObject = indexPatterns.reduce(
|
||||
(acc, indexPattern) => {
|
||||
const newFields = indexPattern.fields
|
||||
|
|
|
@ -19,6 +19,7 @@ jest.spyOn(actualHelpers, 'getErrorMessages');
|
|||
|
||||
export const {
|
||||
getAvailableOperationsByMetadata,
|
||||
memoizedGetAvailableOperationsByMetadata,
|
||||
getOperations,
|
||||
getOperationDisplay,
|
||||
getOperationTypesForField,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { memoize } from 'lodash';
|
||||
import { OperationMetadata } from '../../types';
|
||||
import {
|
||||
operationDefinitionMap,
|
||||
|
@ -187,3 +187,5 @@ export function getAvailableOperationsByMetadata(indexPattern: IndexPattern) {
|
|||
|
||||
return Object.values(operationByMetadata);
|
||||
}
|
||||
|
||||
export const memoizedGetAvailableOperationsByMetadata = memoize(getAvailableOperationsByMetadata);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue