Skip to content

Commit 4b29831

Browse files
author
Stacey Gammon
committed
Merge branch 'master' of github.com:elastic/kibana into 2020-02-26-action-types-2
2 parents dcdec80 + 5555a6c commit 4b29831

File tree

25 files changed

+265
-261
lines changed

25 files changed

+265
-261
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
export function MLJobEditor(props: any): any;
8-
export const EDITOR_MODE: any;
7+
export function XJsonMode() {}

x-pack/legacy/plugins/ml/public/application/components/custom_hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
*/
66

77
export { usePartialState } from './use_partial_state';
8+
export { useXJsonMode, xJsonMode } from './use_x_json_mode';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { useState } from 'react';
8+
import {
9+
collapseLiteralStrings,
10+
expandLiteralStrings,
11+
XJsonMode,
12+
} from '../../../../shared_imports';
13+
14+
export const xJsonMode = new XJsonMode();
15+
16+
export const useXJsonMode = (json: string) => {
17+
const [xJson, setXJson] = useState(expandLiteralStrings(json));
18+
19+
return {
20+
xJson,
21+
setXJson,
22+
xJsonMode,
23+
convertToJson: collapseLiteralStrings,
24+
};
25+
};

x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_advanced_editor/create_analytics_advanced_editor.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import {
1717
} from '@elastic/eui';
1818

1919
import { i18n } from '@kbn/i18n';
20+
import { collapseLiteralStrings } from '../../../../../../../../../../../src/plugins/es_ui_shared/console_lang/lib/json_xjson_translation_tools';
2021

2122
import { CreateAnalyticsFormProps } from '../../hooks/use_create_analytics_form';
23+
import { xJsonMode } from '../../../../../components/custom_hooks';
2224

