Skip to content

Commit c77a2be

Browse files
UX fit-n-finish updates XI (#613) (#614)
(cherry picked from commit c3a9eb8) Signed-off-by: saimedhi <saimedhi@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent ee7ec89 commit c77a2be

File tree

3 files changed

+156
-95
lines changed

3 files changed

+156
-95
lines changed

public/pages/workflows/workflows.tsx

+142-95
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ import {
1616
EuiSmallButton,
1717
EuiText,
1818
EuiFlexItem,
19+
EuiEmptyPrompt,
20+
EuiButton,
1921
} from '@elastic/eui';
2022
import queryString from 'query-string';
2123
import { useSelector } from 'react-redux';
22-
import { BREADCRUMBS, USE_NEW_HOME_PAGE } from '../../utils/constants';
24+
import {
25+
BREADCRUMBS,
26+
USE_NEW_HOME_PAGE,
27+
getAppBasePath,
28+
} from '../../utils/constants';
2329
import { getApplication, getCore, getNavigationUI } from '../../services';
2430
import { WorkflowList } from './workflow_list';
2531
import { NewWorkflow } from './new_workflow';
@@ -257,103 +263,144 @@ export function Workflows(props: WorkflowsProps) {
257263
<EuiPageBody>
258264
<EuiPageHeader
259265
pageTitle={pageTitleAndDescription}
260-
tabs={[
261-
{
262-
id: WORKFLOWS_TAB.MANAGE,
263-
label: 'Manage workflows',
264-
isSelected: selectedTabId === WORKFLOWS_TAB.MANAGE,
265-
onClick: () => {
266-
setSelectedTabId(WORKFLOWS_TAB.MANAGE);
267-
replaceActiveTab(WORKFLOWS_TAB.MANAGE, props, dataSourceId);
268-
},
269-
},
270-
{
271-
id: WORKFLOWS_TAB.CREATE,
272-
label: 'New workflow',
273-
isSelected: selectedTabId === WORKFLOWS_TAB.CREATE,
274-
onClick: () => {
275-
setSelectedTabId(WORKFLOWS_TAB.CREATE);
276-
replaceActiveTab(WORKFLOWS_TAB.CREATE, props, dataSourceId);
277-
},
278-
},
279-
]}
280-
bottomBorder={true}
266+
bottomBorder={false}
281267
/>
268+
{dataSourceEnabled && (dataSourceId === undefined) ? (
269+
<EuiPageContent grow={true}>
270+
<EuiEmptyPrompt
271+
title={<h2>Incompatible data source</h2>}
272+
body={
273+
<p>
274+
No compatible data source available. Add a compatible data
275+
source.
276+
</p>
277+
}
278+
actions={
279+
<EuiButton
280+
color="primary"
281+
fill
282+
href={`${getAppBasePath()}/app/management/opensearch-dashboards/dataSources`}
283+
>
284+
Manage data sources
285+
</EuiButton>
286+
}
287+
/>
288+
</EuiPageContent>
289+
) : (
290+
<>
291+
<EuiPageHeader
292+
tabs={[
293+
{
294+
id: WORKFLOWS_TAB.MANAGE,
295+
label: 'Manage workflows',
296+
isSelected: selectedTabId === WORKFLOWS_TAB.MANAGE,
297+
onClick: () => {
298+
setSelectedTabId(WORKFLOWS_TAB.MANAGE);
299+
replaceActiveTab(
300+
WORKFLOWS_TAB.MANAGE,
301+
props,
302+
dataSourceId
303+
);
304+
},
305+
},
306+
{
307+
id: WORKFLOWS_TAB.CREATE,
308+
label: 'New workflow',
309+
isSelected: selectedTabId === WORKFLOWS_TAB.CREATE,
310+
onClick: () => {
311+
setSelectedTabId(WORKFLOWS_TAB.CREATE);
312+
replaceActiveTab(
313+
WORKFLOWS_TAB.CREATE,
314+
props,
315+
dataSourceId
316+
);
317+
},
318+
},
319+
]}
320+
bottomBorder={true}
321+
style={{ paddingBottom: '0px' }}
322+
/>
282323

283-
<EuiPageContent grow={false}>
284-
<EuiPageHeader
285-
style={{ marginTop: '-8px' }}
286-
pageTitle={
287-
<EuiText size="s">
288-
<h2>
289-
{selectedTabId === WORKFLOWS_TAB.MANAGE
290-
? 'Workflows'
291-
: 'Create a workflow using a template'}
292-
</h2>
293-
</EuiText>
294-
}
295-
rightSideItems={
296-
selectedTabId === WORKFLOWS_TAB.MANAGE
297-
? [
298-
<EuiSmallButton
299-
style={{ marginTop: '8px' }}
300-
fill={true}
301-
onClick={() => {
302-
setSelectedTabId(WORKFLOWS_TAB.CREATE);
303-
replaceActiveTab(
304-
WORKFLOWS_TAB.CREATE,
305-
props,
306-
dataSourceId
307-
);
308-
}}
309-
iconType="plus"
310-
data-testid="createWorkflowButton"
311-
>
312-
Create workflow
313-
</EuiSmallButton>,
314-
<EuiSmallButton
315-
style={{ marginTop: '8px' }}
316-
onClick={() => {
317-
setIsImportModalOpen(true);
318-
}}
319-
data-testid="importWorkflowButton"
320-
>
321-
Import workflow
322-
</EuiSmallButton>,
323-
]
324-
: [
325-
<EuiSmallButton
326-
style={{ marginTop: '8px' }}
327-
onClick={() => {
328-
setIsImportModalOpen(true);
329-
}}
330-
data-testid="importWorkflowButton"
331-
>
332-
Import workflow
333-
</EuiSmallButton>,
334-
]
335-
}
336-
bottomBorder={false}
337-
/>
338-
{selectedTabId === WORKFLOWS_TAB.MANAGE ? (
339-
<WorkflowList setSelectedTabId={setSelectedTabId} />
340-
) : (
341-
<>
342-
<EuiSpacer size="s" />
343-
<NewWorkflow />
344-
</>
345-
)}
346-
{selectedTabId === WORKFLOWS_TAB.MANAGE &&
347-
Object.keys(workflows || {}).length === 0 &&
348-
!loading && (
349-
<EmptyListMessage
350-
onClickNewWorkflow={() => {
351-
setSelectedTabId(WORKFLOWS_TAB.CREATE);
352-
replaceActiveTab(WORKFLOWS_TAB.CREATE, props, dataSourceId);
353-
}}
324+
<EuiPageContent grow={false}>
325+
<EuiPageHeader
326+
style={{ marginTop: '-8px' }}
327+
pageTitle={
328+
<EuiText size="s">
329+
<h2>
330+
{selectedTabId === WORKFLOWS_TAB.MANAGE
331+
? 'Workflows'
332+
: 'Create a workflow using a template'}
333+
</h2>
334+
</EuiText>
335+
}
336+
rightSideItems={
337+
selectedTabId === WORKFLOWS_TAB.MANAGE
338+
? [
339+
<EuiSmallButton
340+
style={{ marginTop: '8px' }}
341+
fill={true}
342+
onClick={() => {
343+
setSelectedTabId(WORKFLOWS_TAB.CREATE);
344+
replaceActiveTab(
345+
WORKFLOWS_TAB.CREATE,
346+
props,
347+
dataSourceId
348+
);
349+
}}
350+
iconType="plus"
351+
data-testid="createWorkflowButton"
352+
>
353+
Create workflow
354+
</EuiSmallButton>,
355+
<EuiSmallButton
356+
style={{ marginTop: '8px' }}
357+
onClick={() => {
358+
setIsImportModalOpen(true);
359+
}}
360+
data-testid="importWorkflowButton"
361+
>
362+
Import workflow
363+
</EuiSmallButton>,
364+
]
365+
: [
366+
<EuiSmallButton
367+
style={{ marginTop: '8px' }}
368+
onClick={() => {
369+
setIsImportModalOpen(true);
370+
}}
371+
data-testid="importWorkflowButton"
372+
>
373+
Import workflow
374+
</EuiSmallButton>,
375+
]
376+
}
377+
bottomBorder={false}
354378
/>
355-
)}
356-
</EuiPageContent>
379+
{selectedTabId === WORKFLOWS_TAB.MANAGE ? (
380+
<WorkflowList setSelectedTabId={setSelectedTabId} />
381+
) : (
382+
<>
383+
<EuiSpacer size="s" />
384+
<NewWorkflow />
385+
</>
386+
)}
387+
{selectedTabId === WORKFLOWS_TAB.MANAGE &&
388+
Object.keys(workflows || {}).length === 0 &&
389+
!loading && (
390+
<EmptyListMessage
391+
onClickNewWorkflow={() => {
392+
setSelectedTabId(WORKFLOWS_TAB.CREATE);
393+
replaceActiveTab(
394+
WORKFLOWS_TAB.CREATE,
395+
props,
396+
dataSourceId
397+
);
398+
}}
399+
/>
400+
)}
401+
</EuiPageContent>
402+
</>
403+
)}
357404
</EuiPageBody>
358405
</EuiPage>
359406
</>

public/utils/constants.ts

+5
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ export const BREADCRUMBS = Object.freeze({
3535
});
3636

3737
export const USE_NEW_HOME_PAGE = getUISettings().get('home:useNewHomePage');
38+
39+
export const getAppBasePath = () => {
40+
const currentPath = window.location.pathname;
41+
return currentPath.substring(0, currentPath.indexOf('/app/'));
42+
};

public/utils/utils.ts

+9
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
Connector,
4747
IngestPipelineErrors,
4848
InputMapEntry,
49+
MapFormValue,
4950
MDSQueryParams,
5051
ModelInputMap,
5152
ModelOutputMap,
@@ -731,6 +732,10 @@ export function getEmbeddingField(
731732
): string | undefined {
732733
let embeddingField = getEmbeddingFieldFromConnector(connector);
733734
const outputMap = processorConfig?.output_map as OutputMapFormValue;
735+
// legacy text_embedding / text_image_embedding processors store vector fields
736+
// in different configs
737+
const fieldMap = processorConfig?.field_map as MapFormValue; // text embedding processor
738+
const embedding = processorConfig?.embedding; // text/image embedding processor
734739
if (
735740
outputMap !== undefined &&
736741
outputMap[0] !== undefined &&
@@ -759,6 +764,10 @@ export function getEmbeddingField(
759764
break;
760765
}
761766
}
767+
} else if (embedding !== undefined) {
768+
embeddingField = embedding
769+
} else if (fieldMap !== undefined) {
770+
embeddingField = get(fieldMap, '0.value', embeddingField)
762771
}
763772
return embeddingField;
764773
}

0 commit comments

Comments
 (0)