route history back bug fix
This commit is contained in:
parent
4db19042c5
commit
e3e1b8f411
|
@ -15,7 +15,6 @@ import HistoryView from '../../views/history/List';
|
|||
export interface Props extends RouteComponentProps<any> {
|
||||
}
|
||||
export interface State {
|
||||
currUrl: string;
|
||||
}
|
||||
|
||||
export class ProbeDetailLayout extends React.Component<Props, State> {
|
||||
|
@ -23,7 +22,6 @@ export class ProbeDetailLayout extends React.Component<Props, State> {
|
|||
constructor(props: Props, context: State) {
|
||||
super(props, context);
|
||||
this.state = {
|
||||
currUrl: this.props.location.pathname,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -52,7 +50,7 @@ export class ProbeDetailLayout extends React.Component<Props, State> {
|
|||
<LeftMenu />
|
||||
<Segment basic style={{ margin: '0 0 0 210px', padding: '0' }}>
|
||||
<Header />
|
||||
<TitleBarContainer sub={sub} location={this.props.location.pathname} />
|
||||
<TitleBarContainer sub={sub} location={this.props.location.pathname} history={this.props.history}/>
|
||||
<Segment basic>
|
||||
<Switch>
|
||||
<Route exact={true} path={`${this.props.match.url}/:id`} component={ProbeDetail} />
|
||||
|
|
|
@ -14,7 +14,6 @@ import HistoryView from '../../views/history/List';
|
|||
export interface Props extends RouteComponentProps<any> {
|
||||
}
|
||||
export interface State {
|
||||
currUrl: string;
|
||||
}
|
||||
|
||||
class SensorDetailLayout extends React.Component<Props, State> {
|
||||
|
@ -22,7 +21,6 @@ class SensorDetailLayout extends React.Component<Props, State> {
|
|||
public constructor(props?: Props, context?: State) {
|
||||
super(props, context);
|
||||
this.state = {
|
||||
currUrl: this.props.location.pathname,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -50,7 +48,7 @@ class SensorDetailLayout extends React.Component<Props, State> {
|
|||
<LeftMenu />
|
||||
<Segment basic style={{ margin: '0 0 0 210px', padding: '0' }}>
|
||||
<Header />
|
||||
<TitleBarContainer sub={sub} location={this.props.location.pathname} />
|
||||
<TitleBarContainer sub={sub} location={this.props.location.pathname} history={this.props.history}/>
|
||||
{/*<TitleBar title='Sensor Details' sub={sub} />*/}
|
||||
<Segment basic>
|
||||
<Switch>
|
||||
|
|
|
@ -13,7 +13,6 @@ import HistoryView from '../../views/history/List';
|
|||
export interface Props extends RouteComponentProps<any> {
|
||||
}
|
||||
export interface State {
|
||||
currUrl: string;
|
||||
}
|
||||
|
||||
export class TargetDetailLayout extends React.Component<Props, State> {
|
||||
|
@ -21,7 +20,6 @@ export class TargetDetailLayout extends React.Component<Props, State> {
|
|||
constructor(props: Props, context: State) {
|
||||
super(props, context);
|
||||
this.state = {
|
||||
currUrl: this.props.location.pathname,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -30,7 +28,7 @@ export class TargetDetailLayout extends React.Component<Props, State> {
|
|||
const sub = [
|
||||
{
|
||||
'name': 'Info',
|
||||
'path': '',
|
||||
'path': '/',
|
||||
},
|
||||
{
|
||||
'name': 'Sensor',
|
||||
|
@ -46,7 +44,7 @@ export class TargetDetailLayout extends React.Component<Props, State> {
|
|||
<LeftMenu />
|
||||
<Segment basic style={{ margin: '0 0 0 210px', padding: '0' }}>
|
||||
<Header />
|
||||
<TitleBarContainer title='Target Details' sub={sub} location={this.props.location.pathname} />
|
||||
<TitleBarContainer sub={sub} location={this.props.location.pathname} history={this.props.history}/>
|
||||
<Segment basic>
|
||||
<Switch>
|
||||
<Route exact={true} path={`${this.props.match.url}/:id`} component={TargetDetail} />
|
||||
|
|
|
@ -5,6 +5,7 @@ import { Grid, Container, Breadcrumb, Header, Menu, Input, Segment, Dropdown } f
|
|||
export interface StateProps {
|
||||
sub: any;
|
||||
location: string;
|
||||
history: any;
|
||||
}
|
||||
|
||||
export interface DispatchProps {
|
||||
|
@ -35,10 +36,27 @@ export class TitleBar extends React.Component<Props, State> {
|
|||
for (let i = 0; i < this.props.sub.length; i++) {
|
||||
if (this.props.sub[i].name.toLowerCase() === last) {
|
||||
this.setState({ selected: i });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public componentWillUpdate(nextProps: Props, nextState: State): void {
|
||||
if (nextProps !== this.props) {
|
||||
if (!this.props.history.location.pathname) {
|
||||
return;
|
||||
}
|
||||
let last = this.props.history.location.pathname.split('/').pop().toLowerCase();
|
||||
for (let i = 0; i < this.props.sub.length; i++) {
|
||||
if (this.props.sub[i].name.toLowerCase() === last) {
|
||||
this.setState({ selected: i });
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.setState({ selected: 0 });
|
||||
}
|
||||
}
|
||||
|
||||
public handleMenu(menu: any, index: number): any {
|
||||
this.setState({
|
||||
selected: index,
|
||||
|
|
|
@ -11,6 +11,7 @@ export function mapStateToProps(state: any, ownProps: any): StateProps {
|
|||
return {
|
||||
sub: ownProps.sub,
|
||||
location: ownProps.location,
|
||||
history: ownProps.history,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user