mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
parent
77ab709976
commit
de4eaf9ae7
7 changed files with 22 additions and 15 deletions
|
@ -9,7 +9,7 @@ Constructs a new instance of the `IndexPattern` class
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(id: string | undefined, getConfig: any, savedObjectsClient: SavedObjectsClientContract, apiClient: IIndexPatternsApiClient, patternCache: any);
|
||||
constructor(id: string | undefined, getConfig: any, savedObjectsClient: SavedObjectsClientContract, apiClient: IIndexPatternsApiClient, patternCache: PatternCache);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
@ -20,5 +20,5 @@ constructor(id: string | undefined, getConfig: any, savedObjectsClient: SavedObj
|
|||
| getConfig | <code>any</code> | |
|
||||
| savedObjectsClient | <code>SavedObjectsClientContract</code> | |
|
||||
| apiClient | <code>IIndexPatternsApiClient</code> | |
|
||||
| patternCache | <code>any</code> | |
|
||||
| patternCache | <code>PatternCache</code> | |
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { IndexPattern } from './index_pattern';
|
||||
|
||||
interface PatternCache {
|
||||
export interface PatternCache {
|
||||
get: (id: string) => IndexPattern;
|
||||
set: (id: string, value: IndexPattern) => IndexPattern;
|
||||
clear: (id: string) => void;
|
||||
|
|
|
@ -85,6 +85,9 @@ const savedObjectsClient = {
|
|||
|
||||
const patternCache = {
|
||||
clear: jest.fn(),
|
||||
get: jest.fn(),
|
||||
set: jest.fn(),
|
||||
clearAll: jest.fn(),
|
||||
};
|
||||
|
||||
const config = {
|
||||
|
|
|
@ -44,6 +44,7 @@ import { flattenHitWrapper } from './flatten_hit';
|
|||
import { IIndexPatternsApiClient } from './index_patterns_api_client';
|
||||
import { getNotifications, getFieldFormats } from '../../services';
|
||||
import { TypeMeta } from './types';
|
||||
import { PatternCache } from './_pattern_cache';
|
||||
|
||||
const MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS = 3;
|
||||
const type = 'index-pattern';
|
||||
|
@ -65,12 +66,13 @@ export class IndexPattern implements IIndexPattern {
|
|||
|
||||
private version: string | undefined;
|
||||
private savedObjectsClient: SavedObjectsClientContract;
|
||||
private patternCache: any;
|
||||
private patternCache: PatternCache;
|
||||
private getConfig: any;
|
||||
private sourceFilters?: [];
|
||||
private originalBody: { [key: string]: any } = {};
|
||||
public fieldsFetcher: any; // probably want to factor out any direct usage and change to private
|
||||
private shortDotsEnable: boolean = false;
|
||||
private apiClient: IIndexPatternsApiClient;
|
||||
|
||||
private mapping: MappingObject = expandShorthand({
|
||||
title: ES_FIELD_TYPES.TEXT,
|
||||
|
@ -99,7 +101,7 @@ export class IndexPattern implements IIndexPattern {
|
|||
getConfig: any,
|
||||
savedObjectsClient: SavedObjectsClientContract,
|
||||
apiClient: IIndexPatternsApiClient,
|
||||
patternCache: any
|
||||
patternCache: PatternCache
|
||||
) {
|
||||
this.id = id;
|
||||
this.savedObjectsClient = savedObjectsClient;
|
||||
|
@ -117,6 +119,7 @@ export class IndexPattern implements IIndexPattern {
|
|||
});
|
||||
|
||||
this.fields = this.createFieldList(this, [], this.shortDotsEnable);
|
||||
this.apiClient = apiClient;
|
||||
this.fieldsFetcher = createFieldsFetcher(
|
||||
this,
|
||||
apiClient,
|
||||
|
@ -396,8 +399,8 @@ export class IndexPattern implements IIndexPattern {
|
|||
duplicateId,
|
||||
this.getConfig,
|
||||
this.savedObjectsClient,
|
||||
this.patternCache,
|
||||
this.fieldsFetcher
|
||||
this.apiClient,
|
||||
this.patternCache
|
||||
);
|
||||
await duplicatePattern.destroy();
|
||||
}
|
||||
|
@ -445,8 +448,8 @@ export class IndexPattern implements IIndexPattern {
|
|||
this.id,
|
||||
this.getConfig,
|
||||
this.savedObjectsClient,
|
||||
this.patternCache,
|
||||
this.fieldsFetcher
|
||||
this.apiClient,
|
||||
this.patternCache
|
||||
);
|
||||
return samePattern.init().then(() => {
|
||||
// What keys changed from now and what the server returned
|
||||
|
@ -489,7 +492,7 @@ export class IndexPattern implements IIndexPattern {
|
|||
this.version = samePattern.version;
|
||||
|
||||
// Clear cache
|
||||
this.patternCache.clear(this.id);
|
||||
this.patternCache.clear(this.id!);
|
||||
|
||||
// Try the save again
|
||||
return this.save(saveAttempts);
|
||||
|
@ -545,8 +548,8 @@ export class IndexPattern implements IIndexPattern {
|
|||
}
|
||||
|
||||
destroy() {
|
||||
this.patternCache.clear(this.id);
|
||||
if (this.id) {
|
||||
this.patternCache.clear(this.id);
|
||||
return this.savedObjectsClient.delete(type, this.id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -842,7 +842,8 @@ export type IMetricAggType = MetricAggType;
|
|||
// @public (undocumented)
|
||||
export class IndexPattern implements IIndexPattern {
|
||||
// Warning: (ae-forgotten-export) The symbol "IIndexPatternsApiClient" needs to be exported by the entry point index.d.ts
|
||||
constructor(id: string | undefined, getConfig: any, savedObjectsClient: SavedObjectsClientContract, apiClient: IIndexPatternsApiClient, patternCache: any);
|
||||
// Warning: (ae-forgotten-export) The symbol "PatternCache" needs to be exported by the entry point index.d.ts
|
||||
constructor(id: string | undefined, getConfig: any, savedObjectsClient: SavedObjectsClientContract, apiClient: IIndexPatternsApiClient, patternCache: PatternCache);
|
||||
// (undocumented)
|
||||
[key: string]: any;
|
||||
// (undocumented)
|
||||
|
|
|
@ -27,6 +27,7 @@ import {
|
|||
IIndexPattern,
|
||||
injectSearchSourceReferences,
|
||||
} from '../../../data/public';
|
||||
import { FailedImport } from './process_import_response';
|
||||
|
||||
type SavedObjectsRawDoc = Record<string, any>;
|
||||
|
||||
|
@ -277,7 +278,7 @@ export async function resolveSavedObjects(
|
|||
// Keep track of how many we actually import because the user
|
||||
// can cancel an override
|
||||
let importedObjectCount = 0;
|
||||
const failedImports: any[] = [];
|
||||
const failedImports: FailedImport[] = [];
|
||||
// Start with the index patterns since everything is dependent on them
|
||||
await awaitEachItemInParallel(docTypes.indexPatterns, async (indexPatternDoc) => {
|
||||
try {
|
||||
|
@ -291,7 +292,7 @@ export async function resolveSavedObjects(
|
|||
importedObjectCount++;
|
||||
}
|
||||
} catch (error) {
|
||||
failedImports.push({ indexPatternDoc, error });
|
||||
failedImports.push({ obj: indexPatternDoc as any, error });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -356,7 +356,6 @@ export default function ({ getService, getPageObjects }) {
|
|||
await PageObjects.settings.importFile(
|
||||
path.join(__dirname, 'exports', '_import_objects_with_index_patterns.json')
|
||||
);
|
||||
await PageObjects.settings.checkImportFailedWarning();
|
||||
await PageObjects.settings.clickImportDone();
|
||||
|
||||
const objects = await PageObjects.settings.getSavedObjectsInTable();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue