Journal edit: disallow editing journals we don't own.

master
Tom Hacohen 6 years ago
parent c5fc6f23f5
commit 525ec58081

@ -28,6 +28,7 @@ import { historyPersistor } from '../persist-state-history';
interface PropsType { interface PropsType {
syncInfo: SyncInfo; syncInfo: SyncInfo;
syncJournal: SyncInfoJournal; syncJournal: SyncInfoJournal;
isOwner: boolean;
} }
interface PropsTypeInner extends PropsType { interface PropsTypeInner extends PropsType {
@ -52,7 +53,7 @@ class Journal extends React.PureComponent<PropsTypeInner> {
} }
render() { render() {
const { theme, syncJournal } = this.props; const { theme, isOwner, syncJournal } = this.props;
let currentTab = this.state.tab; let currentTab = this.state.tab;
let journalOnly = false; let journalOnly = false;
@ -85,6 +86,7 @@ class Journal extends React.PureComponent<PropsTypeInner> {
return ( return (
<React.Fragment> <React.Fragment>
<AppBarOverride title={collectionInfo.displayName}> <AppBarOverride title={collectionInfo.displayName}>
{ isOwner &&
<IconButton <IconButton
component={Link} component={Link}
title="Edit" title="Edit"
@ -92,6 +94,7 @@ class Journal extends React.PureComponent<PropsTypeInner> {
> >
<IconEdit /> <IconEdit />
</IconButton> </IconButton>
}
</AppBarOverride> </AppBarOverride>
<Tabs <Tabs
fullWidth={true} fullWidth={true}

@ -60,6 +60,8 @@ class Journals extends React.PureComponent {
return (<div>Journal not found!</div>); return (<div>Journal not found!</div>);
} }
const isOwner = syncJournal.journal.owner === this.props.etesync.credentials.email;
const collectionInfo = syncJournal.collection; const collectionInfo = syncJournal.collection;
return ( return (
<Switch> <Switch>
@ -81,6 +83,7 @@ class Journals extends React.PureComponent {
<Journal <Journal
syncInfo={this.props.syncInfo} syncInfo={this.props.syncInfo}
syncJournal={syncJournal} syncJournal={syncJournal}
isOwner={isOwner}
/> />
)} )}
/> />

Loading…
Cancel
Save