Skip to content

Commit

Permalink
Removed anys.
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthkh committed Nov 20, 2019
1 parent 1caebf9 commit 0301e7c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ const indexPatternButtonDescription = i18n.translate(
{ defaultMessage: 'Perform full aggregations against any data' }
);

export type UrlHandler = (url: string) => void;

export interface IndexPatternCreationOption {
text: string;
description: string;
testSubj: string;
onClick: () => void;
isBeta?: boolean;
}

export class IndexPatternCreationConfig {
public readonly key = 'default';

Expand Down Expand Up @@ -63,7 +73,9 @@ export class IndexPatternCreationConfig {
this.isBeta = isBeta;
}

public async getIndexPatternCreationOption(urlHandler: any) {
public async getIndexPatternCreationOption(
urlHandler: UrlHandler
): Promise<IndexPatternCreationOption> {
return {
text: indexPatternButtonText,
description: indexPatternButtonDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { HttpServiceBase } from '../../../../../../../../core/public';
import { IndexPatternCreationConfig } from './config';
import { IndexPatternCreationConfig, UrlHandler, IndexPatternCreationOption } from './config';

export class IndexPatternCreationManager {
private configs: IndexPatternCreationConfig[];
Expand All @@ -37,15 +37,15 @@ export class IndexPatternCreationManager {

public getType(key: string | undefined): IndexPatternCreationConfig | null {
if (key) {
const index = key ? this.configs.findIndex(config => config.key === key) : -1;
return index > -1 && this.configs[index] ? this.configs[index] : null;
const index = this.configs.findIndex(config => config.key === key);
return this.configs[index] || null;
} else {
return this.getType('default');
}
}

public async getIndexPatternCreationOptions(urlHandler: any) {
const options: any[] = [];
public async getIndexPatternCreationOptions(urlHandler: UrlHandler) {
const options: IndexPatternCreationOption[] = [];
await Promise.all(
this.configs.map(async config => {
const option = config.getIndexPatternCreationOption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { i18n } from '@kbn/i18n';
import { StaticIndexPattern, Field } from '../../../../../../data/public';

export interface IndexPatternTag {
key: string;
Expand All @@ -27,7 +28,10 @@ export interface IndexPatternTag {
export class IndexPatternListConfig {
public readonly key = 'default';

public getIndexPatternTags(indexPattern: any, isDefault: boolean): IndexPatternTag[] {
public getIndexPatternTags(
indexPattern: StaticIndexPattern,
isDefault: boolean
): IndexPatternTag[] {
return isDefault
? [
{
Expand All @@ -40,11 +44,11 @@ export class IndexPatternListConfig {
: [];
}

public getFieldInfo(indexPattern: any, field: any): string[] {
public getFieldInfo(indexPattern: StaticIndexPattern, field: Field): string[] {
return [];
}

public areScriptedFieldsEnabled(indexPattern: any): boolean {
public areScriptedFieldsEnabled(indexPattern: StaticIndexPattern): boolean {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { IndexPatternListConfig, IndexPatternTag } from './config';
import { StaticIndexPattern, Field } from '../../../../../../data/public';

export class IndexPatternListManager {
private configs: IndexPatternListConfig[];
Expand All @@ -34,21 +35,21 @@ export class IndexPatternListManager {
this.configs.push(config);
}

public getIndexPatternTags(indexPattern: any, isDefault: boolean) {
public getIndexPatternTags(indexPattern: StaticIndexPattern, isDefault: boolean) {
return this.configs.reduce((tags: IndexPatternTag[], config) => {
return config.getIndexPatternTags
? tags.concat(config.getIndexPatternTags(indexPattern, isDefault))
: tags;
}, []);
}

public getFieldInfo(indexPattern: any, field: any): string[] {
public getFieldInfo(indexPattern: StaticIndexPattern, field: Field): string[] {
return this.configs.reduce((info: string[], config) => {
return config.getFieldInfo ? info.concat(config.getFieldInfo(indexPattern, field)) : info;
}, []);
}

public areScriptedFieldsEnabled(indexPattern: any): boolean {
public areScriptedFieldsEnabled(indexPattern: StaticIndexPattern): boolean {
return this.configs.every(config => {
return config.areScriptedFieldsEnabled ? config.areScriptedFieldsEnabled(indexPattern) : true;
});
Expand Down

0 comments on commit 0301e7c

Please sign in to comment.