mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-02 05:36:38 +00:00
Moved logic to mark selected server to parent component in order to affect all children compo0nents on the same route
This commit is contained in:
@@ -1,33 +1,41 @@
|
||||
import React from 'react';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
import { connect } from 'react-redux';
|
||||
import { selectServer } from '../servers/reducers/selectedServer';
|
||||
import CreateShortUrl from '../short-urls/CreateShortUrl';
|
||||
import ShortUrls from '../short-urls/ShortUrls';
|
||||
import AsideMenu from './AsideMenu';
|
||||
|
||||
export function MenuLayout(props) {
|
||||
return (
|
||||
<div className="row">
|
||||
<AsideMenu {...props} />
|
||||
<div className="col-md-10 offset-md-2 col-sm-9 offset-sm-3">
|
||||
<Switch>
|
||||
<Route
|
||||
exact
|
||||
path="/server/:serverId/list-short-urls/:page"
|
||||
component={ShortUrls}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/server/:serverId/create-short-url"
|
||||
component={CreateShortUrl}
|
||||
/>
|
||||
</Switch>
|
||||
export class MenuLayout extends React.Component {
|
||||
componentDidMount() {
|
||||
const { serverId } = this.props.match.params;
|
||||
this.props.selectServer(serverId);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="row">
|
||||
<AsideMenu {...this.props} />
|
||||
<div className="col-md-10 offset-md-2 col-sm-9 offset-sm-3">
|
||||
<Switch>
|
||||
<Route
|
||||
exact
|
||||
path="/server/:serverId/list-short-urls/:page"
|
||||
component={ShortUrls}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/server/:serverId/create-short-url"
|
||||
component={CreateShortUrl}
|
||||
/>
|
||||
</Switch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(state => ({
|
||||
selectedServer: state.selectedServer,
|
||||
shortUrlsListParams: state.shortUrlsListParams,
|
||||
}))(MenuLayout);
|
||||
}), { selectServer })(MenuLayout);
|
||||
|
||||
Reference in New Issue
Block a user