implement redact and links

This commit is contained in:
Matthew Hodgson 2015-10-29 00:38:26 +00:00
parent dbac2e299e
commit de1e8e9f93
1 changed files with 29 additions and 6 deletions

View File

@ -18,13 +18,15 @@ limitations under the License.
var React = require('react'); var React = require('react');
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
var DateUtils = require('../../../../DateUtils'); var DateUtils = require('../../../../DateUtils');
var filesize = require('filesize'); var filesize = require('filesize');
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'ImageView', displayName: 'ImageView',
// XXX: keyboard shortcuts for managing dialogs should be done by the modal dialog base class omehow, surely... // XXX: keyboard shortcuts for managing dialogs should be done by the modal dialog base class somehow, surely...
componentDidMount: function() { componentDidMount: function() {
document.addEventListener("keydown", this.onKeyDown); document.addEventListener("keydown", this.onKeyDown);
}, },
@ -41,6 +43,23 @@ module.exports = React.createClass({
} }
}, },
onRedactClick: function() {
var self = this;
MatrixClientPeg.get().redactEvent(
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
).done(function() {
if (self.props.onFinished) self.props.onFinished();
}, function(e) {
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
// display error message stating you couldn't delete this.
var code = e.errcode || e.statusCode;
Modal.createDialog(ErrorDialog, {
title: "Error",
description: "You cannot delete this image. (" + code + ")"
});
});
},
render: function() { render: function() {
/* /*
@ -89,13 +108,17 @@ module.exports = React.createClass({
<div className="mx_ImageView_metadata"> <div className="mx_ImageView_metadata">
Uploaded on { DateUtils.formatDate(new Date(this.props.mxEvent.getTs())) } by { this.props.mxEvent.getSender() } Uploaded on { DateUtils.formatDate(new Date(this.props.mxEvent.getTs())) } by { this.props.mxEvent.getSender() }
</div> </div>
<a className="mx_ImageView_link" href={ this.props.src } target="_blank">
<div className="mx_ImageView_download"> <div className="mx_ImageView_download">
Download this file ({ filesize(this.props.mxEvent.getContent().info.size) }) Download this file ({ filesize(this.props.mxEvent.getContent().info.size) })
</div> </div>
</a>
<div className="mx_ImageView_button"> <div className="mx_ImageView_button">
<a className="mx_ImageView_link" href={ this.props.src } target="_blank">
View full screen View full screen
</a>
</div> </div>
<div className="mx_ImageView_button"> <div className="mx_ImageView_button" onClick={this.onRedactClick}>
Redact Redact
</div> </div>
<div className="mx_ImageView_shim"> <div className="mx_ImageView_shim">