diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/sections/edit_policy/components/policy_json_flyout.js b/x-pack/legacy/plugins/index_lifecycle_management/public/sections/edit_policy/components/policy_json_flyout.js index 76e5e85c9b66c..8ce3d9f2552de 100644 --- a/x-pack/legacy/plugins/index_lifecycle_management/public/sections/edit_policy/components/policy_json_flyout.js +++ b/x-pack/legacy/plugins/index_lifecycle_management/public/sections/edit_policy/components/policy_json_flyout.js @@ -5,18 +5,13 @@ */ import React, { PureComponent } from 'react'; -import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import PropTypes from 'prop-types'; -import { toastNotifications } from 'ui/notify'; import { - EuiButton, - EuiCodeEditor, - EuiCopy, + EuiCodeBlock, EuiFlyout, EuiFlyoutBody, - EuiFlyoutFooter, EuiFlyoutHeader, EuiPortal, EuiSpacer, @@ -40,8 +35,8 @@ export class PolicyJsonFlyout extends PureComponent { render() { const { lifecycle, close, policyName } = this.props; - const endpoint = `PUT _ilm/policy/${policyName || '{policyName}'}\n`; - const request = `${endpoint}${this.getEsJson(lifecycle)}`; + const endpoint = `PUT _ilm/policy/${policyName || ''}`; + const request = `${endpoint}\n${this.getEsJson(lifecycle)}`; return ( @@ -70,47 +65,20 @@ export class PolicyJsonFlyout extends PureComponent {

- + + {request} + - - - - {copy => ( - { - copy(); - toastNotifications.add(i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.policyJsonFlyout.copiedToClipboardMessage', - { - defaultMessage: 'Request copied to clipboard' - } - )); - }} - > - - - )} - -
); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js index f95fe0d8303ba..eab731530ea72 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js +++ b/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js @@ -93,12 +93,12 @@ describe('Create Rollup Job, step 6: Review', () => { .simulate('click'); }; - it('should have a "Summary" & "JSON" tabs to review the Job', async () => { + it('should have a "Summary" & "Request" tabs to review the Job', async () => { await goToStep(6); - expect(getTabsText()).toEqual(['Summary', 'JSON']); + expect(getTabsText()).toEqual(['Summary', 'Request']); }); - it('should have a "Summary", "Terms" & "JSON" tab if a term aggregation was added', async () => { + it('should have a "Summary", "Terms" & "Request" tab if a term aggregation was added', async () => { httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields: ['my-field'] }); await goToStep(3); selectFirstField('Terms'); @@ -107,10 +107,10 @@ describe('Create Rollup Job, step 6: Review', () => { actions.clickNextStep(); // go to step 5 actions.clickNextStep(); // go to review - expect(getTabsText()).toEqual(['Summary', 'Terms', 'JSON']); + expect(getTabsText()).toEqual(['Summary', 'Terms', 'Request']); }); - it('should have a "Summary", "Histogram" & "JSON" tab if a histogram field was added', async () => { + it('should have a "Summary", "Histogram" & "Request" tab if a histogram field was added', async () => { httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields: ['a-field'] }); await goToStep(4); selectFirstField('Histogram'); @@ -119,10 +119,10 @@ describe('Create Rollup Job, step 6: Review', () => { actions.clickNextStep(); // go to step 5 actions.clickNextStep(); // go to review - expect(getTabsText()).toEqual(['Summary', 'Histogram', 'JSON']); + expect(getTabsText()).toEqual(['Summary', 'Histogram', 'Request']); }); - it('should have a "Summary", "Metrics" & "JSON" tab if a histogram field was added', async () => { + it('should have a "Summary", "Metrics" & "Request" tab if a histogram field was added', async () => { httpRequestsMockHelpers.setIndexPatternValidityResponse({ numericFields: ['a-field'], dateFields: ['b-field'] }); await goToStep(5); selectFirstField('Metrics'); @@ -130,7 +130,7 @@ describe('Create Rollup Job, step 6: Review', () => { actions.clickNextStep(); // go to review - expect(getTabsText()).toEqual(['Summary', 'Metrics', 'JSON']); + expect(getTabsText()).toEqual(['Summary', 'Metrics', 'Request']); }); }); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/index.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/index.js index 2dd9533a23817..d427eeed4a7a8 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/index.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/index.js @@ -15,6 +15,7 @@ export { JOB_DETAILS_TAB_HISTOGRAM, JOB_DETAILS_TAB_METRICS, JOB_DETAILS_TAB_JSON, + JOB_DETAILS_TAB_REQUEST, tabToHumanizedMap, } from './job_details'; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/index.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/index.js index a860284e6d010..16267181dd720 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/index.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/index.js @@ -11,5 +11,6 @@ export { JOB_DETAILS_TAB_HISTOGRAM, JOB_DETAILS_TAB_METRICS, JOB_DETAILS_TAB_JSON, + JOB_DETAILS_TAB_REQUEST, tabToHumanizedMap, } from './job_details'; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/job_details.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/job_details.js index 1d5afc6942aa9..c83cad15dc266 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/job_details.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/job_details.js @@ -14,6 +14,7 @@ import { TabMetrics, TabJson, TabHistogram, + TabRequest, } from './tabs'; export const JOB_DETAILS_TAB_SUMMARY = 'JOB_DETAILS_TAB_SUMMARY'; @@ -21,6 +22,7 @@ export const JOB_DETAILS_TAB_TERMS = 'JOB_DETAILS_TAB_TERMS'; export const JOB_DETAILS_TAB_HISTOGRAM = 'JOB_DETAILS_TAB_HISTOGRAM'; export const JOB_DETAILS_TAB_METRICS = 'JOB_DETAILS_TAB_METRICS'; export const JOB_DETAILS_TAB_JSON = 'JOB_DETAILS_TAB_JSON'; +export const JOB_DETAILS_TAB_REQUEST = 'JOB_DETAILS_TAB_REQUEST'; export const tabToHumanizedMap = { [JOB_DETAILS_TAB_SUMMARY]: ( @@ -53,6 +55,12 @@ export const tabToHumanizedMap = { defaultMessage="JSON" /> ), + [JOB_DETAILS_TAB_REQUEST]: ( + + ), }; const JOB_DETAILS_TABS = [ @@ -61,6 +69,7 @@ const JOB_DETAILS_TABS = [ JOB_DETAILS_TAB_HISTOGRAM, JOB_DETAILS_TAB_METRICS, JOB_DETAILS_TAB_JSON, + JOB_DETAILS_TAB_REQUEST, ]; export const JobDetails = ({ @@ -68,6 +77,7 @@ export const JobDetails = ({ job, stats, json, + endpoint, }) => { const { metrics, @@ -95,6 +105,9 @@ export const JobDetails = ({ [JOB_DETAILS_TAB_JSON]: ( ), + [JOB_DETAILS_TAB_REQUEST]: ( + + ), }; return tabToContentMap[tab]; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/index.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/index.js index 425acabd5ec47..672ad67a16b00 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/index.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/index.js @@ -9,3 +9,4 @@ export { TabTerms } from './tab_terms'; export { TabHistogram } from './tab_histogram'; export { TabMetrics } from './tab_metrics'; export { TabJson } from './tab_json'; +export { TabRequest } from './tab_request'; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_json.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_json.js index bee32a44c35a0..8cfcfc0cc872f 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_json.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_json.js @@ -20,7 +20,7 @@ export const TabJson = ({ mode="json" theme="textmate" isReadOnly - setOptions={{ maxLines: Infinity }} + setOptions={{ maxLines: Infinity, useWorker: false }} value={jsonString} editorProps={{ $blockScrolling: Infinity diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_request.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_request.js new file mode 100644 index 0000000000000..897777af0573f --- /dev/null +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_request.js @@ -0,0 +1,43 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { Fragment } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; + +import { + EuiCodeBlock, + EuiSpacer, + EuiText, +} from '@elastic/eui'; + +export const TabRequest = ({ + json, + endpoint, +}) => { + const request = `${endpoint}\n${JSON.stringify(json, null, 2)}`; + + return ( + + +

+ +

+
+ + + + + {request} + +
+ ); +}; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js index 755fc02dcb8c4..213a1938432fc 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js +++ b/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js @@ -18,16 +18,17 @@ import { JOB_DETAILS_TAB_TERMS, JOB_DETAILS_TAB_HISTOGRAM, JOB_DETAILS_TAB_METRICS, - JOB_DETAILS_TAB_JSON, + JOB_DETAILS_TAB_REQUEST, tabToHumanizedMap, } from '../../components'; + const JOB_DETAILS_TABS = [ JOB_DETAILS_TAB_SUMMARY, JOB_DETAILS_TAB_TERMS, JOB_DETAILS_TAB_HISTOGRAM, JOB_DETAILS_TAB_METRICS, - JOB_DETAILS_TAB_JSON, + JOB_DETAILS_TAB_REQUEST, ]; export class StepReviewUi extends Component { @@ -98,6 +99,8 @@ export class StepReviewUi extends Component { const { job } = this.props; const { selectedTab } = this.state; const json = serializeJob(job); + const endpoint = `PUT _rollup/job/${job.id}`; + return ( @@ -113,7 +116,7 @@ export class StepReviewUi extends Component { {this.renderTabs()} - + ); diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 02b39296c7f5c..4d2099babf26e 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -4878,7 +4878,6 @@ "xpack.indexLifecycleMgmt.editPolicy.phaseErrorMessage": "エラーを修正してください", "xpack.indexLifecycleMgmt.editPolicy.phaseWarm.minimumAgeLabel": "ウォームフェーズのタイミング", "xpack.indexLifecycleMgmt.editPolicy.phaseWarm.minimumAgeUnitsAriaLabel": "ウォームフェーズのタイミングの単位", - "xpack.indexLifecycleMgmt.editPolicy.policyJsonFlyout.copiedToClipboardMessage": "JSON がクリップボードにコピーされました", "xpack.indexLifecycleMgmt.editPolicy.policyNameAlreadyUsedError": "このポリシー名は既に使用されています。", "xpack.indexLifecycleMgmt.editPolicy.policyNameContainsCommaError": "ポリシー名にはコンマを使用できません。", "xpack.indexLifecycleMgmt.editPolicy.policyNameContainsSpaceError": "ポリシー名にはスペースを使用できません。", @@ -4965,7 +4964,6 @@ "xpack.indexLifecycleMgmt.nodeAttrDetails.title": "属性 {selectedNodeAttrs} を含むノード", "xpack.indexLifecycleMgmt.noMatch.noPolicicesDescription": "表示するポリシーがありません", "xpack.indexLifecycleMgmt.optionalMessage": " (オプション)", - "xpack.indexLifecycleMgmt.policyJsonFlyout.copyToClipboardButton": "クリップボードにコピー", "xpack.indexLifecycleMgmt.policyTable.actionsButtonText": "アクション", "xpack.indexLifecycleMgmt.policyTable.addLifecyclePolicyToTemplateConfirmModal.cancelButton": "キャンセル", "xpack.indexLifecycleMgmt.policyTable.addLifecyclePolicyToTemplateConfirmModal.chooseTemplateLabel": "インデックステンプレート", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index d7467fb2c8884..23a92de81a128 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -5020,7 +5020,6 @@ "xpack.indexLifecycleMgmt.editPolicy.phaseErrorMessage": "修复错误", "xpack.indexLifecycleMgmt.editPolicy.phaseWarm.minimumAgeLabel": "温阶段计时", "xpack.indexLifecycleMgmt.editPolicy.phaseWarm.minimumAgeUnitsAriaLabel": "温阶段计时单位", - "xpack.indexLifecycleMgmt.editPolicy.policyJsonFlyout.copiedToClipboardMessage": "JSON 已复制到剪贴板", "xpack.indexLifecycleMgmt.editPolicy.policyNameAlreadyUsedError": "该策略名称已被使用。", "xpack.indexLifecycleMgmt.editPolicy.policyNameContainsCommaError": "策略名称不能包含逗号。", "xpack.indexLifecycleMgmt.editPolicy.policyNameContainsSpaceError": "策略名称不能包含空格。", @@ -5107,7 +5106,6 @@ "xpack.indexLifecycleMgmt.nodeAttrDetails.title": "包含属性 {selectedNodeAttrs} 的节点", "xpack.indexLifecycleMgmt.noMatch.noPolicicesDescription": "没有要显示的策略", "xpack.indexLifecycleMgmt.optionalMessage": " (可选)", - "xpack.indexLifecycleMgmt.policyJsonFlyout.copyToClipboardButton": "复制到剪贴板", "xpack.indexLifecycleMgmt.policyTable.actionsButtonText": "操作", "xpack.indexLifecycleMgmt.policyTable.addLifecyclePolicyToTemplateConfirmModal.cancelButton": "取消", "xpack.indexLifecycleMgmt.policyTable.addLifecyclePolicyToTemplateConfirmModal.chooseTemplateLabel": "索引模板",