Skip to content

Commit de1e8e9

Browse files
committed
implement redact and links
1 parent dbac2e2 commit de1e8e9

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

‎src/skins/vector/views/atoms/ImageView.js‎

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ limitations under the License.
1818

1919
var React = require('react');
2020

21+
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
22+
2123
var DateUtils = require('../../../../DateUtils');
2224
var filesize = require('filesize');
2325

2426
module.exports = React.createClass({
2527
displayName: 'ImageView',
2628

27-
// XXX: keyboard shortcuts for managing dialogs should be done by the modal dialog base class omehow, surely...
29+
// XXX: keyboard shortcuts for managing dialogs should be done by the modal dialog base class somehow, surely...
2830
componentDidMount: function() {
2931
document.addEventListener("keydown", this.onKeyDown);
3032
},
@@ -41,6 +43,23 @@ module.exports = React.createClass({
4143
}
4244
},
4345

46+
onRedactClick: function() {
47+
var self = this;
48+
MatrixClientPeg.get().redactEvent(
49+
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
50+
).done(function() {
51+
if (self.props.onFinished) self.props.onFinished();
52+
}, function(e) {
53+
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
54+
// display error message stating you couldn't delete this.
55+
var code = e.errcode || e.statusCode;
56+
Modal.createDialog(ErrorDialog, {
57+
title: "Error",
58+
description: "You cannot delete this image. (" + code + ")"
59+
});
60+
});
61+
},
62+
4463
render: function() {
4564

4665
/*
@@ -89,13 +108,17 @@ module.exports = React.createClass({
89108
<div className="mx_ImageView_metadata">
90109
Uploaded on { DateUtils.formatDate(new Date(this.props.mxEvent.getTs())) } by { this.props.mxEvent.getSender() }
91110
</div>
92-
<div className="mx_ImageView_download">
93-
Download this file ({ filesize(this.props.mxEvent.getContent().info.size) })
94-
</div>
111+
<a className="mx_ImageView_link" href={ this.props.src } target="_blank">
112+
<div className="mx_ImageView_download">
113+
Download this file ({ filesize(this.props.mxEvent.getContent().info.size) })
114+
</div>
115+
</a>
95116
<div className="mx_ImageView_button">
96-
View full screen
117+
<a className="mx_ImageView_link" href={ this.props.src } target="_blank">
118+
View full screen
119+
</a>
97120
</div>
98-
<div className="mx_ImageView_button">
121+
<div className="mx_ImageView_button" onClick={this.onRedactClick}>
99122
Redact
100123
</div>
101124
<div className="mx_ImageView_shim">

0 commit comments

Comments
 (0)