Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps][File upload] Set complete on index pattern creation #44423

Merged
merged 7 commits into from
Sep 10, 2019
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