From 4318e064b35f3e62e2c3a2096b830b57f56fae53 Mon Sep 17 00:00:00 2001 From: Tal Leibman Date: Sat, 23 Nov 2019 17:12:04 +0200 Subject: [PATCH] Journal Import: add an import link to the sidebar Fixes #55 --- src/App.tsx | 1 + src/Journals/JournalsListImport.tsx | 89 +++++++++++++++++++++++++++++ src/Journals/index.tsx | 16 ++++++ src/SideMenu/index.tsx | 9 +++ 4 files changed, 115 insertions(+) create mode 100644 src/Journals/JournalsListImport.tsx diff --git a/src/App.tsx b/src/App.tsx index 4975b13..2efecea 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -92,6 +92,7 @@ export const routeResolver = new RouteResolver({ }, }, new: 'new', + import: 'import', }, settings: { }, diff --git a/src/Journals/JournalsListImport.tsx b/src/Journals/JournalsListImport.tsx new file mode 100644 index 0000000..7404213 --- /dev/null +++ b/src/Journals/JournalsListImport.tsx @@ -0,0 +1,89 @@ +import * as React from 'react'; + +import { Link } from 'react-router-dom'; + +import IconButton from '@material-ui/core/IconButton'; +import IconAdd from '@material-ui/icons/Add'; + +import { List, ListItem } from '../widgets/List'; + +import AppBarOverride from '../widgets/AppBarOverride'; +import Container from '../widgets/Container'; + +import { routeResolver } from '../App'; + +import { JournalsData, UserInfoData, CredentialsData } from '../store'; +import ImportDialog from './ImportDialog'; +import { SyncInfo, SyncInfoJournal } from '../SyncGate'; + +interface PropsType { + etesync: CredentialsData; + journals: JournalsData; + userInfo: UserInfoData; + syncInfo: SyncInfo; +} + +export default function JournalsList(props: PropsType) { + const [selectedJournal, setSelectedJournal] = React.useState(); + const derived = props.etesync.encryptionKey; + + const journalMap = props.journals.reduce( + (ret, journal) => { + const userInfo = props.userInfo; + const keyPair = userInfo.getKeyPair(userInfo.getCryptoManager(derived)); + const cryptoManager = journal.getCryptoManager(derived, keyPair); + const info = journal.getInfo(cryptoManager); + ret[info.type] = ret[info.type] || []; + ret[info.type].push( + setSelectedJournal(props.syncInfo.get(journal.uid))}> + {info.displayName} ({journal.uid.slice(0, 5)}) + + ); + + return ret; + }, + { CALENDAR: [], + ADDRESS_BOOK: [], + TASKS: [], + }); + + return ( + + + + + + + + + + + + + + + {selectedJournal && ( + setSelectedJournal(undefined)} + /> + )} + + ); +} \ No newline at end of file diff --git a/src/Journals/index.tsx b/src/Journals/index.tsx index 6831f4f..99e7dde 100644 --- a/src/Journals/index.tsx +++ b/src/Journals/index.tsx @@ -6,6 +6,7 @@ import Journal from './Journal'; import JournalEdit from './JournalEdit'; import JournalMembers from './JournalMembers'; import JournalsList from './JournalsList'; +import JournalsListImport from './JournalsListImport'; import { routeResolver } from '../App'; @@ -49,6 +50,21 @@ class Journals extends React.PureComponent { )} /> + ( + <> + + + )} + /> ( diff --git a/src/SideMenu/index.tsx b/src/SideMenu/index.tsx index a2b0d9d..b317e2c 100644 --- a/src/SideMenu/index.tsx +++ b/src/SideMenu/index.tsx @@ -10,6 +10,7 @@ import ActionJournals from '@material-ui/icons/LibraryBooks'; import ActionBugReport from '@material-ui/icons/BugReport'; import ActionQuestionAnswer from '@material-ui/icons/QuestionAnswer'; import LogoutIcon from '@material-ui/icons/PowerSettingsNew'; +import IconImport from '@material-ui/icons/ImportExport'; import logo from '../images/logo.svg'; @@ -60,6 +61,14 @@ class SideMenu extends React.PureComponent { this.props.history.push(routeResolver.getRoute('journals')); }} /> + } + onClick={() => { + this.props.onCloseDrawerRequest(); + this.props.history.push(routeResolver.getRoute('journals.import')); + }} + /> }