prevent editing on desc/title if not authorized to edit

This commit is contained in:
Devin Howard 2017-01-28 15:52:00 -05:00
parent 5c8e9f41bf
commit ad26a7fb2b
3 changed files with 48 additions and 24 deletions

View file

@ -31,8 +31,7 @@ class Desc extends Component {
? '<p.Click to add description...</p>'
: Util.mdToHTML(this.props.desc)
const htmlSpan = <span dangerouslySetInnerHTML={{ __html: descHTML }} />
if (this.props.authorizedToEdit) {
return (
<div className="scroll">
<div className="desc">
@ -58,6 +57,17 @@ class Desc extends Component {
</div>
</div>
)
} else {
return (
<div className="scroll">
<div className="desc">
<span className="riek_desc">
{this.props.desc}
</span>
</div>
</div>
)
}
}
}

View file

@ -2,6 +2,7 @@ import React from 'react'
import { RIETextArea } from 'riek'
const Title = (props) => {
if (props.authorizedToEdit) {
return (
<span className="title">
<RIETextArea value={props.name}
@ -22,12 +23,22 @@ const Title = (props) => {
/>
</span>
)
} else {
return (
<span className="title">
<span className="titleWrapper">
{props.name}
</span>
</span>
)
}
}
/*
* Title.propTypes = {
* name: PropTypes.string,
* onChange: PropTypes.func
* onChange: PropTypes.func,
* authorizedToEdit: PropTypes.bool
* }
*/

View file

@ -23,7 +23,10 @@ class ReactTopicCard extends Component {
return (
<div className={classname}>
<div className={`CardOnGraph ${hasAttachment ? 'hasAttachment' : ''}`} id={`topic_${topicId}`}>
<Title name={topic.get('name')} onChange={this.props.updateTopic} />
<Title name={topic.get('name')}
onChange={this.props.updateTopic}
authorizedToEdit={topic.authorizeToEdit(ActiveMapper)}
/>
<Links topic={topic}
ActiveMapper={this.props.ActiveMapper}
updateTopic={this.props.updateTopic}