diff --git a/src/ts/@overflow/app/views/layout/ProbeDetailLayout.tsx b/src/ts/@overflow/app/views/layout/ProbeDetailLayout.tsx index 7edd350..2326eb3 100644 --- a/src/ts/@overflow/app/views/layout/ProbeDetailLayout.tsx +++ b/src/ts/@overflow/app/views/layout/ProbeDetailLayout.tsx @@ -3,7 +3,7 @@ import { Redirect, RouteComponentProps, RouteProps, Route, Switch } from 'react- import { Container, Menu, Sidebar, Segment, Icon, Breadcrumb, Grid, Dropdown } from 'semantic-ui-react'; import { Header } from './Header'; import { Footer } from './Footer'; -import { TitleBar } from './TitleBar'; +import TitleBarContainer from './TitleBarContainer'; import LeftMenu from './LeftMenu'; import ProbeDetail from '../../views/monitoring/probe/Detail'; @@ -40,7 +40,7 @@ export class ProbeDetailLayout extends React.Component {
- + diff --git a/src/ts/@overflow/app/views/layout/TitleBar.tsx b/src/ts/@overflow/app/views/layout/TitleBar.tsx index 09c7776..aa0fd3c 100644 --- a/src/ts/@overflow/app/views/layout/TitleBar.tsx +++ b/src/ts/@overflow/app/views/layout/TitleBar.tsx @@ -1,6 +1,19 @@ import * as React from 'react'; import { Grid, Container, Breadcrumb, Header, Menu, Input, Segment } from 'semantic-ui-react'; -import { Redirect } from 'react-router-dom'; + + +export interface StateProps { + sub: any; +} + +export interface DispatchProps { + onRedirect(path: string): void; +} + +export type Props = StateProps & DispatchProps; + +export interface State { +} export class TitleBar extends React.Component { @@ -10,9 +23,9 @@ export class TitleBar extends React.Component { }; } - public handleMenu(menu:any): JSX.Element { + public handleMenu(menu:any): any { console.log(menu.path); - return ; + this.props.onRedirect(menu.path); } public renderSubMenus(): JSX.Element { diff --git a/src/ts/@overflow/app/views/layout/TitleBarContainer.tsx b/src/ts/@overflow/app/views/layout/TitleBarContainer.tsx new file mode 100644 index 0000000..5ca518a --- /dev/null +++ b/src/ts/@overflow/app/views/layout/TitleBarContainer.tsx @@ -0,0 +1,24 @@ +import { connect, Dispatch } from 'react-redux'; +import { + TitleBar, + StateProps as StateProps, + DispatchProps as DispatchProps, +} from './TitleBar'; + +import { push as routerPush } from 'react-router-redux'; + +export function mapStateToProps(state: any, ownProps: any): StateProps { + return { + sub: ownProps.sub, + }; +} + +export function mapDispatchToProps(dispatch: Dispatch): DispatchProps { + return { + onRedirect: (path: string) => { + dispatch(routerPush(path)); + }, + }; +} + +export default connect(mapStateToProps, mapDispatchToProps)(TitleBar);