mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Obs ai assistant] - bug bulk import for knowledge base (#205075)
Closes #196096 ## Summary Wrong successful message with error notification pop up on adding a wrong format file under bulk import for knowledge base [#196096](https://github.com/elastic/kibana/issues/196096) --------- Co-authored-by: Søren Louv-Jansen <sorenlouv@gmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
b02c735099
commit
2c97ed3bfe
1 changed files with 8 additions and 4 deletions
|
@ -47,13 +47,18 @@ export function KnowledgeBaseBulkImportFlyout({ onClose }: { onClose: () => void
|
|||
};
|
||||
|
||||
const handleSubmitNewEntryClick = async () => {
|
||||
let entries: Array<Omit<KnowledgeBaseEntry, '@timestamp' | 'title'> & { title: string }> = [];
|
||||
const text = await files[0].text();
|
||||
|
||||
const elements = text.split('\n').filter(Boolean);
|
||||
|
||||
try {
|
||||
entries = elements.map((el) => JSON.parse(el));
|
||||
const entries = elements.map(
|
||||
(el) =>
|
||||
JSON.parse(el) as Omit<KnowledgeBaseEntry, '@timestamp' | 'title'> & {
|
||||
title: string;
|
||||
}
|
||||
);
|
||||
await mutateAsync({ entries });
|
||||
} catch (_) {
|
||||
toasts.addError(
|
||||
new Error(
|
||||
|
@ -74,8 +79,7 @@ export function KnowledgeBaseBulkImportFlyout({ onClose }: { onClose: () => void
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
mutateAsync({ entries }).then(onClose);
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue