forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request elastic#13 from yansavitski/ai-playground-update-s…
…ources Ai playground update sources
- Loading branch information
Showing
8 changed files
with
263 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/kbn-ai-playground/components/sources_panel/indices_list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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 { EuiFormRow, EuiListGroup, EuiListGroupItem } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
interface IndicesListProps { | ||
indices: string[]; | ||
onRemoveClick: (index: string) => void; | ||
hasBorder?: boolean; | ||
} | ||
|
||
export const IndicesList: React.FC<IndicesListProps> = ({ indices, onRemoveClick, hasBorder }) => | ||
indices?.length ? ( | ||
<EuiFormRow | ||
fullWidth | ||
label={i18n.translate('aiPlayground.sources.indices.label', { | ||
defaultMessage: 'Selected indices', | ||
})} | ||
labelType="legend" | ||
> | ||
<EuiListGroup bordered={hasBorder} maxWidth={false} wrapText> | ||
{indices.map((index) => ( | ||
<EuiListGroupItem | ||
key={index} | ||
wrapText | ||
color="primary" | ||
label={index} | ||
size="s" | ||
extraAction={{ | ||
alwaysShow: true, | ||
'aria-label': i18n.translate('aiPlayground.sources.indices.removeIndex', { | ||
defaultMessage: 'Remove index from sources', | ||
}), | ||
color: 'text', | ||
iconType: 'minusInCircle', | ||
onClick: () => onRemoveClick(index), | ||
disabled: indices.length === 1, | ||
}} | ||
/> | ||
))} | ||
</EuiListGroup> | ||
</EuiFormRow> | ||
) : null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
packages/kbn-ai-playground/components/sources_panel/sources_panel.tsx
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
packages/kbn-ai-playground/components/sources_panel/sources_panel_empty_prompt.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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 { | ||
EuiPanel, | ||
EuiTitle, | ||
EuiText, | ||
EuiLink, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiSpacer, | ||
} from '@elastic/eui'; | ||
import React from 'react'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { AddIndicesField } from './add_indices_field'; | ||
import { IndicesTable } from './indices_table'; | ||
|
||
export const SourcesPanelEmptyPrompt: React.FC = () => { | ||
const indices = ['search-index', 'search-books']; | ||
const [selectedIndices, setSelectedIndices] = React.useState<string[]>([]); | ||
const addIndex = (newIndex: string) => { | ||
setSelectedIndices([...selectedIndices, newIndex]); | ||
}; | ||
const removeIndex = (index: string) => { | ||
setSelectedIndices(selectedIndices.filter((indexName) => indexName !== index)); | ||
}; | ||
|
||
return ( | ||
<EuiPanel hasBorder paddingSize="l"> | ||
<EuiTitle size="xs"> | ||
<h5> | ||
<FormattedMessage | ||
id="aiPlayground.emptyPrompts.sources.title" | ||
defaultMessage="Select sources" | ||
/> | ||
</h5> | ||
</EuiTitle> | ||
|
||
<EuiSpacer size="s" /> | ||
|
||
<EuiFlexGroup direction="column" gutterSize="xl"> | ||
<EuiText size="s"> | ||
<p> | ||
<FormattedMessage | ||
id="aiPlayground.emptyPrompts.sources.description" | ||
defaultMessage="Where should the data for this chat experience be retrieved from?" | ||
/> | ||
</p> | ||
</EuiText> | ||
|
||
{!!selectedIndices?.length && ( | ||
<EuiFlexItem> | ||
<IndicesTable indices={selectedIndices} onRemoveClick={removeIndex} /> | ||
</EuiFlexItem> | ||
)} | ||
|
||
<EuiFlexItem> | ||
<AddIndicesField | ||
selectedIndices={selectedIndices} | ||
indices={indices} | ||
onIndexSelect={addIndex} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPanel> | ||
); | ||
}; |
Oops, something went wrong.