From 3bb9dd5e5657e0f4be3dea13c7f55a77881cfa4f Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Tue, 6 Aug 2019 15:31:50 -0700 Subject: [PATCH 1/7] Add API endpoint to Rollup Job JSON summary. --- .../sections/components/job_details/job_details.js | 3 ++- .../sections/components/job_details/tabs/tab_json.js | 10 ++++++++-- .../crud_app/sections/job_create/steps/step_review.js | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) 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..29c6ff3aa242f 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 @@ -68,6 +68,7 @@ export const JobDetails = ({ job, stats, json, + endpoint, }) => { const { metrics, @@ -93,7 +94,7 @@ export const JobDetails = ({ ), [JOB_DETAILS_TAB_JSON]: ( - + ), }; 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..6ad44bc75dbd2 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 @@ -12,15 +12,21 @@ import { export const TabJson = ({ json, + endpoint, }) => { - const jsonString = JSON.stringify(json, null, 2); + let jsonString = JSON.stringify(json, null, 2); + + if (endpoint) { + // Prepend endpoint. + jsonString = `${endpoint}\n${jsonString}`; + } return ( @@ -113,7 +115,7 @@ export class StepReviewUi extends Component { {this.renderTabs()} - + ); From 122d6124ae3de48baf31ded44ce518472028cf34 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 7 Aug 2019 15:23:39 -0700 Subject: [PATCH 2/7] Switch to using EuiCodeBlock, add description text, and make request copyable. --- .../crud_app/sections/components/index.js | 1 + .../sections/components/job_details/index.js | 1 + .../components/job_details/job_details.js | 14 +++++- .../components/job_details/tabs/index.js | 1 + .../components/job_details/tabs/tab_json.js | 8 +--- .../job_details/tabs/tab_request.js | 43 +++++++++++++++++++ .../sections/job_create/steps/step_review.js | 24 +++++------ 7 files changed, 72 insertions(+), 20 deletions(-) create mode 100644 x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_request.js 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 29c6ff3aa242f..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 = ({ @@ -94,7 +103,10 @@ export const JobDetails = ({ ), [JOB_DETAILS_TAB_JSON]: ( - + + ), + [JOB_DETAILS_TAB_REQUEST]: ( + ), }; 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 6ad44bc75dbd2..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 @@ -12,14 +12,8 @@ import { export const TabJson = ({ json, - endpoint, }) => { - let jsonString = JSON.stringify(json, null, 2); - - if (endpoint) { - // Prepend endpoint. - jsonString = `${endpoint}\n${jsonString}`; - } + const jsonString = JSON.stringify(json, null, 2); return ( { + 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 ac6121772de21..888d3ab9f07ca 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,18 +18,10 @@ 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, -]; - export class StepReviewUi extends Component { static propTypes = { job: PropTypes.object.isRequired, @@ -38,8 +30,16 @@ export class StepReviewUi extends Component { constructor(props) { super(props); + this.JOB_DETAILS_TABS = [ + JOB_DETAILS_TAB_SUMMARY, + JOB_DETAILS_TAB_TERMS, + JOB_DETAILS_TAB_HISTOGRAM, + JOB_DETAILS_TAB_METRICS, + JOB_DETAILS_TAB_REQUEST, + ]; + this.state = { - selectedTab: JOB_DETAILS_TABS[0], + selectedTab: this.JOB_DETAILS_TABS[0], }; } @@ -55,7 +55,7 @@ export class StepReviewUi extends Component { const renderedTabs = []; - JOB_DETAILS_TABS.forEach((tab, index) => { + this.JOB_DETAILS_TABS.forEach((tab, index) => { if (tab === JOB_DETAILS_TAB_TERMS && !job.terms.length) { return; } @@ -115,7 +115,7 @@ export class StepReviewUi extends Component { {this.renderTabs()} - + ); From 278038408efde4bbec727a151a17c2befaf33297 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 7 Aug 2019 15:30:37 -0700 Subject: [PATCH 3/7] Align ILM request flyout. --- .../components/policy_json_flyout.js | 48 ++++--------------- 1 file changed, 8 insertions(+), 40 deletions(-) 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..d74cb4ba3b335 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, @@ -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' - } - )); - }} - > - - - )} - - ); From 7f4f7ab379029c3783e92669b3734c6bf3b51da1 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 7 Aug 2019 15:33:39 -0700 Subject: [PATCH 4/7] Revert unnecessary change. --- .../sections/job_create/steps/step_review.js | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) 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 888d3ab9f07ca..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 @@ -22,6 +22,15 @@ import { 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_REQUEST, +]; + export class StepReviewUi extends Component { static propTypes = { job: PropTypes.object.isRequired, @@ -30,16 +39,8 @@ export class StepReviewUi extends Component { constructor(props) { super(props); - this.JOB_DETAILS_TABS = [ - JOB_DETAILS_TAB_SUMMARY, - JOB_DETAILS_TAB_TERMS, - JOB_DETAILS_TAB_HISTOGRAM, - JOB_DETAILS_TAB_METRICS, - JOB_DETAILS_TAB_REQUEST, - ]; - this.state = { - selectedTab: this.JOB_DETAILS_TABS[0], + selectedTab: JOB_DETAILS_TABS[0], }; } @@ -55,7 +56,7 @@ export class StepReviewUi extends Component { const renderedTabs = []; - this.JOB_DETAILS_TABS.forEach((tab, index) => { + JOB_DETAILS_TABS.forEach((tab, index) => { if (tab === JOB_DETAILS_TAB_TERMS && !job.terms.length) { return; } From 875b4de1234cf0d8931aa26e536a6a4b86af524e Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 7 Aug 2019 16:29:25 -0700 Subject: [PATCH 5/7] Remove unused translations. --- x-pack/plugins/translations/translations/ja-JP.json | 2 -- x-pack/plugins/translations/translations/zh-CN.json | 2 -- 2 files changed, 4 deletions(-) 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": "索引模板", From 19796301a4ecc5777ee2e8de9b459307baeb0e20 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 7 Aug 2019 16:40:25 -0700 Subject: [PATCH 6/7] Fix tests. --- .../client_integration/job_create_review.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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']); }); }); From 9d08575a3af8a8e2f4aba35551a10dc6d1cf097a Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 7 Aug 2019 17:39:24 -0700 Subject: [PATCH 7/7] Update ILM endpoint format. --- .../sections/edit_policy/components/policy_json_flyout.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 d74cb4ba3b335..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 @@ -35,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 (