Skip to content

Commit 75784e5

Browse files
committed
updated sweeetalert2 to the new major version 9
1 parent 1cd0019 commit 75784e5

File tree

13 files changed

+112
-113
lines changed

13 files changed

+112
-113
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"resolve-url-loader": "^3.1.1",
5050
"sass-loader": "^8.0.2",
5151
"semver": "^6.3.0",
52-
"sweetalert2": "^8.18.7",
52+
"sweetalert2": "^9.7.1",
5353
"sweetalert2-react-content": "^1.1.0",
5454
"webpack": "^4.41.5",
5555
"webpack-cli": "^3.3.10",

ui/App/components/Mods/ModLoadSave.jsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ModLoadSave extends React.Component {
4747
if(checkboxes.length == 0) {
4848
ReactSwalNormal.fire({
4949
title: "No mods in this save!",
50-
type: "error"
50+
icon: "error"
5151
});
5252
return;
5353
}
@@ -78,7 +78,7 @@ class ModLoadSave extends React.Component {
7878
ReactSwalNormal.fire({
7979
title: "Mods to install",
8080
html: table,
81-
type: 'question',
81+
icon: 'question',
8282
showCancelButton: true,
8383
confirmButtonText: "Download Mods!",
8484
showLoaderOnConfirm: true,
@@ -89,37 +89,40 @@ class ModLoadSave extends React.Component {
8989
ReactSwalNormal.fire({
9090
title: jqXHR.responseJSON.data,
9191
html: true,
92-
type: "error",
92+
icon: "error",
9393
});
9494
}
9595
});
9696
}
9797

9898
loadModsSwalHandler() {
99-
$.ajax({
99+
// TODO remove jquery Ajax, use react one, return Promise from fetch
100+
return new Promise((resolve, reject) => $.ajax({
100101
url: "/api/mods/install/multiple",
101102
method: "POST",
102103
dataType: "JSON",
103104
data: $("#swalForm").serialize(),
104105
success: (data) => {
106+
resolve();
105107
ReactSwalNormal.fire({
106108
title: "All Mods installed successfully!",
107-
type: "success"
109+
icon: "success"
108110
});
109111

110112
this.props.modContentClass.setState({
111113
installedMods: data.data.mods
112114
});
113115
},
114116
error: (jqXHR) => {
117+
reject();
115118
let json_data = JSON.parse(jqXHR.responseJSON.data);
116119

117120
ReactSwalNormal.fire({
118121
title: json_data.detail,
119-
type: "error",
122+
icon: "error",
120123
});
121124
}
122-
})
125+
}));
123126
}
124127

125128
render() {

ui/App/components/Mods/ModOverview.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ModOverview extends React.Component {
4141

4242
ReactSwalNormal.fire({
4343
title: json_data.detail,
44-
type: "error"
44+
icon: "error"
4545
});
4646
}
4747
})

