[ML] Transforms: Extend editing and creation options. (#77370)

Extends the available options in the edit transform flyout and the wizard details step.
This commit is contained in:
Walter Rafelsberger 2020-09-21 16:55:40 +02:00 committed by GitHub
parent 4b49e5a1c8
commit 4e7b7bf65f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 933 additions and 321 deletions

View file

@ -8,12 +8,18 @@ import { schema, TypeOf } from '@kbn/config-schema';
import { TransformPivotConfig } from '../types/transform';
import { destSchema, settingsSchema, sourceSchema, syncSchema } from './transforms';
import { settingsSchema, sourceSchema, syncSchema } from './transforms';
// POST _transform/{transform_id}/_update
export const postTransformsUpdateRequestSchema = schema.object({
description: schema.maybe(schema.string()),
dest: schema.maybe(destSchema),
// we cannot reuse `destSchema` because `index` is optional for the update request
dest: schema.maybe(
schema.object({
index: schema.string(),
pipeline: schema.maybe(schema.string()),
})
),
frequency: schema.maybe(schema.string()),
settings: schema.maybe(settingsSchema),
source: schema.maybe(sourceSchema),

View file

@ -17,3 +17,21 @@ export const getNestedProperty = (
return value;
};
export const setNestedProperty = (obj: Record<string, any>, accessor: string, value: any) => {
let ref = obj;
const accessors = accessor.split('.');
const len = accessors.length;
for (let i = 0; i < len - 1; i++) {
const attribute = accessors[i];
if (ref[attribute] === undefined) {
ref[attribute] = {};
}
ref = ref[attribute];
}
ref[accessors[len - 1]] = value;
return obj;
};