Fix import UI to not fail silently when a record other than index-pattern and search is missing (#33080) (#34442)

* Fix import UI to not fail silently when a record other than index-pattern and search is missing

* Reduce code for error handler
This commit is contained in:
Mike Côté 2019-04-11 18:58:23 -04:00 committed by GitHub
parent b7ce1cf8b1
commit 405fbd3142
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -236,17 +236,12 @@ export async function resolveSavedObjects(savedObjects, overwriteAll, services,
importedObjectCount++;
}
} catch (error) {
if (error instanceof SavedObjectNotFound) {
if (error.savedObjectType === 'search') {
failedImports.push({ obj, error });
}
if (error.savedObjectType === 'index-pattern') {
if (obj.savedSearchId) {
conflictedSavedObjectsLinkedToSavedSearches.push(obj);
} else {
conflictedIndexPatterns.push({ obj, doc: otherDoc });
}
}
const isIndexPatternNotFound = error instanceof SavedObjectNotFound &&
error.savedObjectType === 'index-pattern';
if (isIndexPatternNotFound && obj.savedSearchId) {
conflictedSavedObjectsLinkedToSavedSearches.push(obj);
} else if (isIndexPatternNotFound) {
conflictedIndexPatterns.push({ obj, doc: otherDoc });
} else {
failedImports.push({ obj, error });
}