diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/knowledge_base/use_knowledge_base_status.tsx b/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/knowledge_base/use_knowledge_base_status.tsx index ba6317329d35..75e78f2a0694 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/knowledge_base/use_knowledge_base_status.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/knowledge_base/use_knowledge_base_status.tsx @@ -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 + ); +}; diff --git a/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index.tsx b/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index.tsx index 34e8601e37ce..5cf887ae3375 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index.tsx @@ -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, @@ -73,7 +73,7 @@ export const KnowledgeBaseSettingsManagement: React.FC = 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