diff --git a/src/Pim/PimMain.tsx b/src/Pim/PimMain.tsx deleted file mode 100644 index f4849ef..0000000 --- a/src/Pim/PimMain.tsx +++ /dev/null @@ -1,179 +0,0 @@ -// SPDX-FileCopyrightText: © 2017 EteSync Authors -// SPDX-License-Identifier: AGPL-3.0-only - -import * as React from "react"; -import Fab from "@material-ui/core/Fab"; -import ContentAdd from "@material-ui/icons/Add"; -import Tab from "@material-ui/core/Tab"; -import Tabs from "@material-ui/core/Tabs"; -import { Theme, withTheme } from "@material-ui/core/styles"; - -import * as ICAL from "ical.js"; - -import * as EteSync from "etesync"; - -import { Location, History } from "history"; - -import Container from "../widgets/Container"; - -import SearchableAddressBook from "../components/SearchableAddressBook"; -import Calendar from "../components/Calendar"; -import TaskList from "../components/Tasks/TaskList"; - -import { EventType, ContactType, TaskType, PimType } from "../pim-types"; - -import { routeResolver } from "../App"; - -import { historyPersistor } from "../persist-state-history"; -import { SyncInfo } from "../SyncGate"; -import { UserInfoData, CredentialsData } from "../store"; - -const addressBookTitle = "Address Book"; -const calendarTitle = "Calendar"; -const tasksTitle = "Tasks"; - -const PersistCalendar = historyPersistor("Calendar")(Calendar); - -interface PropsType { - contacts: ContactType[]; - events: EventType[]; - tasks: TaskType[]; - location?: Location; - history?: History; - theme: Theme; - collectionsTaskList: EteSync.CollectionInfo[]; - onItemSave: (item: PimType, journalUid: string, originalItem?: PimType) => Promise; - syncInfo: SyncInfo; - userInfo: UserInfoData; - etesync: CredentialsData; -} - -class PimMain extends React.PureComponent { - public state: { - tab: number; - }; - - constructor(props: any) { - super(props); - this.state = { tab: 1 }; - this.eventClicked = this.eventClicked.bind(this); - this.taskClicked = this.taskClicked.bind(this); - this.contactClicked = this.contactClicked.bind(this); - this.floatingButtonClicked = this.floatingButtonClicked.bind(this); - this.newEvent = this.newEvent.bind(this); - } - - public eventClicked(event: ICAL.Event) { - // FIXME:Hack - const itemUid = `${(event as any).journalUid}|${encodeURIComponent(event.uid)}`; - - this.props.history!.push( - routeResolver.getRoute("pim.events._id", { itemUid })); - } - - public taskClicked(event: ICAL.Event) { - // FIXME:Hack - const itemUid = `${(event as any).journalUid}|${encodeURIComponent(event.uid)}`; - - this.props.history!.push( - routeResolver.getRoute("pim.tasks._id.edit", { itemUid })); - } - - public contactClicked(contact: ContactType) { - // FIXME:Hack - const itemUid = `${(contact as any).journalUid}|${encodeURIComponent(contact.uid)}`; - - this.props.history!.push( - routeResolver.getRoute("pim.contacts._id", { itemUid })); - } - - public newEvent(start?: Date, end?: Date) { - this.props.history!.push( - routeResolver.getRoute("pim.events.new"), - { start, end } - ); - } - - public floatingButtonClicked() { - if (this.state.tab === 0) { - this.props.history!.push( - routeResolver.getRoute("pim.contacts.new") - ); - } else if (this.state.tab === 1) { - this.newEvent(); - } else if (this.state.tab === 2) { - this.props.history!.push( - routeResolver.getRoute("pim.tasks.new") - ); - } - } - - public render() { - const { theme } = this.props; - const { tab } = this.state; - const style = { - floatingButton: { - margin: 0, - top: "auto", - right: 20, - bottom: 20, - left: "auto", - position: "fixed", - } as any, - }; - - return ( - - this.setState({ tab: value })} - > - - - - - - - {tab === 0 && - - } - {tab === 1 && - - } - {tab === 2 && - - } - - - - - - - ); - } -} - -export default withTheme(historyPersistor("PimMain")(PimMain)); diff --git a/src/Pim/index.tsx b/src/Pim/index.tsx index 6c79709..180a5dd 100644 --- a/src/Pim/index.tsx +++ b/src/Pim/index.tsx @@ -30,7 +30,6 @@ import EventEdit from "../components/EventEdit"; import Event from "../components/Event"; import TaskEdit from "../components/Tasks/TaskEdit"; import Task from "../components/Tasks/Task"; -import PimMain from "./PimMain"; import { routeResolver } from "../App"; @@ -77,11 +76,6 @@ const itemsSelector = createSelector( } ); -const itemValuesSelector = createSelector( - itemsSelector, - ({ addressBookItems, calendarItems, taskListItems }) => [addressBookItems, calendarItems, taskListItems].map(Object.values) -); - const ItemChangeLog = React.memo((props: any) => { const { syncInfo, @@ -396,27 +390,9 @@ class Pim extends React.PureComponent { public render() { const { collectionsAddressBook, collectionsCalendar, collectionsTaskList, addressBookItems, calendarItems, taskListItems } = itemsSelector(this.props); - const [contacts, events, tasks] = itemValuesSelector(this.props); return ( - ( - - )} - /> (