Skip to content

A platform for community discussion. Free, open, simple.

FIX: Do not show an empty modal when an IP address is allowed or blocked. (#6265)

Bianca Nenciudc5fddbfe68f
diff --git a/app/assets/javascripts/admin/components/screened-ip-address-form.js.es6 b/app/assets/javascripts/admin/components/screened-ip-address-form.js.es6
index 1a1dd977094..6197bfc3202 100644
--- a/app/assets/javascripts/admin/components/screened-ip-address-form.js.es6
+++ b/app/assets/javascripts/admin/components/screened-ip-address-form.js.es6
@@ -59,18 +59,14 @@ export default Ember.Component.extend({
screenedIpAddress
.save()
.then(result => {
- if (result.success) {
- this.setProperties({ ip_address: "", formSubmitted: false });
- this.sendAction(
- "action",
- ScreenedIpAddress.create(result.screened_ip_address)
- );
- Ember.run.schedule("afterRender", () =>
- this.$(".ip-address-input").focus()
- );
- } else {
- bootbox.alert(result.errors);
- }
+ this.setProperties({ ip_address: "", formSubmitted: false });
+ this.sendAction(
+ "action",
+ ScreenedIpAddress.create(result.screened_ip_address)
+ );
+ Ember.run.schedule("afterRender", () =>
+ this.$(".ip-address-input").focus()
+ );
})
.catch(e => {
this.set("formSubmitted", false);
diff --git a/app/assets/javascripts/admin/controllers/admin-logs-screened-ip-addresses.js.es6 b/app/assets/javascripts/admin/controllers/admin-logs-screened-ip-addresses.js.es6
index ff52b53bf32..a5eb32ae57d 100644
--- a/app/assets/javascripts/admin/controllers/admin-logs-screened-ip-addresses.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-logs-screened-ip-addresses.js.es6
@@ -46,19 +46,14 @@ export default Ember.Controller.extend({
record.set("editing", false);
record
.save()
- .then(saved => {
- if (saved.success) {
- this.set("savedIpAddress", null);
- } else {
- bootbox.alert(saved.errors);
- if (wasEditing) record.set("editing", true);
- }
+ .then(() => {
+ this.set("savedIpAddress", null);
})
.catch(e => {
- if (e.responseJSON && e.responseJSON.errors) {
+ if (e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors) {
bootbox.alert(
I18n.t("generic_error_with_reason", {
- error: e.responseJSON.errors.join(". ")
+ error: e.jqXHR.responseJSON.errors.join(". ")
})
);
} else {
diff --git a/app/controllers/admin/screened_ip_addresses_controller.rb b/app/controllers/admin/screened_ip_addresses_controller.rb
index 6e92777233b..1447fe2dbc9 100644
--- a/app/controllers/admin/screened_ip_addresses_controller.rb
+++ b/app/controllers/admin/screened_ip_addresses_controller.rb
@@ -33,7 +33,7 @@ class Admin::ScreenedIpAddressesController < Admin::AdminController
def update
if @screened_ip_address.update_attributes(allowed_params)
- render json: success_json
+ render_serialized(@screened_ip_address, ScreenedIpAddressSerializer)
else
render_json_error(@screened_ip_address)
end