From b804a8945db63b88c100f894ba9dbf2783056a59 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 5 Aug 2020 18:27:08 +0300 Subject: [PATCH] Add back the tab navigation buttons. --- src/Pim/NavigationTabs.tsx | 58 ++++++++++++++++++++++++++++++++++++++ src/SyncGate.tsx | 17 +++++++++-- 2 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 src/Pim/NavigationTabs.tsx diff --git a/src/Pim/NavigationTabs.tsx b/src/Pim/NavigationTabs.tsx new file mode 100644 index 0000000..323e6ee --- /dev/null +++ b/src/Pim/NavigationTabs.tsx @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: © 2020 EteSync Authors +// SPDX-License-Identifier: AGPL-3.0-only + +import * as React from "react"; +import { Tabs, Tab, useTheme } from "@material-ui/core"; +import { useHistory } from "react-router"; +import { routeResolver } from "../App"; + +export type TabValue = "contacts" | "events" | "tasks"; + +interface PropsType { + value: TabValue; +} + +export default function PimNavigationTabs(props: PropsType) { + const theme = useTheme(); + const history = useHistory(); + + const tabs = [ + { title: "Address Book", linkValue: "contacts" }, + { title: "Calendar", linkValue: "events" }, + { title: "Tasks", linkValue: "tasks" }, + ]; + + let selected; + switch (props.value) { + case "contacts": { + selected = 0; + break; + } + case "events": { + selected = 1; + break; + } + case "tasks": { + selected = 2; + break; + } + } + + return ( + history.push( + routeResolver.getRoute(`pim.${tabs[value].linkValue}`) + )} + > + {tabs.map((x) => ( + + ))} + + ); +} diff --git a/src/SyncGate.tsx b/src/SyncGate.tsx index 09f18bf..04e95e2 100644 --- a/src/SyncGate.tsx +++ b/src/SyncGate.tsx @@ -14,6 +14,7 @@ import { routeResolver } from "./App"; import AppBarOverride from "./widgets/AppBarOverride"; import LoadingIndicator from "./widgets/LoadingIndicator"; +import Container from "./widgets/Container"; import ContactsMain from "./Contacts/Main"; import CalendarsMain from "./Calendars/Main"; import TasksMain from "./Tasks/Main"; @@ -29,6 +30,7 @@ import { SyncManager } from "./sync/SyncManager"; import { StoreState } from "./store"; import { performSync } from "./store/actions"; import { useCredentials } from "./credentials"; +import PimNavigationTabs from "./Pim/NavigationTabs"; export interface SyncInfoJournal { journal: EteSync.Journal; @@ -93,17 +95,26 @@ export default function SyncGate() { - + + + + - + + + + - + + + +