From 86160367656a79204ca5f45d3df355b3c7ff2ce3 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Tue, 10 Mar 2020 16:56:16 +0000 Subject: [PATCH] use path navigartion in place of state --- .../alerting_example/public/application.tsx | 47 ++++-------- .../alerting_example/public/documentation.tsx | 2 +- examples/alerting_example/public/plugin.tsx | 11 +-- .../alerting_example/public/view_alert.tsx | 75 ++++++++----------- .../alerting/common/alert_navigation.ts | 2 +- x-pack/plugins/alerting/public/plugin.ts | 2 +- .../alert_details/components/view_in_app.tsx | 40 ++++------ .../fixtures/plugins/alerts/public/plugin.tsx | 10 +-- 8 files changed, 69 insertions(+), 120 deletions(-) diff --git a/examples/alerting_example/public/application.tsx b/examples/alerting_example/public/application.tsx index 9653c7290d627..e77b38a326a15 100644 --- a/examples/alerting_example/public/application.tsx +++ b/examples/alerting_example/public/application.tsx @@ -20,16 +20,8 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter as Router, Route, withRouter, RouteComponentProps } from 'react-router-dom'; - -import { - EuiPage, - EuiPageSideBar, - // @ts-ignore - EuiSideNav, -} from '@elastic/eui'; - -import { JsonObject } from '../../../src/plugins/kibana_utils/common'; -import { AppMountParameters, CoreStart, ScopedHistory } from '../../../src/core/public'; +import { EuiPage, EuiPageSideBar, EuiSideNav } from '@elastic/eui'; +import { AppMountParameters, CoreStart } from '../../../src/core/public'; import { Page } from './page'; import { DocumentationPage } from './documentation'; import { CreateAlertPage } from './create_alert'; @@ -66,22 +58,13 @@ const Nav = withRouter(({ history, pages }: NavProps) => { ); }); -export interface NavState { - alert: JsonObject; - alertType: JsonObject; -} export interface AlertingExampleComponentParams { application: CoreStart['application']; http: CoreStart['http']; - history: ScopedHistory; basename: string; } -const Home = withRouter(({ history }) => { - return history.location.state ? : ; -}); - -const AlertingExampleApp = ({ basename, http, history }: AlertingExampleComponentParams) => { +const AlertingExampleApp = ({ basename, http }: AlertingExampleComponentParams) => { const pages: PageDef[] = [ { id: 'home', @@ -93,20 +76,13 @@ const AlertingExampleApp = ({ basename, http, history }: AlertingExampleComponen title: 'Create', component: , }, - { - id: 'view', - title: 'View Alert', - component: , - }, ]; const routes = pages.map((page, i) => ( { - return {page.component}; - }} + render={() => {page.component}} /> )); @@ -116,7 +92,17 @@ const AlertingExampleApp = ({ basename, http, history }: AlertingExampleComponen