Removing commands

This commit is contained in:
James Barnsley
2018-10-09 21:51:47 +13:00
parent fc3f5e2d2f
commit c8dc36cd04
5 changed files with 51 additions and 1 deletions

View File

@ -5579,6 +5579,7 @@ exports.getQueueMetadata = getQueueMetadata;
exports.queueMetadataChanged = queueMetadataChanged;
exports.addQueueMetadata = addQueueMetadata;
exports.setCommand = setCommand;
exports.removeCommand = removeCommand;
exports.sendCommand = sendCommand;
exports.commandsUpdated = commandsUpdated;
@ -5797,6 +5798,13 @@ function setCommand(command) {
};
}
function removeCommand(id) {
return {
type: 'PUSHER_REMOVE_COMMAND',
id: id
};
}
function sendCommand(id) {
return {
type: 'PUSHER_SEND_COMMAND',
@ -54385,6 +54393,14 @@ var PusherMiddleware = function () {
next(action);
break;
case 'PUSHER_REMOVE_COMMAND':
var commands_index = Object.assign({}, store.getState().pusher.commands);
delete commands_index[action.id];
store.dispatch(pusherActions.commandsUpdated(commands_index));
next(action);
break;
case 'PUSHER_SEND_COMMAND':
var commands_index = Object.assign({}, pusher.commands);
@ -82153,6 +82169,12 @@ var EditCommand = function (_React$Component) {
return false;
}
}, {
key: 'handleDelete',
value: function handleDelete(e) {
this.props.pusherActions.removeCommand(this.state.id);
window.history.back();
}
}, {
key: 'render',
value: function render() {
@ -82229,6 +82251,13 @@ var EditCommand = function (_React$Component) {
_react2.default.createElement(
'div',
{ className: 'actions centered-text' },
this.props.command ? _react2.default.createElement(
'button',
{ type: 'button', className: 'destructive large', onClick: function onClick(e) {
return _this2.handleDelete(e);
} },
'Delete'
) : null,
_react2.default.createElement(
'button',
{ type: 'submit', className: 'primary large' },

File diff suppressed because one or more lines are too long

View File

@ -204,6 +204,13 @@ export function setCommand(command){
}
}
export function removeCommand(id){
return {
type: 'PUSHER_REMOVE_COMMAND',
id: id
}
}
export function sendCommand(id){
return {
type: 'PUSHER_SEND_COMMAND',

View File

@ -407,6 +407,14 @@ const PusherMiddleware = (function(){
next(action);
break
case 'PUSHER_REMOVE_COMMAND':
var commands_index = Object.assign({}, store.getState().pusher.commands);
delete commands_index[action.id];
store.dispatch(pusherActions.commandsUpdated(commands_index));
next(action);
break
case 'PUSHER_SEND_COMMAND':
var commands_index = Object.assign({}, pusher.commands);

View File

@ -45,6 +45,11 @@ class EditCommand extends React.Component{
return false;
}
handleDelete(e){
this.props.pusherActions.removeCommand(this.state.id);
window.history.back();
}
render(){
return (
<Modal className="modal--create-command">
@ -85,6 +90,7 @@ class EditCommand extends React.Component{
</div>
<div className="actions centered-text">
{this.props.command ? <button type="button" className="destructive large" onClick={e => this.handleDelete(e)}>Delete</button> : null}
<button type="submit" className="primary large">Save</button>
</div>