// SPDX-FileCopyrightText: © 2017 EteSync Authors // SPDX-License-Identifier: AGPL-3.0-only import * as React from 'react'; import IconButton from '@material-ui/core/IconButton'; import Tab from '@material-ui/core/Tab'; import Tabs from '@material-ui/core/Tabs'; import { Theme, withTheme } from '@material-ui/core/styles'; import IconEdit from '@material-ui/icons/Edit'; import IconMembers from '@material-ui/icons/People'; import IconImport from '@material-ui/icons/ImportExport'; import SearchableAddressBook from '../components/SearchableAddressBook'; import Contact from '../components/Contact'; import Calendar from '../components/Calendar'; import Event from '../components/Event'; import Task from '../components/Tasks/Task'; import TaskList from '../components/Tasks/TaskList'; import AppBarOverride from '../widgets/AppBarOverride'; import Container from '../widgets/Container'; import JournalEntries from '../components/JournalEntries'; import journalView from './journalView'; import ImportDialog from './ImportDialog'; import { syncEntriesToItemMap, syncEntriesToEventItemMap, syncEntriesToTaskItemMap } from '../journal-processors'; import { SyncInfo, SyncInfoJournal } from '../SyncGate'; import { Link } from 'react-router-dom'; import { routeResolver } from '../App'; import { historyPersistor } from '../persist-state-history'; import { CredentialsData, UserInfoData } from '../store'; interface PropsType { etesync: CredentialsData; userInfo: UserInfoData; syncInfo: SyncInfo; syncJournal: SyncInfoJournal; isOwner: boolean; } interface PropsTypeInner extends PropsType { theme: Theme; } const JournalAddressBook = journalView(SearchableAddressBook, Contact); const PersistCalendar = historyPersistor('Calendar')(Calendar); const JournalCalendar = journalView(PersistCalendar, Event); const JournalTaskList = journalView(TaskList, Task); class Journal extends React.Component { public state: { tab: number; importDialogOpen: boolean; }; constructor(props: PropsTypeInner) { super(props); this.importDialogToggle = this.importDialogToggle.bind(this); this.state = { tab: 0, importDialogOpen: false, }; } public render() { const { theme, isOwner, syncJournal } = this.props; let currentTab = this.state.tab; let journalOnly = false; const journal = syncJournal.journal; const collectionInfo = syncJournal.collection; const syncEntries = syncJournal.entries; let itemsTitle: string; let itemsView: JSX.Element; if (collectionInfo.type === 'CALENDAR') { itemsView = ( ); itemsTitle = 'Events'; } else if (collectionInfo.type === 'ADDRESS_BOOK') { itemsView = ; itemsTitle = 'Contacts'; } else if (collectionInfo.type === 'TASKS') { itemsView = ( ); itemsTitle = 'Tasks'; } else { itemsView =
Preview is not supported for this journal type
; itemsTitle = 'Items'; journalOnly = true; } currentTab = journalOnly ? 1 : currentTab; return ( {isOwner && <> } this.setState({ tab })} > {currentTab === 0 && {itemsView} } {currentTab === 1 && } ); } private importDialogToggle() { this.setState((state: any) => ({ importDialogOpen: !state.importDialogOpen })); } } export default withTheme(Journal);