From f25dcec023499c64a303954e16932557724225ed Mon Sep 17 00:00:00 2001 From: Joseph McElroy Date: Tue, 1 Oct 2024 16:02:13 +0100 Subject: [PATCH] updates based on feedback --- .github/CODEOWNERS | 2 +- package.json | 2 +- .../{public => }/index.ts | 8 ++++---- .../components/api_key_flyout_wrapper.tsx | 0 .../components/api_key_form.tsx | 0 .../{public => src}/constants.ts | 0 .../hooks/use_search_api_key.ts | 0 .../providers/search_api_key_provider.tsx | 2 +- .../{public => src}/types.ts | 0 .../tsconfig.json | 7 ++++--- .../README.md | 0 .../index.ts | 2 +- .../jest.config.js | 6 +++--- .../kibana.jsonc | 2 +- .../package.json | 2 +- .../src}/lib/create_key.ts | 2 +- .../src}/lib/get_key_by_id.ts | 2 +- .../src}/lib/privileges.ts | 0 .../src}/routes/routes.ts | 2 +- .../tsconfig.json | 6 ++++-- .../types.ts | 0 tsconfig.base.json | 10 ++++++---- .../search_indices/public/application.tsx | 2 +- .../add_documents_code_example.tsx | 19 ++++++++++++------- .../components/indices/details_page.tsx | 2 +- .../public/components/shared/code_sample.tsx | 13 ++----------- .../components/start/create_index_code.tsx | 9 +++++---- .../search_indices/server/routes/index.ts | 2 +- x-pack/plugins/search_indices/tsconfig.json | 4 ++-- yarn.lock | 4 ++-- 30 files changed, 56 insertions(+), 54 deletions(-) rename packages/kbn-search-api-keys-components/{public => }/index.ts (69%) rename packages/kbn-search-api-keys-components/{public => src}/components/api_key_flyout_wrapper.tsx (100%) rename packages/kbn-search-api-keys-components/{public => src}/components/api_key_form.tsx (100%) rename packages/kbn-search-api-keys-components/{public => src}/constants.ts (100%) rename packages/kbn-search-api-keys-components/{public => src}/hooks/use_search_api_key.ts (100%) rename packages/kbn-search-api-keys-components/{public => src}/providers/search_api_key_provider.tsx (99%) rename packages/kbn-search-api-keys-components/{public => src}/types.ts (100%) rename packages/{kbn-search-api-keys-api => kbn-search-api-keys-server}/README.md (100%) rename packages/{kbn-search-api-keys-api/server => kbn-search-api-keys-server}/index.ts (92%) rename packages/{kbn-search-api-keys-api => kbn-search-api-keys-server}/jest.config.js (85%) rename packages/{kbn-search-api-keys-api => kbn-search-api-keys-server}/kibana.jsonc (62%) rename packages/{kbn-search-api-keys-api => kbn-search-api-keys-server}/package.json (72%) rename packages/{kbn-search-api-keys-api/server => kbn-search-api-keys-server/src}/lib/create_key.ts (94%) rename packages/{kbn-search-api-keys-api/server => kbn-search-api-keys-server/src}/lib/get_key_by_id.ts (94%) rename packages/{kbn-search-api-keys-api/server => kbn-search-api-keys-server/src}/lib/privileges.ts (100%) rename packages/{kbn-search-api-keys-api/server => kbn-search-api-keys-server/src}/routes/routes.ts (98%) rename packages/{kbn-search-api-keys-api => kbn-search-api-keys-server}/tsconfig.json (85%) rename packages/{kbn-search-api-keys-api/server => kbn-search-api-keys-server}/types.ts (100%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 50928501e6e17..170a084a5ea1d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -752,7 +752,7 @@ src/plugins/screenshot_mode @elastic/appex-sharedux x-pack/examples/screenshotting_example @elastic/appex-sharedux x-pack/plugins/screenshotting @elastic/kibana-reporting-services packages/kbn-screenshotting-server @elastic/appex-sharedux -packages/kbn-search-api-keys-api @elastic/search-kibana +packages/kbn-search-api-keys-server @elastic/search-kibana packages/kbn-search-api-keys-components @elastic/search-kibana packages/kbn-search-api-panels @elastic/search-kibana x-pack/plugins/search_assistant @elastic/search-kibana diff --git a/package.json b/package.json index 3d2ccb9b9852d..a1fcd09d06845 100644 --- a/package.json +++ b/package.json @@ -769,8 +769,8 @@ "@kbn/screenshotting-example-plugin": "link:x-pack/examples/screenshotting_example", "@kbn/screenshotting-plugin": "link:x-pack/plugins/screenshotting", "@kbn/screenshotting-server": "link:packages/kbn-screenshotting-server", - "@kbn/search-api-keys-api": "link:packages/kbn-search-api-keys-api", "@kbn/search-api-keys-components": "link:packages/kbn-search-api-keys-components", + "@kbn/search-api-keys-server": "link:packages/kbn-search-api-keys-server", "@kbn/search-api-panels": "link:packages/kbn-search-api-panels", "@kbn/search-assistant": "link:x-pack/plugins/search_assistant", "@kbn/search-connectors": "link:packages/kbn-search-connectors", diff --git a/packages/kbn-search-api-keys-components/public/index.ts b/packages/kbn-search-api-keys-components/index.ts similarity index 69% rename from packages/kbn-search-api-keys-components/public/index.ts rename to packages/kbn-search-api-keys-components/index.ts index 3e3cb8e83a154..d188bdb956913 100644 --- a/packages/kbn-search-api-keys-components/public/index.ts +++ b/packages/kbn-search-api-keys-components/index.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export * from './components/api_key_flyout_wrapper'; -export * from './components/api_key_form'; -export * from './hooks/use_search_api_key'; -export * from './providers/search_api_key_provider'; +export * from './src/components/api_key_flyout_wrapper'; +export * from './src/components/api_key_form'; +export * from './src/hooks/use_search_api_key'; +export * from './src/providers/search_api_key_provider'; diff --git a/packages/kbn-search-api-keys-components/public/components/api_key_flyout_wrapper.tsx b/packages/kbn-search-api-keys-components/src/components/api_key_flyout_wrapper.tsx similarity index 100% rename from packages/kbn-search-api-keys-components/public/components/api_key_flyout_wrapper.tsx rename to packages/kbn-search-api-keys-components/src/components/api_key_flyout_wrapper.tsx diff --git a/packages/kbn-search-api-keys-components/public/components/api_key_form.tsx b/packages/kbn-search-api-keys-components/src/components/api_key_form.tsx similarity index 100% rename from packages/kbn-search-api-keys-components/public/components/api_key_form.tsx rename to packages/kbn-search-api-keys-components/src/components/api_key_form.tsx diff --git a/packages/kbn-search-api-keys-components/public/constants.ts b/packages/kbn-search-api-keys-components/src/constants.ts similarity index 100% rename from packages/kbn-search-api-keys-components/public/constants.ts rename to packages/kbn-search-api-keys-components/src/constants.ts diff --git a/packages/kbn-search-api-keys-components/public/hooks/use_search_api_key.ts b/packages/kbn-search-api-keys-components/src/hooks/use_search_api_key.ts similarity index 100% rename from packages/kbn-search-api-keys-components/public/hooks/use_search_api_key.ts rename to packages/kbn-search-api-keys-components/src/hooks/use_search_api_key.ts diff --git a/packages/kbn-search-api-keys-components/public/providers/search_api_key_provider.tsx b/packages/kbn-search-api-keys-components/src/providers/search_api_key_provider.tsx similarity index 99% rename from packages/kbn-search-api-keys-components/public/providers/search_api_key_provider.tsx rename to packages/kbn-search-api-keys-components/src/providers/search_api_key_provider.tsx index 620f008a58c6c..f3a81e72d3b2e 100644 --- a/packages/kbn-search-api-keys-components/public/providers/search_api_key_provider.tsx +++ b/packages/kbn-search-api-keys-components/src/providers/search_api_key_provider.tsx @@ -10,7 +10,7 @@ import React, { useCallback, useReducer, createContext, useEffect } from 'react'; import { useMutation } from '@tanstack/react-query'; import { useKibana } from '@kbn/kibana-react-plugin/public'; -import type { APIKeyCreationResponse } from '@kbn/search-api-keys-api/server/types'; +import type { APIKeyCreationResponse } from '@kbn/search-api-keys-server/types'; import { APIRoutes } from '../types'; import { Status } from '../constants'; diff --git a/packages/kbn-search-api-keys-components/public/types.ts b/packages/kbn-search-api-keys-components/src/types.ts similarity index 100% rename from packages/kbn-search-api-keys-components/public/types.ts rename to packages/kbn-search-api-keys-components/src/types.ts diff --git a/packages/kbn-search-api-keys-components/tsconfig.json b/packages/kbn-search-api-keys-components/tsconfig.json index ec779956b1547..281bdf6203bbb 100644 --- a/packages/kbn-search-api-keys-components/tsconfig.json +++ b/packages/kbn-search-api-keys-components/tsconfig.json @@ -4,7 +4,8 @@ "outDir": "target/types", }, "include": [ - "public/**/*", + "src/**/*", + "index.ts", ], "kbn_references": [ "@kbn/i18n", @@ -12,9 +13,9 @@ "@kbn/kibana-react-plugin", "@kbn/security-api-key-management", "@kbn/search-shared-ui", - "@kbn/search-api-keys-api" + "@kbn/search-api-keys-server" ], "exclude": [ "target/**/*", ] -} +} \ No newline at end of file diff --git a/packages/kbn-search-api-keys-api/README.md b/packages/kbn-search-api-keys-server/README.md similarity index 100% rename from packages/kbn-search-api-keys-api/README.md rename to packages/kbn-search-api-keys-server/README.md diff --git a/packages/kbn-search-api-keys-api/server/index.ts b/packages/kbn-search-api-keys-server/index.ts similarity index 92% rename from packages/kbn-search-api-keys-api/server/index.ts rename to packages/kbn-search-api-keys-server/index.ts index 67646efc2e8fb..e9287e9debdd0 100644 --- a/packages/kbn-search-api-keys-api/server/index.ts +++ b/packages/kbn-search-api-keys-server/index.ts @@ -7,4 +7,4 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export * from './routes/routes'; +export * from './src/routes/routes'; diff --git a/packages/kbn-search-api-keys-api/jest.config.js b/packages/kbn-search-api-keys-server/jest.config.js similarity index 85% rename from packages/kbn-search-api-keys-api/jest.config.js rename to packages/kbn-search-api-keys-server/jest.config.js index 997b5ed138a01..af09324461569 100644 --- a/packages/kbn-search-api-keys-api/jest.config.js +++ b/packages/kbn-search-api-keys-server/jest.config.js @@ -10,8 +10,8 @@ module.exports = { preset: '@kbn/test/jest_node', rootDir: '../..', - roots: ['/packages/kbn-search-api-keys-api'], - coverageDirectory: '/target/kibana-coverage/jest/packages/kbn-search-api-keys-api', + roots: ['/packages/kbn-search-api-keys-server'], + coverageDirectory: '/target/kibana-coverage/jest/packages/kbn-search-api-keys-server', coverageReporters: ['text', 'html'], - collectCoverageFrom: ['/packages/kbn-search-api-keys-api/**/*.{ts,tsx}'], + collectCoverageFrom: ['/packages/kbn-search-api-keys-server/**/*.{ts,tsx}'], }; diff --git a/packages/kbn-search-api-keys-api/kibana.jsonc b/packages/kbn-search-api-keys-server/kibana.jsonc similarity index 62% rename from packages/kbn-search-api-keys-api/kibana.jsonc rename to packages/kbn-search-api-keys-server/kibana.jsonc index 36501e7f34e51..52c6cd9653968 100644 --- a/packages/kbn-search-api-keys-api/kibana.jsonc +++ b/packages/kbn-search-api-keys-server/kibana.jsonc @@ -1,5 +1,5 @@ { "type": "shared-server", - "id": "@kbn/search-api-keys-api", + "id": "@kbn/search-api-keys-server", "owner": "@elastic/search-kibana" } \ No newline at end of file diff --git a/packages/kbn-search-api-keys-api/package.json b/packages/kbn-search-api-keys-server/package.json similarity index 72% rename from packages/kbn-search-api-keys-api/package.json rename to packages/kbn-search-api-keys-server/package.json index 536a7df06d1aa..6c891e7325a2e 100644 --- a/packages/kbn-search-api-keys-api/package.json +++ b/packages/kbn-search-api-keys-server/package.json @@ -1,5 +1,5 @@ { - "name": "@kbn/search-api-keys-api", + "name": "@kbn/search-api-keys-server", "private": true, "version": "1.0.0", "license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0" diff --git a/packages/kbn-search-api-keys-api/server/lib/create_key.ts b/packages/kbn-search-api-keys-server/src/lib/create_key.ts similarity index 94% rename from packages/kbn-search-api-keys-api/server/lib/create_key.ts rename to packages/kbn-search-api-keys-server/src/lib/create_key.ts index e74605c32440d..7bebe713810c8 100644 --- a/packages/kbn-search-api-keys-api/server/lib/create_key.ts +++ b/packages/kbn-search-api-keys-server/src/lib/create_key.ts @@ -9,7 +9,7 @@ import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; import type { Logger } from '@kbn/logging'; -import type { APIKeyCreationResponse } from '../types'; +import type { APIKeyCreationResponse } from '../../types'; export async function createAPIKey( name: string, diff --git a/packages/kbn-search-api-keys-api/server/lib/get_key_by_id.ts b/packages/kbn-search-api-keys-server/src/lib/get_key_by_id.ts similarity index 94% rename from packages/kbn-search-api-keys-api/server/lib/get_key_by_id.ts rename to packages/kbn-search-api-keys-server/src/lib/get_key_by_id.ts index a1337de4c4981..94ae64f56c0da 100644 --- a/packages/kbn-search-api-keys-api/server/lib/get_key_by_id.ts +++ b/packages/kbn-search-api-keys-server/src/lib/get_key_by_id.ts @@ -9,7 +9,7 @@ import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; import type { Logger } from '@kbn/logging'; -import type { GetApiKeyResponse } from '../types'; +import type { GetApiKeyResponse } from '../../types'; export async function getAPIKeyById( id: string, diff --git a/packages/kbn-search-api-keys-api/server/lib/privileges.ts b/packages/kbn-search-api-keys-server/src/lib/privileges.ts similarity index 100% rename from packages/kbn-search-api-keys-api/server/lib/privileges.ts rename to packages/kbn-search-api-keys-server/src/lib/privileges.ts diff --git a/packages/kbn-search-api-keys-api/server/routes/routes.ts b/packages/kbn-search-api-keys-server/src/routes/routes.ts similarity index 98% rename from packages/kbn-search-api-keys-api/server/routes/routes.ts rename to packages/kbn-search-api-keys-server/src/routes/routes.ts index d3ddd4c4e21f1..77a08644f34a5 100644 --- a/packages/kbn-search-api-keys-api/server/routes/routes.ts +++ b/packages/kbn-search-api-keys-server/src/routes/routes.ts @@ -11,7 +11,7 @@ import type { IRouter } from '@kbn/core/server'; import type { Logger } from '@kbn/logging'; import { schema } from '@kbn/config-schema'; -import { APIRoutes } from '../types'; +import { APIRoutes } from '../../types'; import { getAPIKeyById } from '../lib/get_key_by_id'; import { createAPIKey } from '../lib/create_key'; import { fetchClusterHasApiKeys, fetchUserStartPrivileges } from '../lib/privileges'; diff --git a/packages/kbn-search-api-keys-api/tsconfig.json b/packages/kbn-search-api-keys-server/tsconfig.json similarity index 85% rename from packages/kbn-search-api-keys-api/tsconfig.json rename to packages/kbn-search-api-keys-server/tsconfig.json index b775a5eee6418..79fd6573c2443 100644 --- a/packages/kbn-search-api-keys-api/tsconfig.json +++ b/packages/kbn-search-api-keys-server/tsconfig.json @@ -4,7 +4,9 @@ "outDir": "target/types", }, "include": [ - "server/**/*" + "src/**/*", + "types.ts", + "index.ts" ], "kbn_references": [ "@kbn/core-elasticsearch-server", @@ -15,4 +17,4 @@ "exclude": [ "target/**/*", ] -} +} \ No newline at end of file diff --git a/packages/kbn-search-api-keys-api/server/types.ts b/packages/kbn-search-api-keys-server/types.ts similarity index 100% rename from packages/kbn-search-api-keys-api/server/types.ts rename to packages/kbn-search-api-keys-server/types.ts diff --git a/tsconfig.base.json b/tsconfig.base.json index 5cbee514d63b7..aefbd2d12ffd5 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1498,10 +1498,10 @@ "@kbn/screenshotting-plugin/*": ["x-pack/plugins/screenshotting/*"], "@kbn/screenshotting-server": ["packages/kbn-screenshotting-server"], "@kbn/screenshotting-server/*": ["packages/kbn-screenshotting-server/*"], - "@kbn/search-api-keys-api": ["packages/kbn-search-api-keys-api"], - "@kbn/search-api-keys-api/*": ["packages/kbn-search-api-keys-api/*"], "@kbn/search-api-keys-components": ["packages/kbn-search-api-keys-components"], "@kbn/search-api-keys-components/*": ["packages/kbn-search-api-keys-components/*"], + "@kbn/search-api-keys-server": ["packages/kbn-search-api-keys-server"], + "@kbn/search-api-keys-server/*": ["packages/kbn-search-api-keys-server/*"], "@kbn/search-api-panels": ["packages/kbn-search-api-panels"], "@kbn/search-api-panels/*": ["packages/kbn-search-api-panels/*"], "@kbn/search-assistant": ["x-pack/plugins/search_assistant"], @@ -2000,7 +2000,9 @@ "@kbn/zod-helpers/*": ["packages/kbn-zod-helpers/*"], // END AUTOMATED PACKAGE LISTING // Allows for importing from `kibana` package for the exported types. - "@emotion/core": ["typings/@emotion"] + "@emotion/core": [ + "typings/@emotion" + ] }, // Support .tsx files and transform JSX into calls to React.createElement "jsx": "react", @@ -2074,4 +2076,4 @@ "@kbn/ambient-storybook-types" ] } -} +} \ No newline at end of file diff --git a/x-pack/plugins/search_indices/public/application.tsx b/x-pack/plugins/search_indices/public/application.tsx index de0e26f455b2c..e3f537998d5ea 100644 --- a/x-pack/plugins/search_indices/public/application.tsx +++ b/x-pack/plugins/search_indices/public/application.tsx @@ -13,7 +13,7 @@ import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { I18nProvider } from '@kbn/i18n-react'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { SearchApiKeyProvider } from '@kbn/search-api-keys-components/public'; +import { SearchApiKeyProvider } from '@kbn/search-api-keys-components'; import { UsageTrackerContextProvider } from './contexts/usage_tracker_context'; import { SearchIndicesServicesContextDeps } from './types'; diff --git a/x-pack/plugins/search_indices/public/components/index_documents/add_documents_code_example.tsx b/x-pack/plugins/search_indices/public/components/index_documents/add_documents_code_example.tsx index d71046293021a..aa8fd525c8a44 100644 --- a/x-pack/plugins/search_indices/public/components/index_documents/add_documents_code_example.tsx +++ b/x-pack/plugins/search_indices/public/components/index_documents/add_documents_code_example.tsx @@ -11,7 +11,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { TryInConsoleButton } from '@kbn/try-in-console'; -import { useSearchApiKey } from '@kbn/search-api-keys-components/public'; +import { useSearchApiKey } from '@kbn/search-api-keys-components'; import { useKibana } from '../../hooks/use_kibana'; import { IngestCodeSnippetParameters } from '../../types'; import { LanguageSelector } from '../shared/language_selector'; @@ -59,6 +59,7 @@ export const AddDocumentsCodeExample = ({ // TODO: implement smart document generation return generateSampleDocument(codeSampleMappings); }, [codeSampleMappings]); + const { apiKey, apiKeyIsVisible } = useSearchApiKey(); const codeParams: IngestCodeSnippetParameters = useMemo(() => { return { indexName, @@ -66,10 +67,17 @@ export const AddDocumentsCodeExample = ({ sampleDocument, indexHasMappings, mappingProperties: codeSampleMappings, + apiKey: apiKeyIsVisible && apiKey ? apiKey : undefined, }; - }, [indexName, elasticsearchUrl, sampleDocument, codeSampleMappings, indexHasMappings]); - - const { apiKey, apiKeyIsVisible } = useSearchApiKey(); + }, [ + indexName, + elasticsearchUrl, + sampleDocument, + codeSampleMappings, + indexHasMappings, + apiKeyIsVisible, + apiKey, + ]); return ( { usageTracker.click([ AnalyticsEvents.indexDetailsInstallCodeCopy, @@ -135,7 +142,6 @@ export const AddDocumentsCodeExample = ({ })} language={Languages[selectedLanguage].codeBlockLanguage} code={selectedCodeExamples.updateMappingsCommand(codeParams)} - apiKey={apiKeyIsVisible ? apiKey : null} onCodeCopyClick={() => { usageTracker.click([ AnalyticsEvents.indexDetailsAddMappingsCodeCopy, @@ -151,7 +157,6 @@ export const AddDocumentsCodeExample = ({ title={ingestCodeExamples.ingestTitle} language={Languages[selectedLanguage].codeBlockLanguage} code={selectedCodeExamples.ingestCommand(codeParams)} - apiKey={apiKeyIsVisible ? apiKey : null} onCodeCopyClick={() => { usageTracker.click([ AnalyticsEvents.indexDetailsIngestDocumentsCodeCopy, diff --git a/x-pack/plugins/search_indices/public/components/indices/details_page.tsx b/x-pack/plugins/search_indices/public/components/indices/details_page.tsx index 91626d91f8577..94abecd137005 100644 --- a/x-pack/plugins/search_indices/public/components/indices/details_page.tsx +++ b/x-pack/plugins/search_indices/public/components/indices/details_page.tsx @@ -26,7 +26,7 @@ import { useParams } from 'react-router-dom'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { SectionLoading } from '@kbn/es-ui-shared-plugin/public'; -import { ApiKeyForm } from '@kbn/search-api-keys-components/public'; +import { ApiKeyForm } from '@kbn/search-api-keys-components'; import { useIndex } from '../../hooks/api/use_index'; import { useKibana } from '../../hooks/use_kibana'; import { ConnectionDetails } from '../connection_details/connection_details'; diff --git a/x-pack/plugins/search_indices/public/components/shared/code_sample.tsx b/x-pack/plugins/search_indices/public/components/shared/code_sample.tsx index 539455eab4bf6..4ddce94d685b0 100644 --- a/x-pack/plugins/search_indices/public/components/shared/code_sample.tsx +++ b/x-pack/plugins/search_indices/public/components/shared/code_sample.tsx @@ -16,7 +16,6 @@ import { EuiText, EuiThemeProvider, } from '@elastic/eui'; -import { API_KEY_PLACEHOLDER } from '../../constants'; export interface CodeSampleProps { id?: string; @@ -24,17 +23,9 @@ export interface CodeSampleProps { language: string; code: string; onCodeCopyClick?: React.MouseEventHandler; - apiKey?: string | null; } -export const CodeSample = ({ - id, - title, - language, - code, - apiKey, - onCodeCopyClick, -}: CodeSampleProps) => { +export const CodeSample = ({ id, title, language, code, onCodeCopyClick }: CodeSampleProps) => { const onCodeClick = React.useCallback( (e: React.MouseEvent) => { if (onCodeCopyClick === undefined) return; @@ -64,7 +55,7 @@ export const CodeSample = ({ isCopyable transparentBackground > - {apiKey ? code.replace(API_KEY_PLACEHOLDER, apiKey) : code} + {code} diff --git a/x-pack/plugins/search_indices/public/components/start/create_index_code.tsx b/x-pack/plugins/search_indices/public/components/start/create_index_code.tsx index 4aeaa4cb6c957..401173fecc0da 100644 --- a/x-pack/plugins/search_indices/public/components/start/create_index_code.tsx +++ b/x-pack/plugins/search_indices/public/components/start/create_index_code.tsx @@ -9,7 +9,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiSpacer, EuiText } from '@elasti import { i18n } from '@kbn/i18n'; import { TryInConsoleButton } from '@kbn/try-in-console'; -import { ApiKeyForm, useSearchApiKey } from '@kbn/search-api-keys-components/public'; +import { ApiKeyForm, useSearchApiKey } from '@kbn/search-api-keys-components'; import { AnalyticsEvents } from '../../analytics/constants'; import { Languages, AvailableLanguages, LanguageOptions } from '../../code_examples'; @@ -48,16 +48,18 @@ export const CreateIndexCodeView = ({ [usageTracker, changeCodingLanguage] ); const elasticsearchUrl = useElasticsearchUrl(); + const { apiKey, apiKeyIsVisible } = useSearchApiKey(); + const codeParams = useMemo(() => { return { indexName: createIndexForm.indexName || undefined, elasticsearchURL: elasticsearchUrl, + apiKey: apiKeyIsVisible && apiKey ? apiKey : undefined, }; - }, [createIndexForm.indexName, elasticsearchUrl]); + }, [createIndexForm.indexName, elasticsearchUrl, apiKeyIsVisible, apiKey]); const selectedCodeExample = useMemo(() => { return selectedCodeExamples[selectedLanguage]; }, [selectedLanguage, selectedCodeExamples]); - const { displayedApiKey, apiKeyIsVisible } = useSearchApiKey(); return ( @@ -128,7 +130,6 @@ export const CreateIndexCodeView = ({ defaultMessage: 'Connect and create an index', })} language={Languages[selectedLanguage].codeBlockLanguage} - apiKey={apiKeyIsVisible ? displayedApiKey : null} code={selectedCodeExample.createIndex(codeParams)} onCodeCopyClick={() => { usageTracker.click([ diff --git a/x-pack/plugins/search_indices/server/routes/index.ts b/x-pack/plugins/search_indices/server/routes/index.ts index a383c8276c5a5..451647eb22774 100644 --- a/x-pack/plugins/search_indices/server/routes/index.ts +++ b/x-pack/plugins/search_indices/server/routes/index.ts @@ -8,7 +8,7 @@ import type { IRouter } from '@kbn/core/server'; import type { Logger } from '@kbn/logging'; -import { registerSearchApiKeysRoutes } from '@kbn/search-api-keys-api/server'; +import { registerSearchApiKeysRoutes } from '@kbn/search-api-keys-server'; import { registerIndicesRoutes } from './indices'; import { registerStatusRoutes } from './status'; diff --git a/x-pack/plugins/search_indices/tsconfig.json b/x-pack/plugins/search_indices/tsconfig.json index ca6763a6a8563..6d560ef1e96e4 100644 --- a/x-pack/plugins/search_indices/tsconfig.json +++ b/x-pack/plugins/search_indices/tsconfig.json @@ -34,11 +34,11 @@ "@kbn/cloud-plugin", "@kbn/search-index-documents", "@kbn/es-types", - "@kbn/search-api-keys-api", + "@kbn/search-api-keys-server", "@kbn/search-api-keys-components", "@kbn/search-shared-ui" ], "exclude": [ "target/**/*", ] -} +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index feeb131a69018..fdad4289c3b30 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6267,11 +6267,11 @@ version "0.0.0" uid "" -"@kbn/search-api-keys-api@link:packages/kbn-search-api-keys-api": +"@kbn/search-api-keys-components@link:packages/kbn-search-api-keys-components": version "0.0.0" uid "" -"@kbn/search-api-keys-components@link:packages/kbn-search-api-keys-components": +"@kbn/search-api-keys-server@link:packages/kbn-search-api-keys-server": version "0.0.0" uid ""