mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Serverless Search] remove indexing API page (#164784)
## Summary
Removing the Indexing API page from serverless search

This commit is contained in:
parent
fbb2d0bfeb
commit
5622c2e67e
10 changed files with 3 additions and 343 deletions
|
@ -7,5 +7,4 @@
|
|||
*/
|
||||
|
||||
export const SERVERLESS_ES_APP_ID = 'serverlessElasticsearch';
|
||||
export const SERVERLESS_ES_INDEXING_API_ID = 'serverlessIndexingApi';
|
||||
export const SERVERLESS_ES_CONNECTORS_ID = 'serverlessConnectors';
|
||||
|
|
|
@ -6,14 +6,9 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import {
|
||||
SERVERLESS_ES_APP_ID,
|
||||
SERVERLESS_ES_CONNECTORS_ID,
|
||||
SERVERLESS_ES_INDEXING_API_ID,
|
||||
} from './constants';
|
||||
import { SERVERLESS_ES_APP_ID, SERVERLESS_ES_CONNECTORS_ID } from './constants';
|
||||
|
||||
export type AppId = typeof SERVERLESS_ES_APP_ID;
|
||||
export type IndexingApiId = typeof SERVERLESS_ES_INDEXING_API_ID;
|
||||
export type ConnectorsId = typeof SERVERLESS_ES_CONNECTORS_ID;
|
||||
|
||||
export type DeepLinkId = AppId | IndexingApiId | ConnectorsId;
|
||||
export type DeepLinkId = AppId | ConnectorsId;
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export { SERVERLESS_ES_APP_ID, SERVERLESS_ES_INDEXING_API_ID } from './constants';
|
||||
export { SERVERLESS_ES_APP_ID, SERVERLESS_ES_CONNECTORS_ID } from './constants';
|
||||
|
||||
export type { AppId, DeepLinkId } from './deep_links';
|
||||
|
|
|
@ -1,269 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import React, { useMemo, useState } from 'react';
|
||||
|
||||
import {
|
||||
EuiCallOut,
|
||||
EuiComboBox,
|
||||
EuiComboBoxOptionOption,
|
||||
EuiFlexGroup,
|
||||
EuiFlexItem,
|
||||
EuiFormRow,
|
||||
EuiLink,
|
||||
EuiPageTemplate,
|
||||
EuiSpacer,
|
||||
EuiStat,
|
||||
EuiText,
|
||||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import {
|
||||
OverviewPanel,
|
||||
LanguageClientPanel,
|
||||
CodeBox,
|
||||
getLanguageDefinitionCodeSnippet,
|
||||
getConsoleRequest,
|
||||
} from '@kbn/search-api-panels';
|
||||
import type {
|
||||
LanguageDefinition,
|
||||
LanguageDefinitionSnippetArguments,
|
||||
} from '@kbn/search-api-panels';
|
||||
|
||||
import { PLUGIN_ID } from '../../../common';
|
||||
import { docLinks } from '../../../common/doc_links';
|
||||
import { IndexData, FetchIndicesResult } from '../../../common/types';
|
||||
import { FETCH_INDICES_PATH } from '../routes';
|
||||
import { API_KEY_PLACEHOLDER, ELASTICSEARCH_URL_PLACEHOLDER } from '../constants';
|
||||
import { useKibanaServices } from '../hooks/use_kibana';
|
||||
import { javascriptDefinition } from './languages/javascript';
|
||||
import { languageDefinitions } from './languages/languages';
|
||||
|
||||
const NoIndicesContent = () => (
|
||||
<>
|
||||
<EuiSpacer />
|
||||
<EuiText>
|
||||
<FormattedMessage
|
||||
id="xpack.serverlessSearch.content.indexingApi.clientPanel.noIndices.helpText"
|
||||
defaultMessage="Don't have an index yet? {getStartedLink}"
|
||||
values={{
|
||||
getStartedLink: (
|
||||
<EuiLink href={docLinks.gettingStartedIngest} external>
|
||||
{i18n.translate(
|
||||
'xpack.serverlessSearch.content.indexingApi.clientPanel.noIndices.getStartedLink',
|
||||
{ defaultMessage: 'Get started' }
|
||||
)}
|
||||
</EuiLink>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</EuiText>
|
||||
</>
|
||||
);
|
||||
|
||||
interface IndicesContentProps {
|
||||
indices: IndexData[];
|
||||
isLoading: boolean;
|
||||
onChange: (selectedOptions: Array<EuiComboBoxOptionOption<IndexData>>) => void;
|
||||
selectedIndex?: IndexData;
|
||||
setSearchValue: (searchValue?: string) => void;
|
||||
}
|
||||
const IndicesContent = ({
|
||||
indices,
|
||||
isLoading,
|
||||
onChange,
|
||||
selectedIndex,
|
||||
setSearchValue,
|
||||
}: IndicesContentProps) => {
|
||||
const toOption = (index: IndexData) => ({ label: index.name, value: index });
|
||||
const options: Array<EuiComboBoxOptionOption<IndexData>> = indices.map(toOption);
|
||||
return (
|
||||
<>
|
||||
<EuiSpacer />
|
||||
<EuiFlexGroup>
|
||||
<EuiFlexItem>
|
||||
<EuiFormRow
|
||||
fullWidth
|
||||
label={i18n.translate(
|
||||
'xpack.serverlessSearch.content.indexingApi.index.comboBox.title',
|
||||
{ defaultMessage: 'Index' }
|
||||
)}
|
||||
>
|
||||
<EuiComboBox
|
||||
async
|
||||
fullWidth
|
||||
isLoading={isLoading}
|
||||
singleSelection={{ asPlainText: true }}
|
||||
onChange={onChange}
|
||||
onSearchChange={setSearchValue}
|
||||
options={options}
|
||||
selectedOptions={selectedIndex ? [toOption(selectedIndex)] : undefined}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiStat
|
||||
title={selectedIndex ? selectedIndex.count.toLocaleString() : '--'}
|
||||
titleColor="primary"
|
||||
description={i18n.translate(
|
||||
'xpack.serverlessSearch.content.indexingApi.index.documentCount.description',
|
||||
{ defaultMessage: 'Documents' }
|
||||
)}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const ElasticsearchIndexingApi = () => {
|
||||
const { cloud, http, share } = useKibanaServices();
|
||||
const [selectedLanguage, setSelectedLanguage] =
|
||||
useState<LanguageDefinition>(javascriptDefinition);
|
||||
const [indexSearchQuery, setIndexSearchQuery] = useState<string | undefined>(undefined);
|
||||
const [selectedIndex, setSelectedIndex] = useState<IndexData | undefined>(undefined);
|
||||
const elasticsearchURL = useMemo(() => {
|
||||
return cloud?.elasticsearchUrl ?? ELASTICSEARCH_URL_PLACEHOLDER;
|
||||
}, [cloud]);
|
||||
const { data, isLoading, isError } = useQuery({
|
||||
queryKey: ['indices', { searchQuery: indexSearchQuery }],
|
||||
queryFn: async () => {
|
||||
const query = {
|
||||
search_query: indexSearchQuery || null,
|
||||
};
|
||||
const result = await http.get<FetchIndicesResult>(FETCH_INDICES_PATH, { query });
|
||||
return result;
|
||||
},
|
||||
});
|
||||
const assetBasePath = http.basePath.prepend(`/plugins/${PLUGIN_ID}/assets/`);
|
||||
|
||||
const codeSnippetArguments: LanguageDefinitionSnippetArguments = {
|
||||
url: elasticsearchURL,
|
||||
apiKey: API_KEY_PLACEHOLDER,
|
||||
indexName: selectedIndex?.name,
|
||||
};
|
||||
const showNoIndices = !isLoading && data?.indices?.length === 0 && indexSearchQuery === undefined;
|
||||
|
||||
return (
|
||||
<EuiPageTemplate
|
||||
offset={0}
|
||||
grow
|
||||
restrictWidth
|
||||
data-test-subj="svlSearchIndexingApiPage"
|
||||
panelled
|
||||
>
|
||||
<EuiPageTemplate.Header
|
||||
pageTitle={i18n.translate('xpack.serverlessSearch.content.indexingApi.header.title', {
|
||||
defaultMessage: 'Indexing API',
|
||||
})}
|
||||
description={i18n.translate(
|
||||
'xpack.serverlessSearch.content.indexingApi.header.description',
|
||||
{
|
||||
defaultMessage:
|
||||
'Add data to your data stream or index to make it searchable. Choose an ingestion method that fits your application and workflow.',
|
||||
}
|
||||
)}
|
||||
bottomBorder="extended"
|
||||
/>
|
||||
{isError && (
|
||||
<EuiPageTemplate.Section>
|
||||
<EuiCallOut
|
||||
color="danger"
|
||||
title={i18n.translate(
|
||||
'xpack.serverlessSearch.content.indexingApi.fetchIndices.error.title',
|
||||
{ defaultMessage: 'Error fetching indices' }
|
||||
)}
|
||||
/>
|
||||
</EuiPageTemplate.Section>
|
||||
)}
|
||||
<EuiPageTemplate.Section color="subdued" bottomBorder="extended">
|
||||
<OverviewPanel
|
||||
title={i18n.translate('xpack.serverlessSearch.content.indexingApi.clientPanel.title', {
|
||||
defaultMessage: 'Ingest data for the first time',
|
||||
})}
|
||||
description={i18n.translate(
|
||||
'xpack.serverlessSearch.content.indexingApi.clientPanel.description',
|
||||
{ defaultMessage: 'Adding documents to your already created index using the API' }
|
||||
)}
|
||||
leftPanelContent={
|
||||
<>
|
||||
<EuiFlexGroup direction="column">
|
||||
<EuiFlexItem>
|
||||
<EuiText size="s">
|
||||
<strong>
|
||||
{i18n.translate(
|
||||
'xpack.serverlessSearch.content.indexingApi.clientPanel.selectClient.heading',
|
||||
{
|
||||
defaultMessage: 'Choose one',
|
||||
}
|
||||
)}
|
||||
</strong>
|
||||
</EuiText>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
<EuiSpacer size="s" />
|
||||
<EuiFlexGroup gutterSize="xs" direction="row">
|
||||
{languageDefinitions.map((language, index) => (
|
||||
<EuiFlexItem key={`panelItem.${index}`}>
|
||||
<LanguageClientPanel
|
||||
language={language}
|
||||
setSelectedLanguage={setSelectedLanguage}
|
||||
isSelectedLanguage={selectedLanguage === language}
|
||||
assetBasePath={assetBasePath}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
))}
|
||||
</EuiFlexGroup>
|
||||
<EuiSpacer />
|
||||
<CodeBox
|
||||
languages={languageDefinitions}
|
||||
codeSnippet={getLanguageDefinitionCodeSnippet(
|
||||
selectedLanguage,
|
||||
'ingestDataIndex',
|
||||
codeSnippetArguments
|
||||
)}
|
||||
selectedLanguage={selectedLanguage}
|
||||
setSelectedLanguage={setSelectedLanguage}
|
||||
assetBasePath={assetBasePath}
|
||||
sharePlugin={share}
|
||||
consoleRequest={getConsoleRequest('ingestDataIndex')}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
links={
|
||||
showNoIndices
|
||||
? undefined
|
||||
: [
|
||||
{
|
||||
label: i18n.translate(
|
||||
'xpack.serverlessSearch.content.indexingApi.ingestDocsLink',
|
||||
{ defaultMessage: 'Ingestion documentation' }
|
||||
),
|
||||
href: docLinks.gettingStartedIngest,
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
{showNoIndices ? (
|
||||
<NoIndicesContent />
|
||||
) : (
|
||||
<IndicesContent
|
||||
isLoading={isLoading}
|
||||
indices={data?.indices ?? []}
|
||||
onChange={(options) => {
|
||||
setSelectedIndex(options?.[0]?.value);
|
||||
}}
|
||||
setSearchValue={setIndexSearchQuery}
|
||||
selectedIndex={selectedIndex}
|
||||
/>
|
||||
)}
|
||||
</OverviewPanel>
|
||||
</EuiPageTemplate.Section>
|
||||
</EuiPageTemplate>
|
||||
);
|
||||
};
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { CoreStart } from '@kbn/core/public';
|
||||
import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
|
||||
import { I18nProvider } from '@kbn/i18n-react';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
||||
import { ServerlessSearchContext } from './hooks/use_kibana';
|
||||
|
||||
export async function renderApp(
|
||||
element: HTMLElement,
|
||||
core: CoreStart,
|
||||
services: ServerlessSearchContext
|
||||
) {
|
||||
const { ElasticsearchIndexingApi } = await import('./components/indexing_api');
|
||||
const queryClient = new QueryClient();
|
||||
ReactDOM.render(
|
||||
<KibanaThemeProvider theme$={core.theme.theme$}>
|
||||
<KibanaContextProvider services={{ ...core, ...services }}>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ReactQueryDevtools initialIsOpen={false} />
|
||||
<I18nProvider>
|
||||
<ElasticsearchIndexingApi />
|
||||
</I18nProvider>
|
||||
</QueryClientProvider>
|
||||
</KibanaContextProvider>
|
||||
</KibanaThemeProvider>,
|
||||
element
|
||||
);
|
||||
return () => ReactDOM.unmountComponentAtNode(element);
|
||||
}
|
|
@ -98,13 +98,6 @@ const navigationTree: NavigationTreeDefinition = {
|
|||
}),
|
||||
link: 'management:ingest_pipelines',
|
||||
},
|
||||
{
|
||||
id: 'content_indexing_api',
|
||||
link: 'serverlessIndexingApi',
|
||||
title: i18n.translate('xpack.serverlessSearch.nav.content.indexingApi', {
|
||||
defaultMessage: 'Indexing API',
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -47,23 +47,6 @@ export class ServerlessSearchPlugin
|
|||
return await renderApp(element, coreStart, { userProfile, ...services });
|
||||
},
|
||||
});
|
||||
core.application.register({
|
||||
id: 'serverlessIndexingApi',
|
||||
title: i18n.translate('xpack.serverlessSearch.app.indexingApi.title', {
|
||||
defaultMessage: 'Indexing API',
|
||||
}),
|
||||
appRoute: '/app/indexing_api',
|
||||
async mount({ element }: AppMountParameters) {
|
||||
const { renderApp } = await import('./application/indexing_api');
|
||||
const [coreStart, services] = await core.getStartServices();
|
||||
const { security } = services;
|
||||
docLinks.setDocLinks(coreStart.docLinks.links);
|
||||
|
||||
const userProfile = await security.userProfiles.getCurrent();
|
||||
|
||||
return await renderApp(element, coreStart, { userProfile, ...services });
|
||||
},
|
||||
});
|
||||
|
||||
core.application.register({
|
||||
id: 'serverlessConnectors',
|
||||
|
|
|
@ -34705,7 +34705,6 @@
|
|||
"xpack.serverlessSearch.languages.ruby": "Ruby",
|
||||
"xpack.serverlessSearch.learnMore": "En savoir plus",
|
||||
"xpack.serverlessSearch.nav.content": "Contenu",
|
||||
"xpack.serverlessSearch.nav.content.indexingApi": "API d’indexation",
|
||||
"xpack.serverlessSearch.nav.content.indices": "Index",
|
||||
"xpack.serverlessSearch.nav.devTools": "Outils de développement",
|
||||
"xpack.serverlessSearch.nav.explore": "Explorer",
|
||||
|
|
|
@ -34704,7 +34704,6 @@
|
|||
"xpack.serverlessSearch.languages.ruby": "Ruby",
|
||||
"xpack.serverlessSearch.learnMore": "詳細",
|
||||
"xpack.serverlessSearch.nav.content": "コンテンツ",
|
||||
"xpack.serverlessSearch.nav.content.indexingApi": "インデックスAPI",
|
||||
"xpack.serverlessSearch.nav.content.indices": "インデックス",
|
||||
"xpack.serverlessSearch.nav.devTools": "開発ツール",
|
||||
"xpack.serverlessSearch.nav.explore": "探索",
|
||||
|
|
|
@ -34700,7 +34700,6 @@
|
|||
"xpack.serverlessSearch.languages.ruby": "Ruby",
|
||||
"xpack.serverlessSearch.learnMore": "了解详情",
|
||||
"xpack.serverlessSearch.nav.content": "内容",
|
||||
"xpack.serverlessSearch.nav.content.indexingApi": "正在索引 API",
|
||||
"xpack.serverlessSearch.nav.content.indices": "索引",
|
||||
"xpack.serverlessSearch.nav.devTools": "开发工具",
|
||||
"xpack.serverlessSearch.nav.explore": "浏览",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue