Skip to content

Commit

Permalink
Add basic page infrastructure (#28)
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
(cherry picked from commit ac60ae0)
  • Loading branch information
ohltyler authored and github-actions[bot] committed Sep 13, 2023
1 parent e830158 commit 2eb84aa
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 9 deletions.
13 changes: 12 additions & 1 deletion public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React from 'react';
import { Route, RouteComponentProps, Switch } from 'react-router-dom';
import { EuiPageSideBar, EuiSideNav, EuiPageTemplate } from '@elastic/eui';
import { Navigation, APP_PATH } from './utils';
import { Overview, UseCases, Workflows } from './pages';
import { Overview, UseCases, Workflows, WorkflowBuilder } from './pages';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface Props extends RouteComponentProps {}
Expand All @@ -34,6 +34,13 @@ export const AiFlowDashboardsApp = (props: Props) => {
href: `#${APP_PATH.WORKFLOWS}`,
isSelected: props.location.pathname === APP_PATH.WORKFLOWS,
},
{
name: Navigation.WorkflowBuilder,
id: 3,
href: `#${APP_PATH.WORKFLOW_BUILDER}`,
isSelected:
props.location.pathname === APP_PATH.WORKFLOW_BUILDER,
},
],
},
]}
Expand All @@ -57,6 +64,10 @@ export const AiFlowDashboardsApp = (props: Props) => {
path={APP_PATH.WORKFLOWS}
render={(routeProps: RouteComponentProps) => <Workflows />}
/>
<Route
path={APP_PATH.WORKFLOW_BUILDER}
render={(routeProps: RouteComponentProps) => <WorkflowBuilder />}
/>
{/* Defaulting to Overview page */}
<Route
path={`${APP_PATH.HOME}`}
Expand Down
1 change: 1 addition & 0 deletions public/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
export * from './use_cases';
export * from './workflows';
export * from './overview';
export * from './workflow_builder';
6 changes: 6 additions & 0 deletions public/pages/use_cases/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { UseCase } from './use_case';
53 changes: 53 additions & 0 deletions public/pages/use_cases/components/use_case.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React, { useEffect } from 'react';
import {
EuiText,
EuiFlexGroup,
EuiFlexItem,
EuiTitle,
EuiCard,
EuiHorizontalRule,
EuiButton,
} from '@elastic/eui';
interface UseCaseProps {
title: string;
description: string;
}

export function UseCase(props: UseCaseProps) {
return (
<EuiCard
title={
<EuiTitle size="s">
<h2>{props.title}</h2>
</EuiTitle>
}
titleSize="s"
paddingSize="l"
>
<EuiFlexGroup direction="column" gutterSize="l">
<EuiHorizontalRule size="full" margin="m" />
<EuiFlexItem grow={true}>
<EuiText>{props.description}</EuiText>
</EuiFlexItem>
<EuiFlexGroup direction="column" alignItems="center">
<EuiFlexItem grow={false}>
<EuiButton
disabled={false}
isLoading={false}
onClick={() => {
// TODO: possibly link to the workflow builder with a pre-configured flow
}}
>
Go
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexGroup>
</EuiCard>
);
}
45 changes: 41 additions & 4 deletions public/pages/use_cases/use_cases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
*/

import React, { useEffect } from 'react';
import { EuiPageHeader, EuiText } from '@elastic/eui';
import {
EuiPageHeader,
EuiFlexGroup,
EuiFlexItem,
EuiTitle,
EuiFlexGrid,
EuiSpacer,
} from '@elastic/eui';
import { BREADCRUMBS } from '../../utils';
import { UseCase } from './components';
import { getCore } from '../../services';

export function UseCases() {
Expand All @@ -17,8 +25,37 @@ export function UseCases() {
});

return (
<EuiPageHeader>
<EuiText>Use cases page placeholder...</EuiText>
</EuiPageHeader>
<div>
<EuiPageHeader>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiTitle size="l">
<h1>Use Cases</h1>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPageHeader>
<EuiSpacer size="l" />
<EuiFlexGrid columns={3} gutterSize="l">
<EuiFlexItem>
<UseCase
title="Semantic Search"
description="Semantic search description..."
/>
</EuiFlexItem>
<EuiFlexItem>
<UseCase
title="Multi-modal Search"
description="Multi-modal search description..."
/>
</EuiFlexItem>
<EuiFlexItem>
<UseCase
title="Search Summarization"
description="Search summarization description..."
/>
</EuiFlexItem>
</EuiFlexGrid>
</div>
);
}
6 changes: 6 additions & 0 deletions public/pages/workflow_builder/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { WorkflowBuilder } from './workflow_builder';
43 changes: 43 additions & 0 deletions public/pages/workflow_builder/workflow_builder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React, { useEffect } from 'react';
import {
EuiPageHeader,
EuiFlexGroup,
EuiFlexItem,
EuiTitle,
EuiText,
EuiSpacer,
} from '@elastic/eui';
import { BREADCRUMBS } from '../../utils';
import { getCore } from '../../services';

