Removing commands
This commit is contained in:
@ -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',
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user