From 4a50fe2cd6415b0eee39c39896b9552c52e9aacb Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 21 Jul 2017 15:55:39 +0900 Subject: [PATCH] router --- .../app/views/layout/AccountLayout.tsx | 6 ++-- .../@overflow/app/views/layout/AppLayout.tsx | 2 +- src/ts/@overflow/app/views/layout/Layout.tsx | 2 +- .../@overflow/app/views/layout/LeftMenu.tsx | 35 +++++++++++++++++-- .../@overflow/app/views/layout/TempLayout.tsx | 2 +- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/ts/@overflow/app/views/layout/AccountLayout.tsx b/src/ts/@overflow/app/views/layout/AccountLayout.tsx index e193c79..a2c33b9 100644 --- a/src/ts/@overflow/app/views/layout/AccountLayout.tsx +++ b/src/ts/@overflow/app/views/layout/AccountLayout.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { RouteComponentProps, RouteProps, Route } from 'react-router-dom'; +import { RouteComponentProps, RouteProps, Route, Switch } from 'react-router-dom'; import SignIn from '../member/SignIn'; import SignUp from '../member/SignUp'; @@ -20,12 +20,12 @@ class AccountLayout extends React.Component { public render(): JSX.Element { return ( -
+ -
+ ); } diff --git a/src/ts/@overflow/app/views/layout/AppLayout.tsx b/src/ts/@overflow/app/views/layout/AppLayout.tsx index f86f789..d996b3e 100644 --- a/src/ts/@overflow/app/views/layout/AppLayout.tsx +++ b/src/ts/@overflow/app/views/layout/AppLayout.tsx @@ -3,7 +3,7 @@ import { RouteComponentProps, RouteProps, Route } from 'react-router-dom'; import { Container, Menu, Sidebar, Segment, Icon, Breadcrumb, Grid, Dropdown } from 'semantic-ui-react'; import { Header } from './Header'; import { Footer } from './Footer'; -import { LeftMenu } from './LeftMenu'; +import LeftMenu from './LeftMenu'; import Home from '../Home'; diff --git a/src/ts/@overflow/app/views/layout/Layout.tsx b/src/ts/@overflow/app/views/layout/Layout.tsx index 13f4910..5ad4405 100644 --- a/src/ts/@overflow/app/views/layout/Layout.tsx +++ b/src/ts/@overflow/app/views/layout/Layout.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { Container, Menu, Sidebar, Segment, Icon, Breadcrumb, Grid, Dropdown } from 'semantic-ui-react'; import { Header } from './Header'; import { Footer } from './Footer'; -import { LeftMenu } from './LeftMenu'; +import LeftMenu from './LeftMenu'; // import { Routes } from './Routes'; diff --git a/src/ts/@overflow/app/views/layout/LeftMenu.tsx b/src/ts/@overflow/app/views/layout/LeftMenu.tsx index 8e29530..a65e6fe 100644 --- a/src/ts/@overflow/app/views/layout/LeftMenu.tsx +++ b/src/ts/@overflow/app/views/layout/LeftMenu.tsx @@ -1,12 +1,27 @@ import * as React from 'react'; +import { connect, Dispatch } from 'react-redux'; +import { push as routerPush } from 'react-router-redux'; + import { Container, Menu, Dropdown, Segment, Icon, Header, Image } from 'semantic-ui-react'; import { LogoBar } from './LogoBar'; import { TitleBar } from './TitleBar'; -export class LeftMenu extends React.Component { +export interface StateProps { +} - constructor(props: any, context: any) { +export interface DispatchProps { + onChangeUrl?(url: string): void; +} + +export type Props = StateProps & DispatchProps; + +export interface State { +} + +class LeftMenu extends React.Component { + + constructor(props: Props, context: State) { super(props, context); this.state = { }; @@ -36,7 +51,7 @@ export class LeftMenu extends React.Component {
- Probe + this.props.onChangeUrl('/temp/probe')} style={{ 'marginLeft': '30px' }}>Probe Sensors @@ -99,4 +114,18 @@ export class LeftMenu extends React.Component { } +export function mapStateToProps(state: any): StateProps { + return { + }; +} + +export function mapDispatchToProps(dispatch: Dispatch): DispatchProps { + return { + onChangeUrl: (url: string): void => { + dispatch(routerPush(url)); + }, + }; +} + +export default connect(mapStateToProps, mapDispatchToProps)(LeftMenu); diff --git a/src/ts/@overflow/app/views/layout/TempLayout.tsx b/src/ts/@overflow/app/views/layout/TempLayout.tsx index 1cd3bc2..0db5e72 100644 --- a/src/ts/@overflow/app/views/layout/TempLayout.tsx +++ b/src/ts/@overflow/app/views/layout/TempLayout.tsx @@ -3,7 +3,7 @@ import { RouteComponentProps, RouteProps, Route } from 'react-router-dom'; import { Container, Menu, Sidebar, Segment, Icon, Breadcrumb, Grid, Dropdown } from 'semantic-ui-react'; import { Header } from './Header'; import { Footer } from './Footer'; -import { LeftMenu } from './LeftMenu'; +import LeftMenu from './LeftMenu'; import ProbeList from '../monitoring/probe/List';