export function WorkflowBuilder() {
useEffect(() => {
getCore().chrome.setBreadcrumbs([
BREADCRUMBS.AI_APPLICATION_BUILDER,
BREADCRUMBS.WORKFLOW_BUILDER,
]);
});

return (
<div>
<EuiPageHeader>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiTitle size="l">
<h1>Workflow Builder</h1>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPageHeader>
<EuiSpacer size="l" />
<EuiFlexItem>
<EuiText>Placeholder for workflow builder page...</EuiText>
</EuiFlexItem>
</div>
);
}
6 changes: 6 additions & 0 deletions public/pages/workflows/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { WorkflowList } from './workflow_list';
79 changes: 79 additions & 0 deletions public/pages/workflows/components/workflow_list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React, { useState } from 'react';
import { EuiBasicTable } from '@elastic/eui';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface WorkflowListProps {}

interface WorkflowItem {
name: string;
description: string;
}

export function WorkflowList(props: WorkflowListProps) {
const [pageIndex, setPageIndex] = useState(0);
const [pageSize, setPageSize] = useState(5);
const [sortField, setSortField] = useState('name');
const [sortDirection, setSortDirection] = useState('asc');

const columns = [
{
field: 'name',
name: 'Name',
sortable: true,
},
{
field: 'description',
name: 'Description',
sortable: false,
},
];

const items = [
{
name: 'Workflow 1',
},
] as WorkflowItem[];

const sorting = {
sort: {
field: sortField,
direction: sortDirection,
},
enableAllColumns: false,
readOnly: false,
};

const pagination = {
pageIndex,
pageSize,
totalItemCount: items.length,
pageSizeOptions: [5, 10, 20],
};

const onTableChange = ({ page = {}, sort = {} }) => {
const { index, size } = page;
const { field, direction } = sort;

setPageIndex(index);
setPageSize(size);
setSortField(field);
setSortDirection(direction);
};

return (
<EuiBasicTable<WorkflowItem>
items={items}
rowHeader="name"
columns={columns}
sorting={sorting}
pagination={pagination}
onChange={onTableChange}
noItemsMessage={'No existing workflows found'}
/>
);
}
29 changes: 25 additions & 4 deletions public/pages/workflows/workflows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
*/

import React, { useEffect } from 'react';
import { EuiPageHeader, EuiText } from '@elastic/eui';
import {
EuiPageHeader,
EuiTitle,
EuiFlexGroup,
EuiFlexItem,
EuiSpacer,
} from '@elastic/eui';
import { BREADCRUMBS } from '../../utils';
import { getCore } from '../../services';
import { WorkflowList } from './components';

export function Workflows() {
useEffect(() => {
Expand All @@ -17,8 +24,22 @@ export function Workflows() {
});

return (
<EuiPageHeader>
<EuiText>Workflows page placeholder...</EuiText>
</EuiPageHeader>
<div>
<EuiPageHeader>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiTitle size="l">
<h1>Workflows</h1>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPageHeader>
<EuiSpacer size="m" />
<EuiFlexGroup>
<EuiFlexItem>
<WorkflowList />
</EuiFlexItem>
</EuiFlexGroup>
</div>
);
}
6 changes: 6 additions & 0 deletions public/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum Navigation {
AiApplicationBuilder = 'AI Application Builder',
UseCases = 'Use Cases',
Workflows = 'Workflows',
WorkflowBuilder = 'Workflow Builder',
}

export enum APP_PATH {
Expand All @@ -15,10 +16,15 @@ export enum APP_PATH {
WORKSPACE = '/workspace',
WORKFLOWS = '/workflows',
WORKFLOW_DETAIL = '/workflows/:workflowId/',
WORKFLOW_BUILDER = '/workflow-builder',
}

export const BREADCRUMBS = Object.freeze({
AI_APPLICATION_BUILDER: { text: 'AI application builder', href: '#/' },
USE_CASES: { text: 'Use cases', href: `#${APP_PATH.USE_CASES}` },
WORKFLOWS: { text: 'Workflows', href: `#${APP_PATH.WORKFLOWS}` },
WORKFLOW_BUILDER: {
text: 'Workflow builder',
href: `#${APP_PATH.WORKFLOW_BUILDER}`,
},
});

0 comments on commit 2eb84aa

Please sign in to comment.