specify sizes and hyperlinks for non-event images

This commit is contained in:
Matthew Hodgson 2016-04-04 00:16:52 +01:00
parent 333f1e46ca
commit d7eb23db53
1 changed files with 19 additions and 7 deletions

View File

@ -29,8 +29,10 @@ module.exports = React.createClass({
propTypes: { propTypes: {
mxEvent: React.PropTypes.object, mxEvent: React.PropTypes.object,
src: React.PropTypes.string.isRequired, src: React.PropTypes.string.isRequired,
link: React.PropTypes.string,
width: React.PropTypes.number, width: React.PropTypes.number,
height: React.PropTypes.number, height: React.PropTypes.number,
size: React.PropTypes.number,
onFinished: React.PropTypes.func.isRequired, onFinished: React.PropTypes.func.isRequired,
name: React.PropTypes.string name: React.PropTypes.string
}, },
@ -76,11 +78,15 @@ module.exports = React.createClass({
if(this.props.name) { if(this.props.name) {
name = this.props.name; name = this.props.name;
} else if(this.props.mxEvent) { } else if(this.props.mxEvent) {
name = props.mxEvent.getContent().body; name = this.props.mxEvent.getContent().body;
} else { } else {
name = null; name = null;
} }
if (name && this.props.link) {
name = <a href={ this.props.link } target="_blank">{ name }</a>;
}
return name; return name;
}, },
@ -121,14 +127,20 @@ module.exports = React.createClass({
width: this.props.width, width: this.props.width,
height: this.props.height, height: this.props.height,
}; };
res = ", " + style.width + "x" + style.height + "px"; res = style.width + "x" + style.height + "px";
} }
var size; var size;
if (this.props.mxEvent && if (this.props.size) {
this.props.mxEvent.getContent().info && size = filesize(this.props.size);
this.props.mxEvent.getContent().info.size) { }
size = filesize(this.props.mxEvent.getContent().info.size);
var size_res;
if (size && res) {
size_res = size + ", " + res;
}
else {
size_res = size || res;
} }
var showEventMeta = !!this.props.mxEvent; var showEventMeta = !!this.props.mxEvent;
@ -165,7 +177,7 @@ module.exports = React.createClass({
<a className="mx_ImageView_link" href={ this.props.src } target="_blank"> <a className="mx_ImageView_link" href={ this.props.src } target="_blank">
<div className="mx_ImageView_download"> <div className="mx_ImageView_download">
Download this file<br/> Download this file<br/>
<span className="mx_ImageView_size">{ size } { res }</span> <span className="mx_ImageView_size">{ size_res }</span>
</div> </div>
</a> </a>
{ eventRedact } { eventRedact }