From f61d5f0f85a954120b2676a5153f10a05662cf42 Mon Sep 17 00:00:00 2001
From: Ildar Kamalov <i.kamalov@adguard.com>
Date: Thu, 13 Feb 2020 14:13:35 +0300
Subject: [PATCH] + client: show confirm before setting static IP

---
 client/src/__locales/en.json         | 3 ++-
 client/src/install/Setup/Settings.js | 8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json
index 138082c7..e54c4a34 100644
--- a/client/src/__locales/en.json
+++ b/client/src/__locales/en.json
@@ -468,5 +468,6 @@
     "set_static_ip": "Set a static IP address",
     "install_static_ok": "Good news! The static IP address is already configured",
     "install_static_error": "AdGuard Home cannot configure it automatically for your OS. Please look for an instruction on how to do this manually",
-    "install_static_configure": "We have detected that a dynamic IP address is used — <0>{{ip}}</0>. Do you want to use it as your static address?"
+    "install_static_configure": "We have detected that a dynamic IP address is used — <0>{{ip}}</0>. Do you want to use it as your static address?",
+    "confirm_static_ip": "AdGuard Home will configure {{ip}} to be your static IP address. Do you want to proceed?"
 }
diff --git a/client/src/install/Setup/Settings.js b/client/src/install/Setup/Settings.js
index 1c4da3fa..876aa05b 100644
--- a/client/src/install/Setup/Settings.js
+++ b/client/src/install/Setup/Settings.js
@@ -89,7 +89,7 @@ class Settings extends Component {
                         <button
                             type="button"
                             className="btn btn-outline-primary btn-sm"
-                            onClick={this.handleStaticIp}
+                            onClick={() => this.handleStaticIp(ip)}
                         >
                             <Trans>set_static_ip</Trans>
                         </button>
@@ -133,7 +133,7 @@ class Settings extends Component {
         handleFix(web, dns, set_static_ip);
     };
 
-    handleStaticIp = () => {
+    handleStaticIp = (ip) => {
         const {
             webIp,
             webPort,
@@ -146,7 +146,9 @@ class Settings extends Component {
         const dns = { ip: dnsIp, port: dnsPort, autofix: false };
         const set_static_ip = true;
 
-        handleFix(web, dns, set_static_ip);
+        if (window.confirm(this.props.t('confirm_static_ip', { ip }))) {
+            handleFix(web, dns, set_static_ip);
+        }
     };
 
     render() {