Skip to content

Commit

Permalink
[Security Assistant] Knowledge base conflict fix (elastic#195659)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic authored Oct 9, 2024
1 parent 8e986a6 commit 1bf3f2a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,20 @@ export const useInvalidateKnowledgeBaseStatus = () => {
});
}, [queryClient]);
};

/**
* Helper for determining if Knowledge Base setup is complete.
*
* Note: Consider moving to API
*
* @param kbStatus ReadKnowledgeBaseResponse
*/
export const isKnowledgeBaseSetup = (kbStatus: ReadKnowledgeBaseResponse | undefined): boolean => {
return (
(kbStatus?.elser_exists &&
kbStatus?.security_labs_exists &&
kbStatus?.index_exists &&
kbStatus?.pipeline_exists) ??
false
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { useFlyoutModalVisibility } from '../../assistant/common/components/assi
import { IndexEntryEditor } from './index_entry_editor';
import { DocumentEntryEditor } from './document_entry_editor';
import { KnowledgeBaseSettings } from '../knowledge_base_settings';
import { ESQL_RESOURCE, SetupKnowledgeBaseButton } from '../setup_knowledge_base_button';
import { SetupKnowledgeBaseButton } from '../setup_knowledge_base_button';
import { useDeleteKnowledgeBaseEntries } from '../../assistant/api/knowledge_base/entries/use_delete_knowledge_base_entries';
import {
isSystemEntry,
Expand All @@ -73,7 +73,7 @@ export const KnowledgeBaseSettingsManagement: React.FC<Params> = React.memo(({ d
toasts,
} = useAssistantContext();
const [hasPendingChanges, setHasPendingChanges] = useState(false);
const { data: kbStatus, isFetched } = useKnowledgeBaseStatus({ http, resource: ESQL_RESOURCE });
const { data: kbStatus, isFetched } = useKnowledgeBaseStatus({ http });
const isKbSetup = isKnowledgeBaseSetup(kbStatus);

// Only needed for legacy settings management
Expand Down

0 comments on commit 1bf3f2a

Please sign in to comment.