Skip to content

Commit

Permalink
[Security Solution][Bug] Incorrect message as Duplicate entry? shown …
Browse files Browse the repository at this point in the history
…on creating New Knowledge Base index. (#198892)
  • Loading branch information
e40pud committed Nov 5, 2024
1 parent 26f24c6 commit 21dc82f
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,31 @@ export const KnowledgeBaseSettingsManagement: React.FC<Params> = React.memo(({ d
isRefetching: kbStatus?.is_setup_in_progress,
});

const resetStateAndCloseFlyout = useCallback(() => {
setOriginalEntry(undefined);
setSelectedEntry(undefined);
setDuplicateKBItem(null);
closeFlyout();
}, [closeFlyout]);

// Flyout Save/Cancel Actions
const onSaveConfirmed = useCallback(async () => {
if (isKnowledgeBaseEntryResponse(selectedEntry)) {
await updateEntries([selectedEntry]);
closeFlyout();
resetStateAndCloseFlyout();
} else if (isKnowledgeBaseEntryCreateProps(selectedEntry)) {
if (originalEntry) {
setDuplicateKBItem(selectedEntry);
return;
}
await createEntry(selectedEntry);
closeFlyout();
resetStateAndCloseFlyout();
}
}, [selectedEntry, originalEntry, updateEntries, closeFlyout, createEntry]);
}, [selectedEntry, updateEntries, resetStateAndCloseFlyout, originalEntry, createEntry]);

const onSaveCancelled = useCallback(() => {
setOriginalEntry(undefined);
setSelectedEntry(undefined);
closeFlyout();
}, [closeFlyout]);
resetStateAndCloseFlyout();
}, [resetStateAndCloseFlyout]);

const { value: existingIndices } = useAsync(() => {
const indices: string[] = [];
Expand Down Expand Up @@ -323,10 +328,9 @@ export const KnowledgeBaseSettingsManagement: React.FC<Params> = React.memo(({ d
const handleDuplicateEntry = useCallback(async () => {
if (duplicateKBItem) {
await createEntry(duplicateKBItem);
closeFlyout();
setDuplicateKBItem(null);
resetStateAndCloseFlyout();
}
}, [closeFlyout, createEntry, duplicateKBItem]);
}, [createEntry, duplicateKBItem, resetStateAndCloseFlyout]);

if (!enableKnowledgeBaseByDefault) {
return (
Expand Down

0 comments on commit 21dc82f

Please sign in to comment.