From 724bc29e4a7953315c0175a9d5af248b7e9e59de Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 18 Dec 2017 15:14:53 +0000 Subject: [PATCH] Merge the duplicate contact/event view/edit/log routes. --- src/Pim/index.tsx | 250 ++++++++++++++++++++++------------------------ 1 file changed, 118 insertions(+), 132 deletions(-) diff --git a/src/Pim/index.tsx b/src/Pim/index.tsx index 2072f5a..e4a0c35 100644 --- a/src/Pim/index.tsx +++ b/src/Pim/index.tsx @@ -4,6 +4,8 @@ import RaisedButton from 'material-ui/RaisedButton'; import IconEdit from 'material-ui/svg-icons/editor/mode-edit'; import IconChangeHistory from 'material-ui/svg-icons/action/change-history'; +import { withRouter } from 'react-router'; + import * as EteSync from '../api/EteSync'; import { createSelector } from 'reselect'; @@ -90,6 +92,100 @@ const ItemChangeLog = pure((props: any) => { ); }); +const CollectionRoutes = withRouter( + class CollectionRoutesInner extends React.PureComponent { + props: { + syncInfo: SyncInfo, + routePrefix: string, + collections: Array, + componentEdit: any, + componentView: any, + items: {[key: string]: any}, + onItemSave: (item: Object, journalUid: string, originalContact?: Object) => void; + }; + + render() { + const props = this.props; + const ComponentEdit = props.componentEdit; + const ComponentView = props.componentView; + + return ( + + ( + + + + )} + /> + ( + + + + )} + /> + ( + + + + )} + /> + ( + +
+ } + onClick={() => + history.push(routeResolver.getRoute( + props.routePrefix + '._id.log', + {itemUid: match.params.itemUid})) + } + /> + + } + onClick={() => + history.push(routeResolver.getRoute( + props.routePrefix + '._id.edit', + {itemUid: match.params.itemUid})) + } + /> +
+ +
+ )} + /> +
+ ); + } + } +); + class Pim extends React.PureComponent { props: { etesync: CredentialsData; @@ -154,141 +250,31 @@ class Pim extends React.PureComponent { )} /> ( - - - - )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - -
- } - onClick={() => - history.push(routeResolver.getRoute( - 'pim.contacts._id.log', - {itemUid: match.params.itemUid})) - } - /> - - } - onClick={() => - history.push(routeResolver.getRoute( - 'pim.contacts._id.edit', - {itemUid: match.params.itemUid})) - } - /> -
- -
- )} - /> - ( - - - - )} - /> - ( - - - - )} - /> - ( - - - + path={routeResolver.getRoute('pim.contacts')} + render={() => ( + )} /> ( - -
- } - onClick={() => - history.push(routeResolver.getRoute( - 'pim.events._id.log', - {itemUid: match.params.itemUid})) - } - /> - - } - onClick={() => - history.push(routeResolver.getRoute( - 'pim.events._id.edit', - {itemUid: match.params.itemUid})) - } - /> -
- -
+ path={routeResolver.getRoute('pim.events')} + render={() => ( + )} />