Journal: only show change log, not the items.

Was very confusing to people.
master
Tom Hacohen 4 years ago
parent a1bdea6290
commit e38181a8ae

@ -3,35 +3,22 @@
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';
@ -43,22 +30,13 @@ interface PropsType {
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<PropsTypeInner> {
class Journal extends React.Component<PropsType> {
public state: {
tab: number;
importDialogOpen: boolean;
};
constructor(props: PropsTypeInner) {
constructor(props: PropsType) {
super(props);
this.importDialogToggle = this.importDialogToggle.bind(this);
@ -69,43 +47,12 @@ class Journal extends React.Component<PropsTypeInner> {
}
public render() {
const { theme, isOwner, syncJournal } = this.props;
let currentTab = this.state.tab;
let journalOnly = false;
const { isOwner, syncJournal } = this.props;
const journal = syncJournal.journal;
const collectionInfo = syncJournal.collection;
const syncEntries = syncJournal.entries;
let itemsTitle: string;
let itemsView: JSX.Element;
if (collectionInfo.type === 'CALENDAR') {
itemsView = (
<JournalCalendar
journal={journal}
entries={syncEntriesToEventItemMap(collectionInfo, syncEntries)}
/>);
itemsTitle = 'Events';
} else if (collectionInfo.type === 'ADDRESS_BOOK') {
itemsView =
<JournalAddressBook journal={journal} entries={syncEntriesToItemMap(collectionInfo, syncEntries)} />;
itemsTitle = 'Contacts';
} else if (collectionInfo.type === 'TASKS') {
itemsView = (
<JournalTaskList
journal={journal}
syncInfo={this.props.syncInfo}
entries={syncEntriesToTaskItemMap(collectionInfo, syncEntries)}
/>);
itemsTitle = 'Tasks';
} else {
itemsView = <div>Preview is not supported for this journal type</div>;
itemsTitle = 'Items';
journalOnly = true;
}
currentTab = journalOnly ? 1 : currentTab;
return (
<React.Fragment>
<AppBarOverride title={collectionInfo.displayName}>
@ -134,25 +81,9 @@ class Journal extends React.Component<PropsTypeInner> {
<IconImport />
</IconButton>
</AppBarOverride>
<Tabs
variant="fullWidth"
style={{ backgroundColor: theme.palette.primary.main }}
value={currentTab}
onChange={(_event, tab) => this.setState({ tab })}
>
<Tab label={itemsTitle} disabled={journalOnly} />
<Tab label="Journal Entries" />
</Tabs>
{currentTab === 0 &&
<Container>
{itemsView}
</Container>
}
{currentTab === 1 &&
<Container>
<JournalEntries journal={journal} entries={syncEntries} />
</Container>
}
<ImportDialog
etesync={this.props.etesync}
@ -170,4 +101,4 @@ class Journal extends React.Component<PropsTypeInner> {
}
}
export default withTheme(Journal);
export default Journal;

Loading…
Cancel
Save