Skip to content

Commit 9fec285

Browse files
committed
added buttons to ui for downloading and deleting modpacks
1 parent 9547653 commit 9fec285

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

ui/App/components/Mods/ModPacks.jsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

4077
ModPacks.propTypes = {
4178
modPacks: React.PropTypes.array.isRequired,
79+
loadModPackList: React.PropTypes.func.isRequired,
4280
}
4381

4482
export default ModPacks

ui/App/components/ModsContent.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class ModsContent extends React.Component {
109109
/>
110110
<ModPacks
111111
{...this.state}
112+
loadModPackList={this.loadModPackList}
112113
/>
113114

114115
</section>

0 commit comments

Comments
 (0)