@@ -55,7 +55,6 @@ import './style.css';
5555 return { collapsed, ...props } ;
5656} , ( dispatch , props ) => {
5757 const { uid } = props ;
58-
5958 return {
6059 onToggle : ( ) => store . dispatch ( flexActions . toggle ( uid ) ) ,
6160 } ;
@@ -116,7 +115,6 @@ export default class ActionsPanel extends React.Component {
116115 . then ( ( ) => {
117116 const { id } = this . urlParams ;
118117 const { groups } = this . props ;
119-
120118 if ( id && groups && ! groups . some ( ( { actions } ) => actions . some ( ( { ref } ) => ref === id ) ) ) {
121119 this . navigate ( { id : false } ) ;
122120 }
@@ -128,8 +126,7 @@ export default class ActionsPanel extends React.Component {
128126 const {
129127 ref = get ( 'groups[0].actions[0].ref' , this . props ) ,
130128 section = 'general' ,
131- } = this . props . match . params ;
132-
129+ } = this . props . match . params ;
133130 return {
134131 id : ref ,
135132 section,
@@ -211,6 +208,30 @@ export default class ActionsPanel extends React.Component {
211208 } ) ;
212209 }
213210
211+ handleDelete ( ref ) {
212+ return store . dispatch ( {
213+ type : 'DELETE_ACTION' ,
214+ ref,
215+ promise : api . request ( {
216+ method : 'delete' ,
217+ path : `/actions/${ ref } ` ,
218+ } )
219+ . then ( ( res ) => {
220+ notification . success ( `Action "${ ref } " has been deleted successfully.` ) ;
221+ this . navigate ( { id : null } ) ;
222+ store . dispatch ( flexActions . toggleAll ( ) ) ;
223+ return res ;
224+ } )
225+ . catch ( ( err ) => {
226+ notification . error ( `Unable to delete action "${ ref } ".` , {
227+ err,
228+
229+ } ) ;
230+ throw err ;
231+ } ) ,
232+ } ) ;
233+ }
234+
214235 render ( ) {
215236 const { groups, filter, collapsed } = this . props ;
216237 const { id, section } = this . urlParams ;
@@ -282,6 +303,7 @@ export default class ActionsPanel extends React.Component {
282303 ref = { ( ref ) => this . _details = ref }
283304 handleNavigate = { ( ...args ) => this . navigate ( ...args ) }
284305 handleRun = { ( ...args ) => this . handleRun ( ...args ) }
306+ handleDelete = { ( ...arg ) => this . handleDelete ( ...arg ) }
285307
286308 id = { id }
287309 section = { section }
0 commit comments