Skip to content

Commit

Permalink
Refactor: change helper func to "doMappingsHaveType"
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed Jan 28, 2020
1 parent 0045d0d commit df98c23
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export * from './components/load_mappings';

export { OnUpdateHandler, Types } from './mappings_state';

export { doesMappingsHasType } from './lib';
export { doMappingsHaveType } from './lib';
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const getMappingsDefinitionWithType = (mappings: GenericObject): MappingsWithTyp
return typedMappings;
};

export const doesMappingsHasType = (mappings: GenericObject = {}): boolean =>
export const doMappingsHaveType = (mappings: GenericObject = {}): boolean =>
getMappingsDefinitionWithType(mappings).filter(({ type }) => type !== undefined).length > 0;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { uiMetricService } from './ui_metric';
import { useRequest, sendRequest } from './use_request';
import { httpService } from './http';
import { Template } from '../../../common/types';
import { doesMappingsHasType } from '../components/mappings_editor';
import { doMappingsHaveType } from '../components/mappings_editor';

let httpClient: ng.IHttpService;

Expand Down Expand Up @@ -230,7 +230,7 @@ export function loadIndexTemplate(name: Template['name']) {
}

export async function saveTemplate(template: Template, isClone?: boolean) {
const includeTypeName = doesMappingsHasType(template.mappings);
const includeTypeName = doMappingsHaveType(template.mappings);
const result = await sendRequest({
path: `${API_BASE_PATH}/templates`,
method: 'put',
Expand All @@ -248,7 +248,7 @@ export async function saveTemplate(template: Template, isClone?: boolean) {
}

export async function updateTemplate(template: Template) {
const includeTypeName = doesMappingsHasType(template.mappings);
const includeTypeName = doMappingsHaveType(template.mappings);
const { name } = template;
const result = await sendRequest({
path: `${API_BASE_PATH}/templates/${encodeURIComponent(name)}`,
Expand Down

0 comments on commit df98c23

Please sign in to comment.