fix embedly
This commit is contained in:
parent
4eab4cefe8
commit
9f29a24321
1 changed files with 38 additions and 29 deletions
|
@ -61,7 +61,7 @@ class Attachments extends Component {
|
||||||
loadLink = () => {
|
loadLink = () => {
|
||||||
this.setState({embedlyLinkStarted: true})
|
this.setState({embedlyLinkStarted: true})
|
||||||
var e = embedly('card', document.getElementById('embedlyLink'))
|
var e = embedly('card', document.getElementById('embedlyLink'))
|
||||||
if (e.type === 'error') this.setState({embedlyLinkError: true})
|
if (e && e.type === 'error') this.setState({embedlyLinkError: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
removeLink = () => {
|
removeLink = () => {
|
||||||
|
@ -76,39 +76,48 @@ class Attachments extends Component {
|
||||||
render = () => {
|
render = () => {
|
||||||
const { topic, ActiveMapper } = this.props
|
const { topic, ActiveMapper } = this.props
|
||||||
const { linkEdit, embedlyLinkLoaded, embedlyLinkStarted, embedlyLinkError } = this.state
|
const { linkEdit, embedlyLinkLoaded, embedlyLinkStarted, embedlyLinkError } = this.state
|
||||||
var authorizedToEdit = topic.authorizeToEdit(ActiveMapper)
|
|
||||||
|
|
||||||
|
const authorizedToEdit = topic.authorizeToEdit(ActiveMapper)
|
||||||
const hasAttachment = topic.get('link') && topic.get('link') !== ''
|
const hasAttachment = topic.get('link') && topic.get('link') !== ''
|
||||||
|
|
||||||
if (hasAttachment) {
|
if (!hasAttachment && !authorizedToEdit) return null
|
||||||
return (
|
|
||||||
<div className={`embeds ${embedlyLinkLoaded ? '' : 'nonEmbedlyLink'}`}>
|
const className = hasAttachment
|
||||||
<a href={topic.get('link')} id="embedlyLink" target="_blank" data-card-description="0">
|
? `embeds ${embedlyLinkLoaded ? '' : 'nonEmbedlyLink'}`
|
||||||
{topic.get('link')}
|
: 'attachments'
|
||||||
</a>
|
|
||||||
{embedlyLinkStarted && !embedlyLinkLoaded && !embedlyLinkError && <div id="embedlyLinkLoader">loading...</div>}
|
return (
|
||||||
{authorizedToEdit && <div id="linkremove" onClick={this.removeLink}></div>}
|
<div className={className}>
|
||||||
</div>
|
<div className="addLink"
|
||||||
)
|
style={{ display: hasAttachment ? 'none' : 'block' }}
|
||||||
} else if (authorizedToEdit) {
|
>
|
||||||
return (
|
<div id="addLinkIcon"></div>
|
||||||
<div className="attachments">
|
<div id="addLinkInput">
|
||||||
<div className="addLink">
|
<input ref={input => this.linkInput = input}
|
||||||
<div id="addLinkIcon"></div>
|
placeholder="Enter or paste a link"
|
||||||
<div id="addLinkInput">
|
value={linkEdit}
|
||||||
<input ref={input => this.linkInput = input}
|
onChange={this.onLinkChangeHandler}
|
||||||
placeholder="Enter or paste a link"
|
onKeyUp={this.onLinkKeyUpHandler}></input>
|
||||||
value={linkEdit}
|
{linkEdit && <div id="addLinkReset"></div>}
|
||||||
onChange={this.onLinkChangeHandler}
|
|
||||||
onKeyUp={this.onLinkKeyUpHandler}></input>
|
|
||||||
{linkEdit && <div id="addLinkReset"></div>}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
<a style={{ display: hasAttachment ? 'block' : 'none' }}
|
||||||
} else {
|
href={topic.get('link')}
|
||||||
return null
|
id="embedlyLink"
|
||||||
}
|
target="_blank"
|
||||||
|
data-card-description="0"
|
||||||
|
>
|
||||||
|
{topic.get('link')}
|
||||||
|
</a>
|
||||||
|
{embedlyLinkStarted && !embedlyLinkLoaded && !embedlyLinkError && <div id="embedlyLinkLoader">loading...</div>}
|
||||||
|
{authorizedToEdit && (
|
||||||
|
<div id="linkremove"
|
||||||
|
style={{ display: hasAttachment ? 'block' : 'none' }}
|
||||||
|
onClick={this.removeLink}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue