Show warning when importing a missing type (#10521)

* show warning when importing a missing type

* remove template string concatenation
This commit is contained in:
Joe Fleming 2017-02-23 10:36:03 -07:00 committed by Joe Fleming
parent 61365e802e
commit eb9fb9231d

View file

@ -164,8 +164,20 @@ uiModules.get('apps/management')
notify.error('The file could not be processed.');
}
return Promise.map(docs, function (doc) {
const service = find($scope.services, { type: doc._type }).service;
return Promise.map(docs, (doc) => {
const { service } = find($scope.services, { type: doc._type }) || {};
if (!service) {
const msg = `Skipped import of "${doc._source.title}" (${doc._id})`;
const reason = `Invalid type: "${doc._type}"`;
notify.warning(`${msg}, ${reason}`, {
lifetime: 0,
});
return;
}
return service.get().then(function (obj) {
obj.id = doc._id;
return obj.applyESResp(doc).then(function () {
@ -174,7 +186,8 @@ uiModules.get('apps/management')
});
})
.then(refreshIndex)
.then(refreshData, notify.error);
.then(refreshData)
.catch(notify.error);
};
function refreshIndex() {