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

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

Loading…
Cancel
Save