Skip to content

Commit

Permalink
[Maps][File upload] Set complete on index pattern creation (#44423) (#…
Browse files Browse the repository at this point in the history
…45229)

* Set complete on index pattern creation

* Set complete on error as well. Pass resp to callback function on timeout error
  • Loading branch information
Aaron Caldwell authored Sep 10, 2019
1 parent 576d4c0 commit 978f153
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
}
Expand All @@ -147,14 +150,17 @@ export class JsonUploadAndParse extends Component {
this.setState({
indexDataResp,
indexedFile: parsedFile,
currentIndexingStage: INDEXING_STAGE.INDEXING_COMPLETE,
});
let indexPatternResp;
if (boolCreateIndexPattern) {
indexPatternResp = await this._createIndexPattern(this.state);
}

// 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,
Expand Down Expand Up @@ -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}
/>
: (
Expand Down

0 comments on commit 978f153

Please sign in to comment.