2325
export const CreateAnalyticsAdvancedEditor: FC<CreateAnalyticsFormProps> = ({ actions, state }) => {
2426
const {
@@ -42,7 +44,8 @@ export const CreateAnalyticsAdvancedEditor: FC<CreateAnalyticsFormProps> = ({ ac
4244
const onChange = (str: string) => {
4345
setAdvancedEditorRawString(str);
4446
try {
45-
setJobConfig(JSON.parse(str));
47+
const resultJobConfig = JSON.parse(collapseLiteralStrings(str));
48+
setJobConfig(resultJobConfig);
4649
} catch (e) {
4750
resetAdvancedEditorMessages();
4851
}
@@ -119,7 +122,7 @@ export const CreateAnalyticsAdvancedEditor: FC<CreateAnalyticsFormProps> = ({ ac
119122
style={{ maxWidth: '100%' }}
120123
>
121124
<EuiCodeEditor
122-
mode="json"
125+
mode={xJsonMode}
123126
width="100%"
124127
value={advancedEditorRawString}
125128
onChange={onChange}

x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_button/create_analytics_button.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jest.mock('react', () => {
2929
return { ...r, memo: (x: any) => x };
3030
});
3131

32+
jest.mock('../../../../../../../shared_imports');
33+
3234
describe('Data Frame Analytics: <CreateAnalyticsButton />', () => {
3335
test('Minimal initialization', () => {
3436
const { getLastHookValue } = getMountedHook();

x-pack/legacy/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_flyout/create_analytics_flyout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const CreateAnalyticsFlyout: FC<CreateAnalyticsFormProps> = ({
2929
const { isJobCreated, isJobStarted, isModalButtonDisabled, isValid } = state;
3030

3131
return (
32-
<EuiFlyout size="s" onClose={closeModal} data-test-subj="mlAnalyticsCreateJobFlyout">
32+
<EuiFlyout size="m" onClose={closeModal} data-test-subj="mlAnalyticsCreateJobFlyout">
3333
<EuiFlyoutHeader>
3434
<EuiTitle>
3535
<h2 data-test-subj="mlDataFrameAnalyticsFlyoutHeaderTitle">

x-pack/legacy/plugins/ml/public/application/datavisualizer/file_based/components/file_contents/file_contents.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import React from 'react';
99

1010
import { EuiTitle, EuiSpacer } from '@elastic/eui';
1111

12-
import { MLJobEditor, EDITOR_MODE } from '../../../../jobs/jobs_list/components/ml_job_editor';
12+
import { MLJobEditor, ML_EDITOR_MODE } from '../../../../jobs/jobs_list/components/ml_job_editor';
1313

1414
export function FileContents({ data, format, numberOfLines }) {
15-
let mode = EDITOR_MODE.TEXT;
16-
if (format === EDITOR_MODE.JSON) {
17-
mode = EDITOR_MODE.JSON;
15+
let mode = ML_EDITOR_MODE.TEXT;
16+
if (format === ML_EDITOR_MODE.JSON) {
17+
mode = ML_EDITOR_MODE.JSON;
1818
}
1919

2020
const formattedData = limitByNumberOfLines(data, numberOfLines);

x-pack/legacy/plugins/ml/public/application/datavisualizer/file_based/components/import_settings/advanced.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
EuiFlexItem,
1818
} from '@elastic/eui';
1919

20-
import { MLJobEditor, EDITOR_MODE } from '../../../../jobs/jobs_list/components/ml_job_editor';
20+
import { MLJobEditor, ML_EDITOR_MODE } from '../../../../jobs/jobs_list/components/ml_job_editor';
2121
const EDITOR_HEIGHT = '300px';
2222

2323
export function AdvancedSettings({
@@ -149,7 +149,7 @@ function IndexSettings({ initialized, data, onChange }) {
149149
fullWidth
150150
>
151151
<MLJobEditor
152-
mode={EDITOR_MODE.JSON}
152+
mode={ML_EDITOR_MODE.JSON}
153153
readOnly={initialized === true}
154154
value={data}
155155
height={EDITOR_HEIGHT}
@@ -175,7 +175,7 @@ function Mappings({ initialized, data, onChange }) {
175175
fullWidth
176176
>
177177
<MLJobEditor
178-
mode={EDITOR_MODE.JSON}
178+
mode={ML_EDITOR_MODE.JSON}
179179
readOnly={initialized === true}
180180
value={data}
181181
height={EDITOR_HEIGHT}
@@ -201,7 +201,7 @@ function IngestPipeline({ initialized, data, onChange }) {
201201
fullWidth
202202
>
203203
<MLJobEditor
204-
mode={EDITOR_MODE.JSON}
204+
mode={ML_EDITOR_MODE.JSON}
205205
readOnly={initialized === true}
206206
value={data}
207207
height={EDITOR_HEIGHT}

x-pack/legacy/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_job_flyout.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { mlMessageBarService } from '../../../../components/messagebar';
3030
import { withKibana } from '../../../../../../../../../../src/plugins/kibana_react/public';
3131
import { i18n } from '@kbn/i18n';
3232
import { FormattedMessage } from '@kbn/i18n/react';
33+
import { collapseLiteralStrings } from '../../../../../../shared_imports';
3334

3435
export class EditJobFlyoutUI extends Component {
3536
_initialJobFormState = null;
@@ -225,7 +226,7 @@ export class EditJobFlyoutUI extends Component {
225226
groups: this.state.jobGroups,
226227
mml: this.state.jobModelMemoryLimit,
227228
detectorDescriptions: this.state.jobDetectorDescriptions,
228-
datafeedQuery: this.state.datafeedQuery,
229+
datafeedQuery: collapseLiteralStrings(this.state.datafeedQuery),
229230
datafeedQueryDelay: this.state.datafeedQueryDelay,
230231
datafeedFrequency: this.state.datafeedFrequency,
231232
datafeedScrollSize: this.state.datafeedScrollSize,

x-pack/legacy/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/tabs/datafeed.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { EuiFieldText, EuiForm, EuiFormRow, EuiSpacer, EuiFieldNumber } from '@e
1212
import { calculateDatafeedFrequencyDefaultSeconds } from '../../../../../../../common/util/job_utils';
1313
import { getNewJobDefaults } from '../../../../../services/ml_server_info';
1414
import { parseInterval } from '../../../../../../../common/util/parse_interval';
15-
import { MLJobEditor } from '../../ml_job_editor';
15+
import { MLJobEditor, ML_EDITOR_MODE } from '../../ml_job_editor';
1616
import { FormattedMessage } from '@kbn/i18n/react';
1717

1818
function getDefaults(bucketSpan, jobDefaults) {
@@ -85,7 +85,12 @@ export class Datafeed extends Component {
8585
}
8686
style={{ maxWidth: 'inherit' }}
8787
>
88-
<MLJobEditor value={query} onChange={this.onQueryChange} height="200px" />
88+
<MLJobEditor
89+
mode={ML_EDITOR_MODE.XJSON}
90+
value={query}
91+
onChange={this.onQueryChange}
92+
height="200px"
93+
/>
8994
</EuiFormRow>
9095
<EuiFormRow
9196
label={

0 commit comments

Comments
 (0)