Hook up the edit widget button (#1218)

* Hook up the edit widget button

* Review comments
This commit is contained in:
Kegsay 2017-07-14 11:17:59 +01:00 committed by GitHub
parent 1db2431c9f
commit 5274cf59a0
3 changed files with 20 additions and 7 deletions

View file

@ -491,7 +491,7 @@ function canSendEvent(event, roomId) {
} }
if (!canSend) { if (!canSend) {
sendError(event, _t('You do not have permission in this room.')); sendError(event, _t('You do not have permission to do that in this room.'));
return; return;
} }

View file

@ -21,7 +21,9 @@ import React from 'react';
import MatrixClientPeg from '../../../MatrixClientPeg'; import MatrixClientPeg from '../../../MatrixClientPeg';
import ScalarAuthClient from '../../../ScalarAuthClient'; import ScalarAuthClient from '../../../ScalarAuthClient';
import SdkConfig from '../../../SdkConfig'; import SdkConfig from '../../../SdkConfig';
import Modal from '../../../Modal';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import sdk from '../../../index';
const ALLOWED_APP_URL_SCHEMES = ['https:', 'http:']; const ALLOWED_APP_URL_SCHEMES = ['https:', 'http:'];
@ -33,6 +35,7 @@ export default React.createClass({
url: React.PropTypes.string.isRequired, url: React.PropTypes.string.isRequired,
name: React.PropTypes.string.isRequired, name: React.PropTypes.string.isRequired,
room: React.PropTypes.object.isRequired, room: React.PropTypes.object.isRequired,
type: React.PropTypes.string.isRequired,
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -86,8 +89,13 @@ export default React.createClass({
}); });
}, },
_onEditClick: function() { _onEditClick: function(e) {
console.log("Edit widget %s", this.props.id); console.log("Edit widget ID ", this.props.id);
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
const src = this._scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId, 'type_' + this.props.type);
Modal.createDialog(IntegrationsManager, {
src: src,
}, "mx_IntegrationsManager");
}, },
_onDeleteClick: function() { _onDeleteClick: function() {
@ -120,10 +128,10 @@ export default React.createClass({
<div> Loading... </div> <div> Loading... </div>
); );
} else { } else {
// Note that there is advice saying allow-scripts shouldn;t be used with allow-same-origin // Note that there is advice saying allow-scripts shouldn't be used with allow-same-origin
// because that would allow the iframe to prgramatically remove the sandbox attribute, but // because that would allow the iframe to prgramatically remove the sandbox attribute, but
// this would only be for content hosted on the same origin as the riot client: anything // this would only be for content hosted on the same origin as the riot client: anything
// hosted on the same origin as the client will get the same access access as if you clicked // hosted on the same origin as the client will get the same access as if you clicked
// a link to it. // a link to it.
const sandboxFlags = "allow-forms allow-popups allow-popups-to-escape-sandbox "+ const sandboxFlags = "allow-forms allow-popups allow-popups-to-escape-sandbox "+
"allow-same-origin allow-scripts"; "allow-same-origin allow-scripts";
@ -140,18 +148,22 @@ export default React.createClass({
</div> </div>
); );
} }
// editing is done in scalar
const showEditButton = Boolean(this._scalarClient);
return ( return (
<div className={this.props.fullWidth ? "mx_AppTileFullWidth" : "mx_AppTile"} id={this.props.id}> <div className={this.props.fullWidth ? "mx_AppTileFullWidth" : "mx_AppTile"} id={this.props.id}>
<div className="mx_AppTileMenuBar"> <div className="mx_AppTileMenuBar">
{this.formatAppTileName()} {this.formatAppTileName()}
<span className="mx_AppTileMenuBarWidgets"> <span className="mx_AppTileMenuBarWidgets">
{/* Edit widget */} {/* Edit widget */}
{/* <img {showEditButton && <img
src="img/edit.svg" src="img/edit.svg"
className="mx_filterFlipColor mx_AppTileMenuBarWidget mx_AppTileMenuBarWidgetPadding" className="mx_filterFlipColor mx_AppTileMenuBarWidget mx_AppTileMenuBarWidgetPadding"
width="8" height="8" alt="Edit" width="8" height="8" alt="Edit"
onClick={this._onEditClick} onClick={this._onEditClick}
/> */} />}
{/* Delete widget */} {/* Delete widget */}
<img src="img/cancel.svg" <img src="img/cancel.svg"

View file

@ -169,6 +169,7 @@ module.exports = React.createClass({
id={app.id} id={app.id}
url={app.url} url={app.url}
name={app.name} name={app.name}
type={app.type}
fullWidth={arr.length<2 ? true : false} fullWidth={arr.length<2 ? true : false}
room={this.props.room} room={this.props.room}
userId={this.props.userId} userId={this.props.userId}