Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Search] fix: update vector search snippets to use try in console button #178402

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
import React from 'react';

import { useValues } from 'kea';
import { compressToEncodedURIComponent } from 'lz-string';

import {
EuiButtonEmpty,
EuiCodeBlock,
EuiCodeBlockProps,
EuiCopy,
EuiFlexGroup,
EuiFlexItem,
EuiHorizontalRule,
EuiPanel,
EuiThemeProvider,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { TryInConsoleButton } from '@kbn/search-api-panels';

import { KibanaLogic } from '../../../shared/kibana';

Expand All @@ -32,49 +33,42 @@ export const DevToolsConsoleCodeBlock: React.FC<DevToolsConsoleCodeBlockProps> =
children,
...props
}) => {
const {
application,
share: { url },
} = useValues(KibanaLogic);
const { application, consolePlugin, share } = useValues(KibanaLogic);

const consolePreviewLink =
!!application?.capabilities?.dev_tools?.show &&
url.locators
.get('CONSOLE_APP_LOCATOR')
?.useUrl(
{ loadFrom: `data:text/plain,${compressToEncodedURIComponent(children)}` },
undefined,
[]
);
const showConsoleLink = !!application?.capabilities?.dev_tools?.show;

return (
<EuiThemeProvider colorMode="dark">
<EuiPanel hasShadow={false}>
<EuiFlexGroup direction="column" gutterSize="xs">
<EuiFlexGroup direction="rowReverse" gutterSize="s">
{consolePreviewLink && (
<EuiButtonEmpty
iconType="popout"
color="success"
href={consolePreviewLink}
target="_blank"
>
<FormattedMessage
id="xpack.enterpriseSearch.component.devToolsConsoleCodeBlock.tryInConsole"
defaultMessage="Try in Console"
<EuiFlexGroup
direction="rowReverse"
gutterSize="s"
alignItems="center"
responsive={false}
>
{showConsoleLink && (
<EuiFlexItem grow={false}>
<TryInConsoleButton
request={children}
application={application}
consolePlugin={consolePlugin}
sharePlugin={share}
/>
</EuiButtonEmpty>
</EuiFlexItem>
)}
<EuiCopy textToCopy={children}>
{(copy) => (
<EuiButtonEmpty iconType="copyClipboard" onClick={copy} color="text">
<FormattedMessage
id="xpack.enterpriseSearch.component.devToolsConsoleCodeBlock.copy"
defaultMessage="Copy"
/>
</EuiButtonEmpty>
)}
</EuiCopy>
<EuiFlexItem grow={false}>
<EuiCopy textToCopy={children}>
{(copy) => (
<EuiButtonEmpty color="text" iconType="copyClipboard" size="s" onClick={copy}>
<FormattedMessage
id="xpack.enterpriseSearch.component.devToolsConsoleCodeBlock.copy"
defaultMessage="Copy"
/>
</EuiButtonEmpty>
)}
</EuiCopy>
</EuiFlexItem>
</EuiFlexGroup>
<EuiHorizontalRule margin="xs" />
<EuiCodeBlock
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -13857,7 +13857,6 @@
"xpack.enterpriseSearch.betaConnectorCalloutTitle": "Connecteur en version bêta",
"xpack.enterpriseSearch.betaLabel": "Bêta",
"xpack.enterpriseSearch.component.devToolsConsoleCodeBlock.copy": "Copier",
"xpack.enterpriseSearch.component.devToolsConsoleCodeBlock.tryInConsole": "Essayer dans la console",
"xpack.enterpriseSearch.connector.connectorTypePanel.title": "Type de connecteur",
"xpack.enterpriseSearch.connector.connectorTypePanel.unknown.label": "Inconnu",
"xpack.enterpriseSearch.connector.ingestionStatus.title": "Statut de l'ingestion",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -13870,7 +13870,6 @@
"xpack.enterpriseSearch.betaConnectorCalloutTitle": "ベータ版コネクター",
"xpack.enterpriseSearch.betaLabel": "ベータ",
"xpack.enterpriseSearch.component.devToolsConsoleCodeBlock.copy": "コピー",
"xpack.enterpriseSearch.component.devToolsConsoleCodeBlock.tryInConsole": "コンソールで試す",
"xpack.enterpriseSearch.connector.connectorTypePanel.title": "コネクタータイプ",
"xpack.enterpriseSearch.connector.connectorTypePanel.unknown.label": "不明",
"xpack.enterpriseSearch.connector.ingestionStatus.title": "インジェスチョンステータス",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -13964,7 +13964,6 @@
"xpack.enterpriseSearch.betaConnectorCalloutTitle": "公测版连接器",
"xpack.enterpriseSearch.betaLabel": "公测版",
"xpack.enterpriseSearch.component.devToolsConsoleCodeBlock.copy": "复制",
"xpack.enterpriseSearch.component.devToolsConsoleCodeBlock.tryInConsole": "在 Console 中试用",
"xpack.enterpriseSearch.connector.connectorTypePanel.title": "连接器类型",
"xpack.enterpriseSearch.connector.connectorTypePanel.unknown.label": "未知",
"xpack.enterpriseSearch.connector.ingestionStatus.title": "采集状态",
Expand Down