From 26788cc749ef86d2baaf23f688ba87a02be7b181 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 5 Aug 2020 21:56:03 +0300 Subject: [PATCH] Collections: add collection list import page. --- src/Collections/CollectionImport.tsx | 84 ++++++++++++++++++++++++++++ src/Collections/Main.tsx | 9 ++- 2 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 src/Collections/CollectionImport.tsx diff --git a/src/Collections/CollectionImport.tsx b/src/Collections/CollectionImport.tsx new file mode 100644 index 0000000..0470450 --- /dev/null +++ b/src/Collections/CollectionImport.tsx @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: © 2017 EteSync Authors +// SPDX-License-Identifier: AGPL-3.0-only + +import * as React from "react"; + +import ContactsIcon from "@material-ui/icons/Contacts"; +import CalendarTodayIcon from "@material-ui/icons/CalendarToday"; +import FormatListBulletedIcon from "@material-ui/icons/FormatListBulleted"; + +import { List, ListItem } from "../widgets/List"; + +import AppBarOverride from "../widgets/AppBarOverride"; +import Container from "../widgets/Container"; + +import { CachedCollection } from "../Pim/helpers"; +import ColorBox from "../widgets/ColorBox"; +import ImportDialog from "./ImportDialog"; + +interface PropsType { + collections: CachedCollection[]; +} + +export default function CollectionImport(props: PropsType) { + const [selectedCollection, setSelectedCollection] = React.useState(); + + const collectionMap = { + "etebase.vcard": [], + "etebase.vevent": [], + "etebase.vtodo": [], + }; + + function colClicked(colUid: string) { + const collection = props.collections.find((x) => x.collection.uid === colUid); + setSelectedCollection(collection); + } + + for (const col of props.collections) { + if (collectionMap[col.metadata.type]) { + const colorBox = (col.metadata.color) ? ( + + ) : undefined; + + collectionMap[col.metadata.type].push(( + colClicked(col.collection.uid)}> + {col.metadata.name} + + )); + } + } + + return ( + + + + } + nestedItems={collectionMap["etebase.vcard"]} + /> + + } + nestedItems={collectionMap["etebase.vevent"]} + /> + + } + nestedItems={collectionMap["etebase.vtodo"]} + /> + + {selectedCollection && ( + setSelectedCollection(undefined)} + /> + )} + + ); +} diff --git a/src/Collections/Main.tsx b/src/Collections/Main.tsx index 5126818..11f4743 100644 --- a/src/Collections/Main.tsx +++ b/src/Collections/Main.tsx @@ -13,6 +13,7 @@ import LoadingIndicator from "../widgets/LoadingIndicator"; import { CachedCollection, getDecryptCollectionsFunction, PimFab } from "../Pim/helpers"; import CollectionList from "./CollectionList"; +import CollectionImport from "./CollectionImport"; import PageNotFound from "../PageNotFound"; import CollectionEdit from "./CollectionEdit"; import Collection from "./Collection"; @@ -64,7 +65,9 @@ export default function CollectionsMain() { path={routeResolver.getRoute("collections")} exact > - + history.push( routeResolver.getRoute("collections.new") @@ -75,7 +78,9 @@ export default function CollectionsMain() { path={routeResolver.getRoute("collections.import")} exact > - Import +