ui/App/components/Mods/packs/ModPackOverview.jsx

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ class ModPackOverview extends React.Component {
6767
},
6868
showLoaderOnConfirm: true,
6969
preConfirm: (inputValue) => {
70-
// console.log(this);
71-
72-
$.ajax({
70+
// TODO remove jquery Ajax, use react one, return Promise from fetch
71+
return new Promise((resolve, reject) => $.ajax({
7372
url: "/api/mods/packs/create",
7473
method: "POST",
7574
data: {name: inputValue},
7675
dataType: "JSON",
7776
success: (data) => {
7877
this.mutex.lock(() => {
78+
resolve();
7979
let packList = this.state.listPacks;
8080

8181
data.data.mod_packs.forEach((v, k) => {
@@ -91,24 +91,25 @@ class ModPackOverview extends React.Component {
9191

9292
ReactSwalNormal.fire({
9393
title: "modpack created successfully",
94-
type: "success"
94+
icon: "success"
9595
});
9696

9797
this.mutex.unlock();
9898
});
9999
},
100100
error: (jqXHR, status, err) => {
101+
reject();
101102
console.log('api/mods/packs/create', status, err.toString());
102103

103104
let jsonResponse = jqXHR.responseJSON;
104105

105106
ReactSwalNormal.fire({
106107
title: "Error on creating modpack",
107108
text: jsonResponse.data,
108-
type: "error"
109+
icon: "error"
109110
});
110111
}
111-
});
112+
}));
112113
}
113114
});
114115
}
@@ -121,18 +122,20 @@ class ModPackOverview extends React.Component {
121122
ReactSwalDanger.fire({
122123
title: "Are you sure?",
123124
html: <p>You really want to delete this modpack?<br/>There is no turning back, the modpack will be deleted forever (a very long time)!</p>,
124-
type: "question",
125+
icon: "question",
125126
showCancelButton: true,
126127
showLoaderOnConfirm: true,
127128
preConfirm: () => {
128-
$.ajax({
129+
// TODO remove jquery Ajax, use react one, return Promise from fetch
130+
return new Promise((resolve, reject) => $.ajax({
129131
url: "/api/mods/packs/delete",
130132
method: "POST",
131133
data: {name: name},
132134
dataType: "JSON",
133135
success: (data) => {
134136
if(data.success) {
135137
this.mutex.lock(() => {
138+
resolve();
136139
let modPacks = this.state.listPacks;
137140

138141
modPacks.forEach((v, k) => {
@@ -147,14 +150,15 @@ class ModPackOverview extends React.Component {
147150

148151
ReactSwalNormal.fire({
149152
title: "Modpack deleted successfully",
150-
type: "success"
153+
icon: "success"
151154
});
152155

153156
this.mutex.unlock();
154157
});
155158
}
156159
},
157160
error: (jqXHR, status, err) => {
161+
reject();
158162
console.log('api/mods/packs/delete', status, err.toString());
159163

160164
let jsonResponse = jqXHR.responseJSON || err.toString();
@@ -163,10 +167,10 @@ class ModPackOverview extends React.Component {
163167
ReactSwalNormal.fire({
164168
title: "Error on creating modpack",
165169
text: jsonResponse,
166-
type: "error"
170+
icon: "error"
167171
});
168172
}
169-
})
173+
}));
170174
}
171175
});
172176
}
@@ -179,26 +183,29 @@ class ModPackOverview extends React.Component {
179183
ReactSwalDanger.fire({
180184
title: "Are you sure?",
181185
text: "This operation will replace the current installed mods with the mods out of the selected ModPack!",
182-
type: "question",
186+
icon: "question",
183187
showCancelButton: true,
184188
showLoaderOnConfirm: true,
185189
preConfirm: () => {
186-
$.ajax({
190+
// TODO remove jquery Ajax, use react one, return Promise from fetch
191+
return new Promise((resolve, reject) => $.ajax({
187192
url: "/api/mods/packs/load",
188193
method: "POST",
189194
data: {name: name},
190195
dataType: "JSON",
191196
success: (data) => {
197+
resolve();
192198
ReactSwalNormal.fire({
193199
title: "ModPack loaded!",
194-
type: "success"
200+
icon: "success"
195201
});
196202

197203
this.props.modContentClass.setState({
198204
installedMods: data.data.mods
199205
});
200206
},
201207
error: (jqXHR, status, err) => {
208+
reject();
202209
console.log('api/mods/packs/load', status, err.toString());
203210

204211
let jsonResponse = jqXHR.responseJSON || err.toString();
@@ -207,10 +214,10 @@ class ModPackOverview extends React.Component {
207214
ReactSwalNormal.fire({
208215
title: "Error on loading ModPack",
209216
text: jsonResponse,
210-
type: "error"
217+
icon: "error"
211218
});
212219
}
213-
})
220+
}));
214221
}
215222
});
216223
}
@@ -227,7 +234,7 @@ class ModPackOverview extends React.Component {
227234
ReactSwalNormal.fire({
228235
title: "Toggle mod failed",
229236
text: "Can't toggle the mod, when an update is still in progress",
230-
type: "error"
237+
icon: "error"
231238
});
232239
return false;
233240
}
@@ -274,7 +281,7 @@ class ModPackOverview extends React.Component {
274281
ReactSwalNormal.fire({
275282
title: "Toggle Mod went wrong",
276283
text: err.toString(),
277-
type: "error"
284+
icon: "error"
278285
});
279286
}
280287
});
@@ -287,7 +294,7 @@ class ModPackOverview extends React.Component {
287294
ReactSwalNormal.fire({
288295
title: "Delete failed",
289296
text: "Can't delete the mod, when an update is still in progress",
290-
type: "error"
297+
icon: "error"
291298
});
292299
return false;
293300
}
@@ -300,13 +307,14 @@ class ModPackOverview extends React.Component {
300307
ReactSwalDanger.fire({
301308
title: "Delete Mod?",
302309
text: "This will delete the mod forever",
303-
type: "question",
310+
icon: "question",
304311
showCancelButton: true,
305312
confirmButtonText: "Delete it!",
306313
cancelButtonText: "Close",
307314
showLoaderOnConfirm: true,
308315
preConfirm: () => {
309-
$.ajax({
316+
// TODO remove jquery Ajax, use react one, return Promise from fetch
317+
return new Promise((resolve, reject) => $.ajax({
310318
url: "/api/mods/packs/mod/delete",
311319
method: "POST",
312320
data: {
@@ -317,9 +325,10 @@ class ModPackOverview extends React.Component {
317325
success: (data) => {
318326
if(data.success) {
319327
this.mutex.lock(() => {
328+
resolve();
320329
ReactSwalNormal.fire({
321330
title: <p>Delete of mod {modName} inside modPack {modPackName} successful</p>,
322-
type: "success"
331+
icon: "success"
323332
})
324333

325334
let packList = this.state.listPacks;
@@ -344,14 +353,15 @@ class ModPackOverview extends React.Component {
344353
}
345354
},
346355
error: (jqXHR, status, err) => {
356+
reject();
347357
console.log('api/mods/packs/mod/delete', status, err.toString());
348358
ReactSwalNormal.fire({
349359
title: "Delete Mod went wrong",
350360
text: jqXHR.responseJSON.data,
351-
type: "error"
361+
icon: "error"
352362
});
353363
}
354-
});
364+
}));
355365
}
356366
});
357367
}
@@ -363,7 +373,7 @@ class ModPackOverview extends React.Component {
363373
ReactSwalNormal.fire({
364374
title: "Update failed",
365375
text: "please login into Factorio to update mod",
366-
type: "error",
376+
icon: "error",
367377
});
368378

369379
let $addModBox = $('#add-mod-box');
@@ -423,7 +433,7 @@ class ModPackOverview extends React.Component {
423433
ReactSwalNormal.fire({
424434
title: "Update Mod went wrong",
425435
text: jqXHR.responseJSON.data,
426-
type: "error"
436+
icon: "error"
427437
});
428438
}
429439
});

0 commit comments

Comments
 (0)