Skip to content

Commit

Permalink
[Search] Moving search-empty-prompt to a shared package (elastic#204545)
Browse files Browse the repository at this point in the history
## Summary

The goal for this PR is to move the `search-empty-propmpt` we use as a
Empty states and coming soon pages in Serverless to a shared package in
order to be able to reuse this layout and some parts of the content
either in Stack or Serverless.

After merging this PR, next one will bring this content to Stack:
[[Search][Stack] Web Crawlers coming soon
pages](elastic#204768)

References:
- [Packages / Internal Dependency
Management](https://docs.elastic.dev/kibana-dev-docs/ops/packages)

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
3 people authored Dec 19, 2024
1 parent 5599174 commit 4f4772f
Show file tree
Hide file tree
Showing 25 changed files with 956 additions and 960 deletions.
3 changes: 3 additions & 0 deletions x-pack/packages/search/shared_ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
* 2.0.
*/

export * from './src/connector_icon';
export * from './src/decorative_horizontal_stepper';
export * from './src/form_info_field/form_info_field';
export * from './src/search_empty_prompt';
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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 { EuiToolTip, EuiIcon } from '@elastic/eui';

interface ConnectorIconProps {
name: string;
serviceType: string;
iconPath?: string;
showTooltip?: boolean;
}

export const ConnectorIcon: React.FC<ConnectorIconProps> = ({
name,
serviceType,
iconPath,
showTooltip = true,
}) => {
const icon = <EuiIcon size="l" title={name} id={serviceType} type={iconPath || 'defaultIcon'} />;

return showTooltip ? <EuiToolTip content={name}>{icon}</EuiToolTip> : icon;
};
8 changes: 8 additions & 0 deletions x-pack/packages/search/shared_ui/src/connector_icon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

export * from './connector_icon';
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 { EuiStepsHorizontal, EuiStepsHorizontalProps } from '@elastic/eui';
import { css } from '@emotion/react';

interface DecorativeHorizontalStepperProps {
stepCount?: number;
}

export const DecorativeHorizontalStepper: React.FC<DecorativeHorizontalStepperProps> = ({
stepCount = 2,
}) => {
// Generate the steps dynamically based on the stepCount prop
const horizontalSteps: EuiStepsHorizontalProps['steps'] = Array.from(
{ length: stepCount },
(_, index) => ({
title: '',
status: 'incomplete',
onClick: () => {},
})
);

return (
/* This is a presentational component, not intended for user interaction:
pointer-events: none, prevents user interaction with the component.
inert prevents click, focus, and other interactive events, removing it from the tab order.
role="presentation" indicates that this component is purely decorative and not interactive for assistive technologies.
Together, these attributes help ensure the component is accesible. */
<EuiStepsHorizontal
css={css`
pointer-events: none;
`}
steps={horizontalSteps}
size="s"
role="presentation"
// @ts-ignore due to React 18 and TypeScript doesn't have native HTML inert attribute support yet
inert=""
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* 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.
*/
export * from './decorative_horizontal_stepper';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

export * from './search_empty_prompt';
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* 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 {
EuiFlexGroup,
EuiFlexItem,
EuiPanel,
EuiIcon,
EuiTitle,
EuiText,
EuiButtonEmpty,
EuiBadge,
} from '@elastic/eui';

interface BackButtonProps {
label: string;
onClickBack: () => void;
}
interface SearchEmptyPromptProps {
actions?: React.ReactNode;
backButton?: BackButtonProps;
body?: React.ReactNode;
description?: string;
icon?: string | React.JSXElementConstructor<any>;
isComingSoon?: boolean;
comingSoonLabel?: string;
title: string;
}

export const SearchEmptyPrompt: React.FC<SearchEmptyPromptProps> = ({
actions,
backButton,
body,
description,
icon,
isComingSoon,
comingSoonLabel,
title,
}) => {
return (
<EuiPanel paddingSize="l" hasShadow={false} hasBorder>
<EuiFlexGroup alignItems="center" justifyContent="center" direction="column" gutterSize="l">
{backButton && (
<EuiFlexItem>
<EuiButtonEmpty
data-test-subj="serverlessSearchElasticManagedWebCrawlerEmptyBackButton"
iconType="arrowLeft"
onClick={backButton.onClickBack}
>
{backButton.label}
</EuiButtonEmpty>
</EuiFlexItem>
)}
{icon && (
<EuiFlexItem>
<EuiIcon size="xxl" type={icon} />
</EuiFlexItem>
)}
<EuiFlexItem>
<EuiTitle>
<h2>{title}</h2>
</EuiTitle>
</EuiFlexItem>
{isComingSoon && (
<EuiFlexItem>
<EuiBadge color="accent">{comingSoonLabel}</EuiBadge>
</EuiFlexItem>
)}
{description && (
<EuiFlexItem>
<EuiText textAlign="center" color="subdued">
<p>{description}</p>
</EuiText>
</EuiFlexItem>
)}
{body && <>{body}</>}
{actions && (
<EuiFlexGroup direction="row" gutterSize="m">
{actions}
</EuiFlexGroup>
)}
</EuiFlexGroup>
</EuiPanel>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -42632,13 +42632,11 @@
"xpack.serverlessSearch.connectors.typeLabel": "Type",
"xpack.serverlessSearch.connectors.variablesTitle": "Variable pour votre {url}",
"xpack.serverlessSearch.connectors.waitingForConnection": "En attente de connexion",
"xpack.serverlessSearch.connectorsEmpty.description": "La configuration et le déploiement d'un connecteur se passe entre la source de données tierce, votre terminal et l'UI sans serveur d'Elasticsearch. Le processus à haut niveau ressemble à ça :",
"xpack.serverlessSearch.connectorsEmpty.dockerLabel": "Docker",
"xpack.serverlessSearch.connectorsEmpty.guideOneDescription": "Choisissez une source de données à synchroniser",
"xpack.serverlessSearch.connectorsEmpty.guideThreeDescription": "Saisissez les informations d'accès et de connexion pour votre source de données et exécutez votre première synchronisation",
"xpack.serverlessSearch.connectorsEmpty.guideTwoDescription": "Déployez le code du connecteur sur votre propre infrastructure en exécutant {source} ou à l'aide de {docker}",
"xpack.serverlessSearch.connectorsEmpty.sourceLabel": "source",
"xpack.serverlessSearch.connectorsEmpty.title": "Créer un connecteur",
"xpack.serverlessSearch.connectorsPythonLink": "elastic/connecteurs",
"xpack.serverlessSearch.connectorsTable.summaryLabel": "Affichage des {items} de {count} {connectors}",
"xpack.serverlessSearch.disabled": "Désactivé",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42489,13 +42489,11 @@
"xpack.serverlessSearch.connectors.typeLabel": "型",
"xpack.serverlessSearch.connectors.variablesTitle": "{url}の変数",
"xpack.serverlessSearch.connectors.waitingForConnection": "接続を待機中",
"xpack.serverlessSearch.connectorsEmpty.description": "コネクターを設定およびデプロイするには、サードパーティのデータソース、端末、ElasticsearchサーバーレスUI の間で作業することになります。プロセスの概要は次のとおりです。",
"xpack.serverlessSearch.connectorsEmpty.dockerLabel": "Docker",
"xpack.serverlessSearch.connectorsEmpty.guideOneDescription": "同期したいデータソースを選択します。",
"xpack.serverlessSearch.connectorsEmpty.guideThreeDescription": "データソースのアクセスと接続の詳細情報を入力し、最初の同期を実行します",
"xpack.serverlessSearch.connectorsEmpty.guideTwoDescription": "{source}から実行するか、{docker}を使用して、独自のインフラにコネクターコードをデプロイします。",
"xpack.serverlessSearch.connectorsEmpty.sourceLabel": "ソース",
"xpack.serverlessSearch.connectorsEmpty.title": "コネクターを作成する",
"xpack.serverlessSearch.connectorsPythonLink": "elastic/コネクター",
"xpack.serverlessSearch.connectorsTable.summaryLabel": "{count} {connectors}中{items}を表示中",
"xpack.serverlessSearch.disabled": "無効",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41877,13 +41877,11 @@
"xpack.serverlessSearch.connectors.typeLabel": "类型",
"xpack.serverlessSearch.connectors.variablesTitle": "您的 {url} 的变量",
"xpack.serverlessSearch.connectors.waitingForConnection": "等待连接",
"xpack.serverlessSearch.connectorsEmpty.description": "要设置并部署连接器,您需要在第三方数据源、终端与 Elasticsearch 无服务器 UI 之间开展工作。高级流程类似于这样:",
"xpack.serverlessSearch.connectorsEmpty.dockerLabel": "Docker",
"xpack.serverlessSearch.connectorsEmpty.guideOneDescription": "选择要同步的数据源",
"xpack.serverlessSearch.connectorsEmpty.guideThreeDescription": "输入您数据源的访问权限和连接详情,然后运行第一次同步",
"xpack.serverlessSearch.connectorsEmpty.guideTwoDescription": "通过从 {source} 运行或使用 {docker} 在您自己的基础设施上部署连接器代码",
"xpack.serverlessSearch.connectorsEmpty.sourceLabel": "源",
"xpack.serverlessSearch.connectorsEmpty.title": "创建连接器",
"xpack.serverlessSearch.connectorsPythonLink": "Elastic/连接器",
"xpack.serverlessSearch.connectorsTable.summaryLabel": "正在显示 {items} 个(共 {count} 个){connectors}",
"xpack.serverlessSearch.disabled": "已禁用",
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/serverless_search/common/i18n_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export const TECH_PREVIEW_LABEL: string = i18n.translate('xpack.serverlessSearch
defaultMessage: 'Tech preview',
});

export const COMING_SOON_LABEL: string = i18n.translate('xpack.serverlessSearch.comingSoon', {
defaultMessage: 'Coming soon',
});

export const INVALID_JSON_ERROR: string = i18n.translate(
'xpack.serverlessSearch.invalidJsonError',
{
Expand Down
Loading

0 comments on commit 4f4772f

Please sign in to comment.