From acb8030d126a21d9f1f41c8a6eb30bd3230f7fc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9gis=20Hanol?= <regis@hanol.fr>
Date: Fri, 21 Nov 2014 00:31:22 +0100
Subject: [PATCH] add confirm dialog when deleting other accounts with same IP
 address

---
 .../admin/components/ip-lookup.js.es6         | 23 +++++++++++--------
 config/locales/client.en.yml                  |  1 +
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/app/assets/javascripts/admin/components/ip-lookup.js.es6 b/app/assets/javascripts/admin/components/ip-lookup.js.es6
index cf9829f7e..b7dbaf764 100644
--- a/app/assets/javascripts/admin/components/ip-lookup.js.es6
+++ b/app/assets/javascripts/admin/components/ip-lookup.js.es6
@@ -43,17 +43,20 @@ export default Ember.Component.extend({
 
     deleteAllOtherAccounts: function() {
       var self = this;
-      this.setProperties({ other_accounts: null, otherAccountsLoading: true });
-
-      Discourse.ajax("/admin/users/delete-others-with-same-ip.json", {
-        type: "DELETE",
-        data: {
-          "ip": this.get("ip"),
-          "exclude": this.get("user_id"),
-          "order": "trust_level DESC"
+      bootbox.confirm(I18n.t("ip_lookup.confirm_delete_other_accounts"), I18n.t("no_value"), I18n.t("yes_value"), function (confirmed) {
+        if (confirmed) {
+          self.setProperties({ other_accounts: null, otherAccountsLoading: true });
+          Discourse.ajax("/admin/users/delete-others-with-same-ip.json", {
+            type: "DELETE",
+            data: {
+              "ip": self.get("ip"),
+              "exclude": self.get("user_id"),
+              "order": "trust_level DESC"
+            }
+          }).then(function() {
+            self.send("lookup");
+          });
         }
-      }).then(function() {
-        self.send("lookup");
       });
     }
   }
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 43363649d..664e6bda4 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -285,6 +285,7 @@ en:
       read_time: "read time"
       topics_entered: "topics entered"
       post_count: "# posts"
+      confirm_delete_other_accounts: "Are you sure you want to delete these accounts?"
 
     user:
       said: "{{username}}:"