mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Import saved searches first (#10740)
* import saved searches first * move saved object type grouping into a helper
This commit is contained in:
parent
6587cc178e
commit
6cee4ec8f1
1 changed files with 25 additions and 2 deletions
|
@ -133,7 +133,7 @@ uiModules.get('apps/management')
|
|||
notify.error('The file could not be processed.');
|
||||
}
|
||||
|
||||
return Promise.map(docs, function (doc) {
|
||||
function importDocument(doc) {
|
||||
const { service } = find($scope.services, { type: doc._type }) || {};
|
||||
|
||||
if (!service) {
|
||||
|
@ -153,7 +153,30 @@ uiModules.get('apps/management')
|
|||
return obj.save();
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function groupByType(docs) {
|
||||
const defaultDocTypes = {
|
||||
searches: [],
|
||||
other: [],
|
||||
};
|
||||
|
||||
return docs.reduce((types, doc) => {
|
||||
switch (doc._type) {
|
||||
case 'search':
|
||||
types.searches.push(doc);
|
||||
break;
|
||||
default:
|
||||
types.other.push(doc);
|
||||
}
|
||||
return types;
|
||||
}, defaultDocTypes);
|
||||
}
|
||||
|
||||
const docTypes = groupByType(docs);
|
||||
|
||||
return Promise.map(docTypes.searches, importDocument)
|
||||
.then(() => Promise.map(docTypes.other, importDocument))
|
||||
.then(refreshIndex)
|
||||
.then(refreshData)
|
||||
.catch(notify.error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue