Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SweetAlert2 v6.11.5 -> 9.5.4 #1617

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Draft
- Update sweetalert2 library to latest version [#1617](https://github.com/bigcommerce/cornerstone/pull/1617)
- Allow alert text color editing from theme editor and update default alert text color for Bold variation [#1565](https://github.com/bigcommerce/cornerstone/pull/1565)
- Add jquery-migrate to Modal test [#1599](https://github.com/bigcommerce/cornerstone/pull/1599)
- Upgrade core-js to version 3 [#1598](https://github.com/bigcommerce/cornerstone/pull/1598)
Expand Down
12 changes: 6 additions & 6 deletions assets/js/theme/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ export default class Account extends PageManager {

if (!submitForm) {
event.preventDefault();
swal({
swal.fire({
text: this.context.selectItem,
type: 'error',
icon: 'error',
});
}
});
Expand Down Expand Up @@ -198,9 +198,9 @@ export default class Account extends PageManager {
return true;
}

swal({
swal.fire({
text: errorMessage,
type: 'error',
icon: 'error',
});

return event.preventDefault();
Expand Down Expand Up @@ -299,9 +299,9 @@ export default class Account extends PageManager {
storeInstrument(this.context, data, () => {
window.location.href = this.context.paymentMethodsUrl;
}, () => {
swal({
swal.fire({
text: this.context.generic_error,
type: 'error',
icon: 'error',
});
});
}
Expand Down
64 changes: 33 additions & 31 deletions assets/js/theme/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ export default class Cart extends PageManager {
const newQty = $target.data('action') === 'inc' ? oldQty + 1 : oldQty - 1;
// Does not quality for min/max quantity
if (newQty < minQty) {
return swal({
return swal.fire({
text: minError,
type: 'error',
icon: 'error',
});
} else if (maxQty > 0 && newQty > maxQty) {
return swal({
return swal.fire({
text: maxError,
type: 'error',
icon: 'error',
});
}

Expand All @@ -51,9 +51,9 @@ export default class Cart extends PageManager {
this.refreshContent(remove);
} else {
$el.val(oldQty);
swal({
swal.fire({
text: response.data.errors.join('\n'),
type: 'error',
icon: 'error',
});
}
});
Expand All @@ -74,21 +74,21 @@ export default class Cart extends PageManager {
if (!newQty) {
invalidEntry = $el.val();
$el.val(oldQty);
return swal({
return swal.fire({
text: `${invalidEntry} is not a valid entry`,
type: 'error',
icon: 'error',
});
} else if (newQty < minQty) {
$el.val(oldQty);
return swal({
return swal.fire({
text: minError,
type: 'error',
icon: 'error',
});
} else if (maxQty > 0 && newQty > maxQty) {
$el.val(oldQty);
return swal({
return swal.fire({
text: maxError,
type: 'error',
icon: 'error',
});
}

Expand All @@ -103,9 +103,9 @@ export default class Cart extends PageManager {
this.refreshContent(remove);
} else {
$el.val(oldQty);
swal({
swal.fire({
text: response.data.errors.join('\n'),
type: 'error',
icon: 'error',
});
}
});
Expand All @@ -117,9 +117,9 @@ export default class Cart extends PageManager {
if (response.data.status === 'succeed') {
this.refreshContent(true);
} else {
swal({
swal.fire({
text: response.data.errors.join('\n'),
type: 'error',
icon: 'error',
});
}
});
Expand Down Expand Up @@ -150,9 +150,9 @@ export default class Cart extends PageManager {
const data = result.data || {};

if (err) {
swal({
swal.fire({
text: err,
type: 'error',
icon: 'error',
});
return false;
}
Expand Down Expand Up @@ -240,13 +240,15 @@ export default class Cart extends PageManager {
$('.cart-remove', this.$cartContent).on('click', event => {
const itemId = $(event.currentTarget).data('cartItemid');
const string = $(event.currentTarget).data('confirmDelete');
swal({
swal.fire({
text: string,
type: 'warning',
icon: 'warning',
showCancelButton: true,
}).then(() => {
// remove item from cart
cartRemoveItem(itemId);
}).then((result) => {
if (result.value) {
// remove item from cart
cartRemoveItem(itemId);
}
});
event.preventDefault();
});
Expand Down Expand Up @@ -289,19 +291,19 @@ export default class Cart extends PageManager {

// Empty code
if (!code) {
return swal({
return swal.fire({
text: $codeInput.data('error'),
type: 'error',
icon: 'error',
});
}

utils.api.cart.applyCode(code, (err, response) => {
if (response.data.status === 'success') {
this.refreshContent();
} else {
swal({
swal.fire({
text: response.data.errors.join('\n'),
type: 'error',
icon: 'error',
});
}
});
Expand Down Expand Up @@ -333,19 +335,19 @@ export default class Cart extends PageManager {
event.preventDefault();

if (!giftCertCheck(code)) {
return swal({
return swal.fire({
text: $certInput.data('error'),
type: 'error',
icon: 'error',
});
}

utils.api.cart.applyGiftCertificate(code, (err, resp) => {
if (resp.data.status === 'success') {
this.refreshContent();
} else {
swal({
swal.fire({
text: resp.data.errors.join('\n'),
type: 'error',
icon: 'error',
});
}
});
Expand Down
4 changes: 2 additions & 2 deletions assets/js/theme/cart/shipping-estimator.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export default class ShippingEstimator {
// Requests the states for a country with AJAX
stateCountry(this.$state, this.context, { useIdForStates: true }, (err, field) => {
if (err) {
swal({
swal.fire({
text: err,
type: 'error',
icon: 'error',
});

throw new Error(err);
Expand Down
14 changes: 10 additions & 4 deletions assets/js/theme/global/sweet-alert.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import 'weakmap-polyfill';
import sweetAlert from 'sweetalert2';

// WeakMap will defined in the global scope if native WeakMap is not supported.
const weakMap = new WeakMap(); // eslint-disable-line no-unused-vars

// Set defaults for sweetalert2 popup boxes
sweetAlert.setDefaults({
const Swal = sweetAlert.mixin({
buttonsStyling: false,
confirmButtonClass: 'button',
cancelButtonClass: 'button',
customClass: {
confirmButton: 'button',
cancelButton: 'button',
},
});

// Re-export
export default sweetAlert;
export default Swal;