From 96adbd61855692dc1fedd477f1a044e93330e11f Mon Sep 17 00:00:00 2001 From: andrey Date: Fri, 26 Jun 2020 12:42:15 +0200 Subject: [PATCH] [#10811] There should be an option to continue opening suspicious urls --- src/status_im/browser/core.cljs | 7 +++++++ .../screens/browser/site_blocked/styles.cljs | 7 ++----- .../screens/browser/site_blocked/views.cljs | 21 +++++++++++-------- src/status_im/ui/screens/browser/views.cljs | 7 ++++--- translations/en.json | 3 ++- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/status_im/browser/core.cljs b/src/status_im/browser/core.cljs index bd397d39ef..ad152f6845 100644 --- a/src/status_im/browser/core.cljs +++ b/src/status_im/browser/core.cljs @@ -139,6 +139,13 @@ (update-browser (assoc browser :history-index (dec history-index))) (resolve-url nil))))) +(fx/defn ignore-unsafe + {:events [:browser/ignore-unsafe]} + [cofx] + (let [browser (get-current-browser (:db cofx)) + host (http/url-host (get-current-url browser))] + (update-browser cofx (assoc browser :ignore-unsafe host)))) + (defn can-go-forward? [{:keys [history-index history]}] (< history-index (dec (count history)))) diff --git a/src/status_im/ui/screens/browser/site_blocked/styles.cljs b/src/status_im/ui/screens/browser/site_blocked/styles.cljs index da1e7545c1..361320d5b1 100644 --- a/src/status_im/ui/screens/browser/site_blocked/styles.cljs +++ b/src/status_im/ui/screens/browser/site_blocked/styles.cljs @@ -3,8 +3,7 @@ (def container {:justify-content :center - :flex 1 - :background-color colors/gray-lighter}) + :flex 1}) (def container-root-view {:flex 1 @@ -26,6 +25,4 @@ {:color colors/blue}) (def buttons-container - {:flex-direction :row - :justify-content :center - :margin-top 24}) + {:margin 24}) diff --git a/src/status_im/ui/screens/browser/site_blocked/views.cljs b/src/status_im/ui/screens/browser/site_blocked/views.cljs index 3cd22db1e9..b669049798 100644 --- a/src/status_im/ui/screens/browser/site_blocked/views.cljs +++ b/src/status_im/ui/screens/browser/site_blocked/views.cljs @@ -2,10 +2,10 @@ (:require [re-frame.core :as re-frame] [status-im.i18n :as i18n] [status-im.ui.components.colors :as colors] - [status-im.ui.components.common.common :as components.common] [status-im.ui.components.icons.vector-icons :as vector-icons] [status-im.ui.components.react :as react] - [status-im.ui.screens.browser.site-blocked.styles :as styles]) + [status-im.ui.screens.browser.site-blocked.styles :as styles] + [quo.core :as quo]) (:require-macros [status-im.utils.views :as views])) (views/defview view [{:keys [can-go-back?]}] @@ -16,16 +16,19 @@ [vector-icons/icon :main-icons/info {:color colors/red}] [react/text {:style styles/title-text} (i18n/label :t/browsing-site-blocked-title)] - [react/nested-text {:style styles/description-text} + [react/nested-text {:style styles/description-text} (i18n/label :t/browsing-site-blocked-description1) [{:on-press #(.openURL ^js react/linking "status-im://chat/public/status") :style styles/chat-link-text} "#status"] (i18n/label :t/browsing-site-blocked-description2)] [react/view styles/buttons-container - [components.common/button {:on-press (fn [] - (let [handler (if can-go-back? - :browser.ui/previous-page-button-pressed - :navigate-back)] - (re-frame/dispatch [handler]))) - :label (i18n/label :t/browsing-site-blocked-go-back)}]]]]) + [quo/button {:on-press (fn [] + (let [handler (if can-go-back? + :browser.ui/previous-page-button-pressed + :navigate-back)] + (re-frame/dispatch [handler])))} + (i18n/label :t/browsing-site-blocked-go-back)]] + [quo/button {:theme :negative + :on-press #(re-frame/dispatch [:browser/ignore-unsafe])} + (i18n/label :t/continue-anyway)]]]) diff --git a/src/status_im/ui/screens/browser/views.cljs b/src/status_im/ui/screens/browser/views.cljs index 97bdbd81ae..96aea7ad32 100644 --- a/src/status_im/ui/screens/browser/views.cljs +++ b/src/status_im/ui/screens/browser/views.cljs @@ -105,7 +105,7 @@ ;; should-component-update is called only when component's props are changed, ;; that's why it can't be used in `browser`, because `url` comes from subs (views/defview browser-component - [{:keys [error? url browser browser-id unsafe? can-go-back? + [{:keys [error? url browser browser-id unsafe? can-go-back? ignore-unsafe can-go-forward? resolving? network-id url-original show-permission show-tooltip dapp? name dapps-account]}] {:should-component-update (fn [_ _ args] @@ -114,7 +114,7 @@ [react/view {:flex 1 :elevation -10} [react/view components.styles/flex - (if unsafe? + (if (and unsafe? (not= (http/url-host url) ignore-unsafe)) [site-blocked.views/view {:can-go-back? can-go-back? :site browser-id}] [components.webview/webview @@ -148,7 +148,7 @@ (views/defview browser [] (views/letsubs [window-width [:dimensions/window-width] - {:keys [browser-id dapp? name unsafe?] :as browser} [:get-current-browser] + {:keys [browser-id dapp? name unsafe? ignore-unsafe] :as browser} [:get-current-browser] {:keys [url error? loading? url-editing? show-tooltip show-permission resolving?]} [:browser/options] dapps-account [:dapps-account] network-id [:chain-id]] @@ -167,6 +167,7 @@ :browser browser :browser-id browser-id :unsafe? unsafe? + :ignore-unsafe ignore-unsafe :can-go-back? can-go-back? :can-go-forward? can-go-forward? :resolving? resolving? diff --git a/translations/en.json b/translations/en.json index a5d86ea7fb..4b716fea08 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1157,5 +1157,6 @@ "tx-fail-description2" : "This transaction is likely to fail. Set a custom network fee to sign at your own risk.", "set-custom-fee" : "Set custom fee", "not-enough-snt": "Not enough SNT", - "set-max": "Set max" + "set-max": "Set max", + "continue-anyway": "Continue anyway" }