[7.7] [Mappings Editor] Add logic for including type name in e… (#62341)

This commit is contained in:
Jean-Louis Leysens 2020-04-03 10:29:02 +02:00 committed by GitHub
parent 671b444320
commit 4973ddd780
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,6 +24,9 @@ import { serializers } from '../../../../shared_imports';
import { serializeTemplate } from '../../../../../common/lib/template_serialization';
import { Template } from '../../../../../common/types';
import { doMappingsHaveType } from '../../mappings_editor/lib';
import { StepProps } from '../types';
const { stripEmptyFields } = serializers;
@ -159,7 +162,10 @@ export const StepReview: React.FunctionComponent<StepProps> = ({ template, updat
);
const RequestTab = () => {
const endpoint = `PUT _template/${name || '<templateName>'}`;
const includeTypeName = doMappingsHaveType(template.mappings);
const endpoint = `PUT _template/${name || '<templateName>'}${
includeTypeName ? '?include_type_name' : ''
}`;
const templateString = JSON.stringify(serializedTemplate, null, 2);
const request = `${endpoint}\n${templateString}`;