From 978f153a88554e61dd819af0b130902bcb399b3a Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Mon, 9 Sep 2019 22:20:25 -0600 Subject: [PATCH] [Maps][File upload] Set complete on index pattern creation (#44423) (#45229) * Set complete on index pattern creation * Set complete on error as well. Pass resp to callback function on timeout error --- .../components/json_upload_and_parse.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/x-pack/legacy/plugins/file_upload/public/components/json_upload_and_parse.js b/x-pack/legacy/plugins/file_upload/public/components/json_upload_and_parse.js index dca8c966deb03..d5f9a21d6454d 100644 --- a/x-pack/legacy/plugins/file_upload/public/components/json_upload_and_parse.js +++ b/x-pack/legacy/plugins/file_upload/public/components/json_upload_and_parse.js @@ -24,13 +24,16 @@ const INDEXING_STAGE = { WRITING_TO_INDEX: i18n.translate( 'xpack.fileUpload.jsonUploadAndParse.writingToIndex', { defaultMessage: 'Writing to index' }), + INDEXING_COMPLETE: i18n.translate( + 'xpack.fileUpload.jsonUploadAndParse.indexingComplete', + { defaultMessage: 'Indexing complete' }), CREATING_INDEX_PATTERN: i18n.translate( 'xpack.fileUpload.jsonUploadAndParse.creatingIndexPattern', { defaultMessage: 'Creating index pattern' }), INDEX_PATTERN_COMPLETE: i18n.translate( 'xpack.fileUpload.jsonUploadAndParse.indexPatternComplete', { defaultMessage: 'Index pattern complete' }), - DATA_INDEXING_ERROR: i18n.translate( + INDEXING_ERROR: i18n.translate( 'xpack.fileUpload.jsonUploadAndParse.dataIndexingError', { defaultMessage: 'Data indexing error' }), INDEX_PATTERN_ERROR: i18n.translate( @@ -134,11 +137,11 @@ export class JsonUploadAndParse extends Component { indexedFile: null, indexDataResp, indexRequestInFlight: false, - currentIndexingStage: INDEXING_STAGE.INDEXING_COMPLETE, + currentIndexingStage: INDEXING_STAGE.INDEXING_ERROR, }); this._resetFileAndIndexSettings(); if (onIndexingComplete) { - onIndexingComplete(); + onIndexingComplete({ indexDataResp }); } return; } @@ -147,6 +150,7 @@ export class JsonUploadAndParse extends Component { this.setState({ indexDataResp, indexedFile: parsedFile, + currentIndexingStage: INDEXING_STAGE.INDEXING_COMPLETE, }); let indexPatternResp; if (boolCreateIndexPattern) { @@ -154,7 +158,9 @@ export class JsonUploadAndParse extends Component { } // Indexing complete, update state & callback (if any) - this.setState({ currentIndexingStage: INDEXING_STAGE.INDEXING_COMPLETE }); + this.setState({ + currentIndexingStage: INDEXING_STAGE.INDEX_PATTERN_COMPLETE + }); if (onIndexingComplete) { onIndexingComplete({ indexDataResp, @@ -221,7 +227,10 @@ export class JsonUploadAndParse extends Component { importStage={currentIndexingStage} indexDataResp={indexDataResp} indexPatternResp={indexPatternResp} - complete={currentIndexingStage === INDEXING_STAGE.INDEXING_COMPLETE} + complete={ + currentIndexingStage === INDEXING_STAGE.INDEX_PATTERN_COMPLETE + || currentIndexingStage === INDEXING_STAGE.INDEXING_ERROR + } indexName={indexName} /> : (