@@ -5,6 +5,32 @@ class ModPacks extends React.Component {
55 super ( props )
66 }
77
8+ removeModPack ( modpack , e ) {
9+ var self = this ;
10+ swal ( {
11+ title : "Are you sure?" ,
12+ text : "Modpack: " + modpack + " will be deleted" ,
13+ type : "warning" ,
14+ showCancelButton : true ,
15+ confirmButtonColor : "#DD6B55" ,
16+ confirmButtonText : "Yes, delete it!" ,
17+ closeOnConfirm : false
18+ } ,
19+ ( ) => {
20+ $ . ajax ( {
21+ url : "/api/mods/packs/rm/" + modpack ,
22+ dataType : "json" ,
23+ success : ( resp ) => {
24+ if ( resp . success === true ) {
25+ swal ( "Deleted!" , resp . data , "success" ) ;
26+ self . props . loadModPackList ( ) ;
27+ }
28+ }
29+ } )
30+ } ) ;
31+
32+ }
33+
834 render ( ) {
935 return (
1036 < div className = "box" >
@@ -23,9 +49,20 @@ class ModPacks extends React.Component {
2349 </ thead >
2450 < tbody >
2551 { this . props . modPacks . map ( ( mod , i ) => {
52+ console . log ( mod )
53+ let dlURL = "/api/mods/packs/dl/" + mod
2654 return (
2755 < tr key = { i } >
2856 < td > { mod } </ td >
57+ < td > < a className = "btn btn-default" href = { dlURL } > </ a > </ td >
58+ < td >
59+ < button
60+ className = "btn btn-danger"
61+ ref = "modpack"
62+ type = "button"
63+ onClick = { this . removeModPack . bind ( this , mod ) } >
64+ </ button >
65+ </ td >
2966 </ tr >
3067 )
3168 } ) }
@@ -39,6 +76,7 @@ class ModPacks extends React.Component {
3976
4077ModPacks . propTypes = {
4178 modPacks : React . PropTypes . array . isRequired ,
79+ loadModPackList : React . PropTypes . func . isRequired ,
4280}
4381
4482export default ModPacks
0 commit comments