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 Props extends RouteComponentProps<any> {
|
||||||
}
|
}
|
||||||
export interface State {
|
export interface State {
|
||||||
currUrl: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ProbeDetailLayout extends React.Component<Props, State> {
|
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) {
|
constructor(props: Props, context: State) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
this.state = {
|
this.state = {
|
||||||
currUrl: this.props.location.pathname,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +50,7 @@ export class ProbeDetailLayout extends React.Component<Props, State> {
|
||||||
<LeftMenu />
|
<LeftMenu />
|
||||||
<Segment basic style={{ margin: '0 0 0 210px', padding: '0' }}>
|
<Segment basic style={{ margin: '0 0 0 210px', padding: '0' }}>
|
||||||
<Header />
|
<Header />
|
||||||
<TitleBarContainer sub={sub} location={this.props.location.pathname} />
|
<TitleBarContainer sub={sub} location={this.props.location.pathname} history={this.props.history}/>
|
||||||
<Segment basic>
|
<Segment basic>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact={true} path={`${this.props.match.url}/:id`} component={ProbeDetail} />
|
<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 Props extends RouteComponentProps<any> {
|
||||||
}
|
}
|
||||||
export interface State {
|
export interface State {
|
||||||
currUrl: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SensorDetailLayout extends React.Component<Props, State> {
|
class SensorDetailLayout extends React.Component<Props, State> {
|
||||||
|
@ -22,7 +21,6 @@ class SensorDetailLayout extends React.Component<Props, State> {
|
||||||
public constructor(props?: Props, context?: State) {
|
public constructor(props?: Props, context?: State) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
this.state = {
|
this.state = {
|
||||||
currUrl: this.props.location.pathname,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +48,7 @@ class SensorDetailLayout extends React.Component<Props, State> {
|
||||||
<LeftMenu />
|
<LeftMenu />
|
||||||
<Segment basic style={{ margin: '0 0 0 210px', padding: '0' }}>
|
<Segment basic style={{ margin: '0 0 0 210px', padding: '0' }}>
|
||||||
<Header />
|
<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} />*/}
|
{/*<TitleBar title='Sensor Details' sub={sub} />*/}
|
||||||
<Segment basic>
|
<Segment basic>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
|
|
@ -13,7 +13,6 @@ import HistoryView from '../../views/history/List';
|
||||||
export interface Props extends RouteComponentProps<any> {
|
export interface Props extends RouteComponentProps<any> {
|
||||||
}
|
}
|
||||||
export interface State {
|
export interface State {
|
||||||
currUrl: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TargetDetailLayout extends React.Component<Props, State> {
|
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) {
|
constructor(props: Props, context: State) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
this.state = {
|
this.state = {
|
||||||
currUrl: this.props.location.pathname,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +28,7 @@ export class TargetDetailLayout extends React.Component<Props, State> {
|
||||||
const sub = [
|
const sub = [
|
||||||
{
|
{
|
||||||
'name': 'Info',
|
'name': 'Info',
|
||||||
'path': '',
|
'path': '/',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'Sensor',
|
'name': 'Sensor',
|
||||||
|
@ -46,7 +44,7 @@ export class TargetDetailLayout extends React.Component<Props, State> {
|
||||||
<LeftMenu />
|
<LeftMenu />
|
||||||
<Segment basic style={{ margin: '0 0 0 210px', padding: '0' }}>
|
<Segment basic style={{ margin: '0 0 0 210px', padding: '0' }}>
|
||||||
<Header />
|
<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>
|
<Segment basic>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact={true} path={`${this.props.match.url}/:id`} component={TargetDetail} />
|
<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 {
|
export interface StateProps {
|
||||||
sub: any;
|
sub: any;
|
||||||
location: string;
|
location: string;
|
||||||
|
history: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DispatchProps {
|
export interface DispatchProps {
|
||||||
|
@ -32,13 +33,30 @@ export class TitleBar extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let last = this.props.location.split('/').pop().toLowerCase();
|
let last = this.props.location.split('/').pop().toLowerCase();
|
||||||
for(let i = 0; i < this.props.sub.length; i++) {
|
for (let i = 0; i < this.props.sub.length; i++) {
|
||||||
if(this.props.sub[i].name.toLowerCase() === last) {
|
if (this.props.sub[i].name.toLowerCase() === last) {
|
||||||
this.setState({selected: i});
|
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 {
|
public handleMenu(menu: any, index: number): any {
|
||||||
this.setState({
|
this.setState({
|
||||||
selected: index,
|
selected: index,
|
||||||
|
|
|
@ -11,6 +11,7 @@ export function mapStateToProps(state: any, ownProps: any): StateProps {
|
||||||
return {
|
return {
|
||||||
sub: ownProps.sub,
|
sub: ownProps.sub,
|
||||||
location: ownProps.location,
|
location: ownProps.location,
|
||||||
|
history: ownProps.history,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user