Clean up the sidemenu.

master
Tom Hacohen 7 years ago
parent 25402639b6
commit 588bec69cc

@ -1,7 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import { NavLink } from 'react-router-dom';
import { List, ListItem } from 'material-ui/List'; import { List, ListItem } from 'material-ui/List';
import Subheader from 'material-ui/Subheader'; import Subheader from 'material-ui/Subheader';
import Divider from 'material-ui/Divider'; import Divider from 'material-ui/Divider';
@ -28,6 +27,7 @@ interface PropsType {
interface PropsTypeInner extends PropsType { interface PropsTypeInner extends PropsType {
journals: JournalsType; journals: JournalsType;
history: any;
} }
class SideMenu extends React.Component { class SideMenu extends React.Component {
@ -57,7 +57,10 @@ class SideMenu extends React.Component {
<SideMenuJournals <SideMenuJournals
etesync={this.props.etesync} etesync={this.props.etesync}
journals={this.props.journals.value} journals={this.props.journals.value}
onItemClick={this.props.onCloseDrawerRequest} onItemClick={(journalUid: string) => {
this.props.onCloseDrawerRequest();
this.props.history.push(routeResolver.getRoute('journals._id', { journalUid: journalUid }));
}}
/> />
</React.Fragment> </React.Fragment>
); );
@ -79,12 +82,14 @@ class SideMenu extends React.Component {
</div> </div>
</div> </div>
<List> <List>
<NavLink <ListItem
to={routeResolver.getRoute('home')} primaryText="Main"
exact={true} leftIcon={<ActionHome />}
> onClick={() => {
<ListItem primaryText="Main" leftIcon={<ActionHome />} onClick={this.props.onCloseDrawerRequest} /> this.props.onCloseDrawerRequest();
</NavLink> this.props.history.push(routeResolver.getRoute('home'));
}}
/>
{loggedInItems} {loggedInItems}
<Divider /> <Divider />
<Subheader>External Links</Subheader> <Subheader>External Links</Subheader>

@ -1,18 +1,16 @@
import * as React from 'react'; import * as React from 'react';
import { Link } from 'react-router-dom';
import { ListItem } from 'material-ui/List'; import { ListItem } from 'material-ui/List';
import * as EteSync from './api/EteSync'; import * as EteSync from './api/EteSync';
import { routeResolver } from './App';
import { JournalsData, CredentialsData } from './store'; import { JournalsData, CredentialsData } from './store';
class SideMenuJournals extends React.Component { class SideMenuJournals extends React.Component {
props: { props: {
etesync: CredentialsData; etesync: CredentialsData;
journals: JournalsData; journals: JournalsData;
onItemClick: () => void; onItemClick: (journalUid: string) => void;
}; };
constructor(props: any) { constructor(props: any) {
@ -38,13 +36,8 @@ class SideMenuJournals extends React.Component {
let info = journal.getInfo(cryptoManager); let info = journal.getInfo(cryptoManager);
ret[info.type] = ret[info.type] || []; ret[info.type] = ret[info.type] || [];
ret[info.type].push( ret[info.type].push(
<ListItem key={journal.uid}> <ListItem key={journal.uid} onClick={() => this.props.onItemClick(journal.uid)}>
<Link
to={routeResolver.getRoute('journals._id', { journalUid: journal.uid })}
onClick={this.props.onItemClick}
>
{info.displayName} ({journal.uid.slice(0, 5)}) {info.displayName} ({journal.uid.slice(0, 5)})
</Link>
</ListItem> </ListItem>
); );
} }

Loading…
Cancel
Save