|
| 1 | +/* |
| 2 | + * Copyright OpenSearch Contributors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +import React from 'react'; |
| 7 | +import { I18nProvider } from '@osd/i18n/react'; |
| 8 | +import { Route, RouteComponentProps, Switch } from 'react-router-dom'; |
| 9 | +import { EuiPageSideBar, EuiSideNav, EuiPageTemplate } from '@elastic/eui'; |
| 10 | +import { CoreStart } from '../../../src/core/public'; |
| 11 | +import { Navigation, APP_PATH } from './utils'; |
| 12 | +import { Overview, UseCases, Workflows } from './pages'; |
| 13 | +import { CoreServicesConsumer } from './core_services'; |
| 14 | + |
| 15 | +interface Props extends RouteComponentProps {} |
| 16 | + |
| 17 | +export const AiFlowDashboardsApp = (props: Props) => { |
| 18 | + const sidebar = ( |
| 19 | + <EuiPageSideBar style={{ minWidth: 190 }} hidden={false}> |
| 20 | + <EuiSideNav |
| 21 | + style={{ width: 190 }} |
| 22 | + items={[ |
| 23 | + { |
| 24 | + name: Navigation.AiApplicationBuilder, |
| 25 | + id: 0, |
| 26 | + items: [ |
| 27 | + { |
| 28 | + name: Navigation.UseCases, |
| 29 | + id: 1, |
| 30 | + href: `#${APP_PATH.USE_CASES}`, |
| 31 | + isSelected: props.location.pathname === APP_PATH.USE_CASES, |
| 32 | + }, |
| 33 | + { |
| 34 | + name: Navigation.Workflows, |
| 35 | + id: 2, |
| 36 | + href: `#${APP_PATH.WORKFLOWS}`, |
| 37 | + isSelected: props.location.pathname === APP_PATH.WORKFLOWS, |
| 38 | + }, |
| 39 | + ], |
| 40 | + }, |
| 41 | + ]} |
| 42 | + /> |
| 43 | + </EuiPageSideBar> |
| 44 | + ); |
| 45 | + |
| 46 | + // Render the application DOM. |
| 47 | + return ( |
| 48 | + <CoreServicesConsumer> |
| 49 | + {(core: CoreStart | null) => |
| 50 | + core && ( |
| 51 | + <I18nProvider> |
| 52 | + <> |
| 53 | + <EuiPageTemplate |
| 54 | + template="empty" |
| 55 | + pageContentProps={{ paddingSize: 'm' }} |
| 56 | + pageSideBar={sidebar} |
| 57 | + > |
| 58 | + <Switch> |
| 59 | + <Route |
| 60 | + path={APP_PATH.USE_CASES} |
| 61 | + render={(props: RouteComponentProps) => <UseCases />} |
| 62 | + /> |
| 63 | + <Route |
| 64 | + path={APP_PATH.WORKFLOWS} |
| 65 | + render={(props: RouteComponentProps) => <Workflows />} |
| 66 | + /> |
| 67 | + {/* Defaulting to Overview page */} |
| 68 | + <Route |
| 69 | + path={`${APP_PATH.HOME}`} |
| 70 | + render={(props: RouteComponentProps) => <Overview />} |
| 71 | + /> |
| 72 | + </Switch> |
| 73 | + </EuiPageTemplate> |
| 74 | + </> |
| 75 | + </I18nProvider> |
| 76 | + ) |
| 77 | + } |
| 78 | + </CoreServicesConsumer> |
| 79 | + ); |
| 80 | +}; |
0 commit comments