Skip to content

Commit

Permalink
Finish cleanup and feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers committed Jul 26, 2019
1 parent 3004ab0 commit d7d39e3
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 114 deletions.
26 changes: 0 additions & 26 deletions src/legacy/core_plugins/data/public/index_patterns/static.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

import { IndexPattern } from 'ui/index_patterns';
// @ts-ignore
import { shortenDottedString } from '../../../../../common/utils/shorten_dotted_string';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { SearchBar } from './search_bar';
import { IndexPattern } from 'ui/index_patterns';

jest.mock('../../../../data/public', () => {
return {
Expand Down
4 changes: 4 additions & 0 deletions src/legacy/ui/public/index_patterns/_field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export interface FieldType {
aggregatable?: boolean;
filterable?: boolean;
searchable?: boolean;
sortable?: boolean;
visualizable?: boolean;
readFromDocValues?: boolean;
scripted?: boolean;
parent?: string;
Expand All @@ -64,6 +66,8 @@ export class Field implements FieldType {
aggregatable?: boolean;
filterable?: boolean;
searchable?: boolean;
sortable?: boolean;
visualizable?: boolean;
scripted?: boolean;
parent?: string;
subType?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/index_patterns/_field_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { IndexPattern } from 'ui/index_patterns/_index_pattern';
import { Field, FieldSpec } from './_field';

export class FieldList extends IndexedArray<Field> {
constructor(indexPattern: IndexPattern, specs: FieldSpec[], shortDotsEnable: boolean = false) {
constructor(indexPattern: IndexPattern, specs: FieldSpec[], shortDotsEnable = false) {
super({
index: ['name'],
group: ['type'],
Expand Down
69 changes: 0 additions & 69 deletions src/legacy/ui/public/index_patterns/_get.js

This file was deleted.

12 changes: 1 addition & 11 deletions src/legacy/ui/public/index_patterns/_index_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ export interface StaticIndexPattern {
timeFieldName?: string;
}

export const createIndexPatternMock = (params: Record<string, any>): StaticIndexPattern => {
return {
...params,
id: params.id || 'testIndexPattern',
title: params.title || 'testIndexPattern',
type: params.type,
fields: params.fields || [],
};
};

export class IndexPattern implements StaticIndexPattern {
[key: string]: any;

Expand Down Expand Up @@ -354,7 +344,7 @@ export class IndexPattern implements StaticIndexPattern {
return this.fields.byName[this.timeFieldName];
}

getFieldByName(name: string) {
getFieldByName(name: string): Field | void {
if (!this.fields || !this.fields.byName) return;
return this.fields.byName[name];
}
Expand Down
6 changes: 4 additions & 2 deletions src/legacy/ui/public/index_patterns/_pattern_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
* under the License.
*/

import { IndexPattern } from './index';

export interface PatternCache {
get: (id: string) => any;
set: (id: string, value: any) => any;
get: (id: string) => IndexPattern;
set: (id: string, value: Promise<IndexPattern>) => Promise<IndexPattern>;
clear: (id: string) => void;
clearAll: () => void;
}
Expand Down
10 changes: 5 additions & 5 deletions src/legacy/ui/public/index_patterns/index_patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class IndexPatterns {
this.savedObjectsClient = savedObjectsClient;
}

private async loadSavedObjects() {
private async refreshSavedObjectsCache() {
this.savedObjectsCache = (await this.savedObjectsClient.find({
type: 'index-pattern',
fields: [],
Expand All @@ -51,7 +51,7 @@ export class IndexPatterns {

getIds = async (refresh: boolean) => {
if (!this.savedObjectsCache || refresh) {
await this.loadSavedObjects();
await this.refreshSavedObjectsCache();
}
if (this.savedObjectsCache) {
return this.savedObjectsCache.map(obj => _.get(obj, 'id'));
Expand All @@ -60,7 +60,7 @@ export class IndexPatterns {

getTitles = async (refresh: boolean) => {
if (!this.savedObjectsCache || refresh) {
await this.loadSavedObjects();
await this.refreshSavedObjectsCache();
}
if (this.savedObjectsCache) {
return this.savedObjectsCache.map(obj => _.get(obj, 'attributes.title'));
Expand All @@ -69,7 +69,7 @@ export class IndexPatterns {

getFields = async (fields: string[], refresh: boolean) => {
if (!this.savedObjectsCache || refresh) {
await this.loadSavedObjects();
await this.refreshSavedObjectsCache();
}
if (this.savedObjectsCache) {
return this.savedObjectsCache.map(obj => {
Expand Down Expand Up @@ -105,7 +105,7 @@ export class IndexPatterns {
return cache || indexPatternCache.set(id, this.make(id));
};

make = (id?: string) => {
make = (id?: string): Promise<IndexPattern> => {
return new IndexPattern(
id,
(cfg: any) => this.config.get(cfg),
Expand Down

0 comments on commit d7d39e3

Please sign in to comment.