From 62162c0f2af27da09913c1a2cbd98b3d7e7e5bd4 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Tue, 30 Nov 2021 16:13:26 +0200 Subject: [PATCH] [#12848] Add an option to submit error report to GH --- src/status_im/ui/screens/bug_report.cljs | 15 +++++++++--- src/status_im/utils/logging/core.cljs | 29 ++++++++++++++++++++++++ translations/en.json | 2 ++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/status_im/ui/screens/bug_report.cljs b/src/status_im/ui/screens/bug_report.cljs index 23dda827ea..f6bd2e0219 100644 --- a/src/status_im/ui/screens/bug_report.cljs +++ b/src/status_im/ui/screens/bug_report.cljs @@ -35,6 +35,15 @@ {:type :primary :accessibility-label :bug-report-submit :theme :accent - :on-press #(re-frame/dispatch - [:logging/submit-report])} - (i18n/label :t/submit)]]])) + :on-press #(re-frame/dispatch [:logging/submit-report])} + (i18n/label :t/bug-report-submit-email)] + [react-native/view + {:style {:margin-vertical 16 + :align-items :center}} + [quo/text (i18n/label :t/or)]] + [quo/button + {:type :primary + :accessibility-label :bug-report-submit-gh-issue + :theme :accent + :on-press #(re-frame/dispatch [:logging/submit-gh-issue])} + (i18n/label :t/bug-report-submit-gh-issue)]]])) diff --git a/src/status_im/utils/logging/core.cljs b/src/status_im/utils/logging/core.cljs index dbab2a661b..dba53889cc 100644 --- a/src/status_im/utils/logging/core.cljs +++ b/src/status_im/utils/logging/core.cljs @@ -1,6 +1,7 @@ (ns status-im.utils.logging.core (:require ["react-native-mail" :default react-native-mail] [clojure.string :as string] + [goog.string :as gstring] [re-frame.core :as re-frame] [status-im.bottom-sheet.core :as bottom-sheet] [status-im.i18n.i18n :as i18n] @@ -227,3 +228,31 @@ cofx (bottom-sheet/hide-bottom-sheet) (send-logs :email)))) + +(re-frame/reg-fx + ::open-url + (fn [url] + (.openURL ^js react/linking url))) + +(def gh-issue-url "https://github.com/status-im/status-react/issues/new?labels=bug&title=%s&body=%s") + +(fx/defn submit-issue + [{:keys [db]}] + (let [{:keys [steps description]} + (get db :bug-report/details) + + title (or description (i18n/label :t/bug-report-description-placeholder)) + body (str title + "\n\n" + (or steps (i18n/label :t/bug-report-steps-placeholder))) + url (gstring/format gh-issue-url (js/escape title) (js/escape body))] + {::open-url url})) + +(fx/defn submit-gh-issue + {:events [:logging/submit-gh-issue]} + [{:keys [db] :as cofx} details steps] + (fx/merge + cofx + {:db (dissoc db :bug-report/details)} + (bottom-sheet/hide-bottom-sheet) + (submit-issue))) diff --git a/translations/en.json b/translations/en.json index 06a3e82778..1cc64a57c0 100644 --- a/translations/en.json +++ b/translations/en.json @@ -114,6 +114,8 @@ "bug-report-description-placeholder": "Required, can't be empty", "bug-report-steps": "Steps to reproduce", "bug-report-steps-placeholder": "- open app\n- do something\n- and then somethig else...", + "bug-report-submit-email": "Submit by email with logs archive", + "bug-report-submit-gh-issue": "Submit a GitHub issue without logs", "bug-report-too-short-description": "Description is too short", "camera-access-error": "To grant the required camera permission, please go to your system settings and make sure that Status > Camera is selected.", "can-not-add-yourself": "That's you, to start a chat choose someone else",