Skip to content

Commit d78c9fb

Browse files
authored
sweetalert update (#6195)
This updates sweetalert to sweetalert2 in most javascript files. However, the only file that does not change is NDB_Page.class.inc, since there is some error in Travis. Resolves (partially) #6114 See also #6192
1 parent 338b6dd commit d78c9fb

File tree

19 files changed

+75
-56
lines changed

19 files changed

+75
-56
lines changed

modules/candidate_parameters/jsx/CandidateDOB.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import Loader from 'Loader';
4+
import swal from 'sweetalert2';
45

56
class CandidateDOB extends Component {
67
constructor(props) {
@@ -111,7 +112,7 @@ class CandidateDOB extends Component {
111112
let dob = this.state.formData.dob ?
112113
this.state.formData.dob : null;
113114
if (dob > today) {
114-
swal({
115+
swal.fire({
115116
title: 'Error!',
116117
text: 'Date of birth cannot be later than today!',
117118
type: 'error',
@@ -140,7 +141,7 @@ class CandidateDOB extends Component {
140141
})
141142
.then((resp) => {
142143
if (resp.ok && resp.status === 200) {
143-
swal({
144+
swal.fire({
144145
title: 'Success!',
145146
text: 'Date of birth updated!',
146147
type: 'success',
@@ -150,7 +151,7 @@ class CandidateDOB extends Component {
150151
this.fetchData();
151152
}
152153
} else {
153-
swal({
154+
swal.fire({
154155
title: 'Error!',
155156
text: 'Something went wrong.',
156157
type: 'error',

modules/candidate_parameters/jsx/CandidateDOD.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import Loader from 'Loader';
4+
import swal from 'sweetalert2';
45

56
class CandidateDOD extends Component {
67
constructor(props) {
@@ -112,7 +113,7 @@ class CandidateDOD extends Component {
112113
this.state.data.dob : null;
113114

114115
if (dod > today) {
115-
swal({
116+
swal.fire({
116117
title: 'Invalid date',
117118
text: 'Date of death cannot be later than today!',
118119
type: 'error',
@@ -122,7 +123,7 @@ class CandidateDOD extends Component {
122123
}
123124

124125
if (dob > dod) {
125-
swal({
126+
swal.fire({
126127
title: 'Invalid date',
127128
text: 'Date of death must be after date of birth!',
128129
type: 'error',
@@ -152,7 +153,7 @@ class CandidateDOD extends Component {
152153
}
153154
).then((resp) => resp.text()
154155
).then((result) => {
155-
swal({
156+
swal.fire({
156157
title: 'Success!',
157158
text: 'Date of death updated!',
158159
type: 'success',
@@ -163,7 +164,7 @@ class CandidateDOD extends Component {
163164
}
164165
}).catch((error) => {
165166
console.error(error);
166-
swal({
167+
swal.fire({
167168
title: 'Error!',
168169
text: 'Something went wrong.',
169170
type: 'error',

modules/candidate_parameters/jsx/ConsentStatus.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
3-
3+
import swal from 'sweetalert2';
44
import Loader from 'Loader';
55

66
/**
@@ -181,13 +181,13 @@ class ConsentStatus extends Component {
181181
contentType: false,
182182
processData: false,
183183
success: (data) => {
184-
swal('Success!', 'Update successful.', 'success');
184+
swal.fire('Success!', 'Update successful.', 'success');
185185
this.fetchData();
186186
},
187187
error: (error) => {
188188
console.error(error);
189189
let errorMessage = error.responseText || 'Update failed.';
190-
swal('Error!', errorMessage, 'error');
190+
swal.fire('Error!', errorMessage, 'error');
191191
},
192192
});
193193
}

modules/data_release/jsx/addPermissionForm.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import Loader from 'jsx/Loader';
4+
import swal from 'sweetalert2';
45

56
/**
67
* Add Permission Form
@@ -161,7 +162,7 @@ class AddPermissionForm extends Component {
161162
body: formObj,
162163
}).then( (response) => {
163164
if (response.ok) {
164-
swal({
165+
swal.fire({
165166
text: 'Permission Update Success!',
166167
title: '',
167168
type: 'success',
@@ -173,7 +174,7 @@ class AddPermissionForm extends Component {
173174
let msg = response.statusText ?
174175
response.statusText :
175176
'Submission Error!';
176-
swal(msg, '', 'error');
177+
swal.fire(msg, '', 'error');
177178
console.error(msg);
178179
}
179180
});

modules/data_release/jsx/managePermissionsForm.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import Loader from 'jsx/Loader';
4+
import swal from 'sweetalert2';
45
import Modal from 'Modal';
56

67
/**
@@ -130,7 +131,7 @@ class ManagePermissionsForm extends Component {
130131
})
131132
.then((response) => {
132133
if (response.ok) {
133-
swal({
134+
swal.fire({
134135
text: 'Permission Update Success!',
135136
title: '',
136137
type: 'success',
@@ -140,7 +141,7 @@ class ManagePermissionsForm extends Component {
140141
} else {
141142
let msg = response.statusText ?
142143
response.statusText : 'Submission Error!';
143-
swal(msg, '', 'error');
144+
swal.fire(msg, '', 'error');
144145
console.error(msg);
145146
return Promise.reject();
146147
}

modules/data_release/jsx/uploadFileForm.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import ProgressBar from 'ProgressBar';
4+
import swal from 'sweetalert2';
45

56

67
/**
@@ -134,7 +135,7 @@ class UploadFileForm extends Component {
134135
+ ')';
135136
errorMessage['Filesize'] = msg;
136137
hasError['Filesize'] = true;
137-
swal({
138+
swal.fire({
138139
title: 'Error',
139140
text: msg,
140141
type: 'error',
@@ -175,12 +176,12 @@ class UploadFileForm extends Component {
175176
errorMessage: msg,
176177
uploadProgress: -1,
177178
});
178-
swal(msg, '', 'error');
179+
swal.fire(msg, '', 'error');
179180
console.error(msg);
180181
} else {
181182
const responseUrl = new URL(response.url);
182183
if (responseUrl.searchParams.has('duplicate')) {
183-
swal({
184+
swal.fire({
184185
title: 'Are you sure?',
185186
text: 'A file with this name already exists!\n '
186187
+ 'Would you like to overwrite existing file?\n '
@@ -207,7 +208,7 @@ class UploadFileForm extends Component {
207208
formData: {}, // reset form data after successful file upload
208209
uploadProgress: -1,
209210
});
210-
swal({
211+
swal.fire({
211212
text: 'Upload Successful!',
212213
title: '',
213214
type: 'success',
@@ -223,7 +224,7 @@ class UploadFileForm extends Component {
223224
errorMessage: msg,
224225
uploadProgress: -1,
225226
});
226-
swal(msg, '', 'error');
227+
swal.fire(msg, '', 'error');
227228
console.error(error);
228229
});
229230
}

modules/document_repository/jsx/categoryForm.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import PropTypes from 'prop-types';
22
import Loader from 'Loader';
3+
import swal from 'sweetalert2';
4+
35
/**
46
* Document Upload Form
57
*
@@ -129,7 +131,7 @@ class DocCategoryForm extends React.Component {
129131
this.setState({
130132
formData: {}, // reset form data after successful file upload
131133
});
132-
swal('Add Successful!', '', 'success');
134+
swal.fire('Add Successful!', '', 'success');
133135
});
134136
}
135137
/**

modules/document_repository/jsx/docIndex.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ChildTree from './childTree';
66
import Loader from 'Loader';
77
import FilterableDataTable from 'FilterableDataTable';
88
import NullFilterableDataTable from './NullFilterableDataTable';
9+
import swal from 'sweetalert2';
910

1011
class DocIndex extends React.Component {
1112
constructor(props) {
@@ -147,7 +148,7 @@ class DocIndex extends React.Component {
147148
case 'Delete File':
148149
let id = row['Edit'];
149150
function click() {
150-
swal({
151+
swal.fire({
151152
title: 'Are you sure?',
152153
text: 'Your will not be able to recover this file!',
153154
type: 'warning',
@@ -165,7 +166,7 @@ class DocIndex extends React.Component {
165166
}).then((resp) => resp.json())
166167
.then(()=>{
167168
location.reload();
168-
swal('delete Successful!', '', 'success');
169+
swal.fire('delete Successful!', '', 'success');
169170
});
170171
}
171172
);

modules/document_repository/jsx/editForm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* exported DocEditForm */
22
import Loader from 'Loader';
33
import PropTypes from 'prop-types';
4+
import swal from 'sweetalert2';
45
/**
56
* Document Edit Form
67
*
@@ -141,7 +142,7 @@ class DocEditForm extends React.Component {
141142
})
142143
.then((resp) => resp.json())
143144
.then(()=>{
144-
swal('Updated Successful!', '', 'success');
145+
swal.fire('Updated Successful!', '', 'success');
145146
this.fetchData();
146147
});
147148
}

modules/help_editor/js/help_editor_helper.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import swal from 'sweetalert2';
2+
13
$(document).ready(function(){
24
$("input[name=preview]").click(function(e) {
35
if($('div.help-content').length) {
@@ -65,7 +67,7 @@ $("#save-help").click(function(e) {
6567
helpID: helpID ? helpID : '',
6668
},
6769
success: function() {
68-
swal({
70+
swal.fire({
6971
title: "Content update successful!",
7072
type: "success",
7173
showCancelButton: true,
@@ -80,7 +82,7 @@ $("#save-help").click(function(e) {
8082
},
8183
error: function(xhr, errorCode, errorMsg) {
8284
console.error(xhr);
83-
swal({
85+
swal.fire({
8486
title: "Content update unsuccessful.",
8587
text: errorCode + ": " + xhr.status + " " + errorMsg,
8688
type: "error",

0 commit comments

Comments
 (0)