|
@@ -5,12 +5,12 @@ import { withTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
import AppContainer from '../../services/AppContainer';
|
|
import AppContainer from '../../services/AppContainer';
|
|
|
|
|
+import NavigationContainer from '../../services/NavigationContainer';
|
|
|
|
|
|
|
|
|
|
|
|
|
class SidebarNav extends React.Component {
|
|
class SidebarNav extends React.Component {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
static propTypes = {
|
|
|
- currentContentsId: PropTypes.string,
|
|
|
|
|
onItemSelected: PropTypes.func,
|
|
onItemSelected: PropTypes.func,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -18,14 +18,17 @@ class SidebarNav extends React.Component {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
itemSelectedHandler = (contentsId) => {
|
|
itemSelectedHandler = (contentsId) => {
|
|
|
- const { onItemSelected } = this.props;
|
|
|
|
|
|
|
+ const { navigationContainer, onItemSelected } = this.props;
|
|
|
if (onItemSelected != null) {
|
|
if (onItemSelected != null) {
|
|
|
onItemSelected(contentsId);
|
|
onItemSelected(contentsId);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ navigationContainer.setState({ sidebarContentsId: contentsId });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
PrimaryItem = ({ id, label, iconName }) => {
|
|
PrimaryItem = ({ id, label, iconName }) => {
|
|
|
- const isSelected = this.props.currentContentsId === id;
|
|
|
|
|
|
|
+ const { sidebarContentsId } = this.props.navigationContainer.state;
|
|
|
|
|
+ const isSelected = sidebarContentsId === id;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<button
|
|
<button
|
|
@@ -80,11 +83,12 @@ class SidebarNav extends React.Component {
|
|
|
|
|
|
|
|
SidebarNav.propTypes = {
|
|
SidebarNav.propTypes = {
|
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
|
|
+ navigationContainer: PropTypes.instanceOf(NavigationContainer).isRequired,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Wrapper component for using unstated
|
|
* Wrapper component for using unstated
|
|
|
*/
|
|
*/
|
|
|
-const SidebarNavWrapper = withUnstatedContainers(SidebarNav, [AppContainer]);
|
|
|
|
|
|
|
+const SidebarNavWrapper = withUnstatedContainers(SidebarNav, [AppContainer, NavigationContainer]);
|
|
|
|
|
|
|
|
export default withTranslation()(SidebarNavWrapper);
|
|
export default withTranslation()(SidebarNavWrapper);
|