Merge pull request #1520 from matrix-org/rxl881/deleteWidget

Add a delete confirmation dialog for widgets
pull/21833/head
Richard Lewis 2017-10-25 10:45:52 +01:00 committed by GitHub
commit fd85c74bc5
2 changed files with 26 additions and 13 deletions

View File

@ -172,18 +172,29 @@ export default React.createClass({
*/ */
_onDeleteClick: function() { _onDeleteClick: function() {
if (this._canUserModify()) { if (this._canUserModify()) {
console.log("Delete widget %s", this.props.id); // Show delete confirmation dialog
this.setState({deleting: true}); const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
MatrixClientPeg.get().sendStateEvent( Modal.createTrackedDialog('Delete Widget', '', QuestionDialog, {
this.props.room.roomId, title: _t("Delete Widget"),
'im.vector.modular.widgets', description: _t(
{}, // empty content "Deleting a widget removes it for all users in this room." +
this.props.id, " Are you sure you want to delete this widget?"),
).then(() => { button: _t("Delete widget"),
console.log('Deleted widget'); onFinished: (confirmed) => {
}, (e) => { if (!confirmed) {
console.error('Failed to delete widget', e); return;
this.setState({deleting: false}); }
this.setState({deleting: true});
MatrixClientPeg.get().sendStateEvent(
this.props.room.roomId,
'im.vector.modular.widgets',
{}, // empty content
this.props.id,
).catch((e) => {
console.error('Failed to delete widget', e);
this.setState({deleting: false});
});
},
}); });
} else { } else {
console.log("Revoke widget permissions - %s", this.props.id); console.log("Revoke widget permissions - %s", this.props.id);
@ -305,7 +316,7 @@ export default React.createClass({
let deleteIcon = 'img/cancel.svg'; let deleteIcon = 'img/cancel.svg';
let deleteClasses = 'mx_filterFlipColor mx_AppTileMenuBarWidget'; let deleteClasses = 'mx_filterFlipColor mx_AppTileMenuBarWidget';
if(this._canUserModify()) { if(this._canUserModify()) {
deleteIcon = 'img/cancel-red.svg'; deleteIcon = 'img/icon-delete-pink.svg';
deleteClasses += ' mx_AppTileMenuBarWidgetDelete'; deleteClasses += ' mx_AppTileMenuBarWidgetDelete';
} }

View File

@ -200,6 +200,8 @@
"Authentication": "Authentication", "Authentication": "Authentication",
"Failed to delete device": "Failed to delete device", "Failed to delete device": "Failed to delete device",
"Delete": "Delete", "Delete": "Delete",
"Delete Widget": "Delete Widget",
"Deleting a widget removes it for all users in this room. Are you sure you want to delete this widget?": "Deleting a widget removes it for all users in this room. Are you sure you want to delete this widget?",
"Disable Notifications": "Disable Notifications", "Disable Notifications": "Disable Notifications",
"Enable Notifications": "Enable Notifications", "Enable Notifications": "Enable Notifications",
"Cannot add any more widgets": "Cannot add any more widgets", "Cannot add any more widgets": "Cannot add any more widgets",