From b4b66f94ec57227b2271b8b67c6b3ccb74982ee8 Mon Sep 17 00:00:00 2001 From: Jakub Date: Mon, 13 Feb 2023 09:46:27 +0100 Subject: [PATCH] feat(GODT-2355): improve wording and actions on bad event --- Makefile | 16 ++++++- .../bridge-gui/bridge-gui/QMLBackend.cpp | 6 ++- .../bridge-gui/bridge-gui/QMLBackend.h | 2 +- .../bridge-gui/qml/BugReportView.qml | 4 ++ .../bridge-gui/qml/ContentWrapper.qml | 7 ++- .../bridge-gui/bridge-gui/qml/MainWindow.qml | 5 +- .../bridge-gui/qml/NotificationPopups.qml | 5 ++ .../qml/Notifications/Notifications.qml | 46 +++++++++++++------ 8 files changed, 71 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 86c969b4..aaab6659 100644 --- a/Makefile +++ b/Makefile @@ -294,7 +294,7 @@ gofiles: ./internal/bridge/credits.go cd ./utils/ && ./credits.sh bridge ## Run and debug -.PHONY: run run-qt run-qt-cli run-nogui run-cli run-noninteractive run-debug run-qml-preview clean-vendor clean-frontend-qt clean-frontend-qt-common clean +.PHONY: run run-qt run-qt-cli run-nogui run-cli run-noninteractive run-debug run-gui-tester clean-vendor clean-frontend-qt clean-frontend-qt-common clean LOG?=debug LOG_IMAP?=client # client/server/all, or empty to turn it off @@ -321,6 +321,20 @@ run-nogui: build-nogui clean-vendor gofiles run-debug: dlv debug ./cmd/Desktop-Bridge/main.go -- -l=debug +ifeq "${TARGET_OS}" "windows" + EXE_SUFFIX=.exe +endif + +bridge-gui-tester: build-gui + cp ./cmd/Desktop-Bridge/deploy/${TARGET_OS}/bridge-gui${EXE_SUFFIX} . + cd ./internal/frontend/bridge-gui/bridge-gui-tester && cmake . && make + +run-gui-tester: bridge-gui-tester + # copying tester as bridge so bridge-gui will start it and connect to it automatically + cp ./internal/frontend/bridge-gui/bridge-gui-tester/bridge-gui-tester${EXE_SUFFIX} bridge${EXE_SUFFIX} + ./bridge-gui${EXE_SUFFIX} + + clean-vendor: rm -rf ./vendor diff --git a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp index 9c8bfb4d..6314bcc8 100644 --- a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp +++ b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp @@ -874,12 +874,14 @@ void QMLBackend::onLoginAlreadyLoggedIn(QString const &userID) { //**************************************************************************************************************************************************** void QMLBackend::onUserBadEvent(QString const &userID, QString const &errorMessage) { HANDLE_EXCEPTION( - Q_UNUSED(errorMessage); SPUser const user = users_->getUserWithID(userID); if (!user) app().log().error(QString("Received bad event for unknown user %1").arg(user->id())); user->setState(UserState::SignedOut); - emit userBadEvent(tr("%1 was logged out because of an internal error.").arg(user->primaryEmailOrUsername())); + emit userBadEvent( + tr("Internal error: %1 was automatically logged out. Please log in again or report this problem if the issue persists.").arg(user->primaryEmailOrUsername()), + errorMessage + ); emit selectUser(userID); emit showMainWindow(); ) diff --git a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h index 05197abe..be39aab1 100644 --- a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h +++ b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h @@ -222,7 +222,7 @@ signals: // Signals received from the Go backend, to be forwarded to QML void addressChangedLogout(QString const &address); ///< Signal for the 'addressChangedLogout' gRPC stream event. void apiCertIssue(); ///< Signal for the 'apiCertIssue' gRPC stream event. void userDisconnected(QString const &username); ///< Signal for the 'userDisconnected' gRPC stream event. - void userBadEvent(QString const &message); ///< Signal for the 'userBadEvent' gRPC stream event. + void userBadEvent(QString const &description, QString const &errorMessage); ///< Signal for the 'userBadEvent' gRPC stream event. void internetOff(); ///< Signal for the 'internetOff' gRPC stream event. void internetOn(); ///< Signal for the 'internetOn' gRPC stream event. void resetFinished(); ///< Signal for the 'resetFinished' gRPC stream event. diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/BugReportView.qml b/internal/frontend/bridge-gui/bridge-gui/qml/BugReportView.qml index 8bc50b34..fc566eec 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/BugReportView.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/BugReportView.qml @@ -170,6 +170,10 @@ SettingsView { } } + function setDescription(message) { + description.text = message + } + function setDefaultValue() { description.text = "" address.text = root.selectedAddress diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/ContentWrapper.qml b/internal/frontend/bridge-gui/bridge-gui/qml/ContentWrapper.qml index 404addea..93b2e8f7 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/ContentWrapper.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/ContentWrapper.qml @@ -348,6 +348,7 @@ Item { } BugReportView { // 8 + id: bugReport colorScheme: root.colorScheme selectedAddress: { if (accounts.currentIndex < 0) return "" @@ -409,10 +410,14 @@ Item { } accounts.currentIndex = i; if (user.state === EUserState.SignedOut) - showSignIn(user.primaryEmailOrUsername()) + showSignIn(user.primaryEmailOrUsername()) return; } console.error("User with ID ", userID, " was not found in the account list") } + function showBugReportAndPrefill(description) { + rightContent.showBugReport() + bugReport.setDescription(description) + } } diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/MainWindow.qml b/internal/frontend/bridge-gui/bridge-gui/qml/MainWindow.qml index 4894f6be..2abb52b4 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/MainWindow.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/MainWindow.qml @@ -169,7 +169,6 @@ ApplicationWindow { root.showSetup(null,"") } } - } NotificationPopups { @@ -188,6 +187,10 @@ ApplicationWindow { function showHelp() { contentWrapper.showHelp() } function selectUser(userID) { contentWrapper.selectUser(userID) } + function showBugReportAndPrefill(message) { + contentWrapper.showBugReportAndPrefill(message) + } + function showSignIn(username) { if (contentLayout.currentIndex == 1) return contentWrapper.showSignIn(username) diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/NotificationPopups.qml b/internal/frontend/bridge-gui/bridge-gui/qml/NotificationPopups.qml index 84a178c1..5c65ddad 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/NotificationPopups.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/NotificationPopups.qml @@ -129,6 +129,11 @@ Item { notification: root.notifications.noActiveKeyForRecipient } + NotificationDialog { + colorScheme: root.colorScheme + notification: root.notifications.userBadEvent + } + NotificationDialog { colorScheme: root.colorScheme notification: root.notifications.genericError diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/Notifications/Notifications.qml b/internal/frontend/bridge-gui/bridge-gui/qml/Notifications/Notifications.qml index 23638a32..f7ac3d20 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/Notifications/Notifications.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/Notifications/Notifications.qml @@ -1046,8 +1046,8 @@ QtObject { property Notification apiCertIssue: Notification { title: qsTr("Unable to establish a \nsecure connection to \nProton servers") description: qsTr("Bridge cannot verify the authenticity of Proton servers on your current network due to a TLS certificate error. " + - "Start Bridge again after ensuring your connection is secure and/or connecting to a VPN. Learn more about TLS pinning " + - "here.") + "Start Bridge again after ensuring your connection is secure and/or connecting to a VPN. Learn more about TLS pinning " + + "here.") brief: title icon: "./icons/ic-exclamation-circle-filled.svg" @@ -1086,7 +1086,7 @@ QtObject { function onNoActiveKeyForRecipient(email) { root.noActiveKeyForRecipient.description = qsTr("There are no active keys to encrypt your message to %1. "+ - "Please update the setting for this contact.").arg(email) + "Please update the setting for this contact.").arg(email) root.noActiveKeyForRecipient.active = true } } @@ -1103,17 +1103,21 @@ QtObject { } property Notification userBadEvent: Notification { - title: qsTr("User was logged out") + title: qsTr("Your account was logged out") brief: title description: "#PlaceHolderText" icon: "./icons/ic-exclamation-circle-filled.svg" type: Notification.NotificationType.Danger - group: Notifications.Group.Connection + group: Notifications.Group.Connection | Notifications.Group.Dialogs + + property var bugReportMsg: "Reporting an issue:\n\n\"%1\"\n\nError: %2\n\nThe issue persists even after loggin back in." + property var errorMessage: "" Connections { target: Backend - function onUserBadEvent(message) { - root.userBadEvent.description = message + function onUserBadEvent(description, errorMessage) { + root.userBadEvent.description = description + root.userBadEvent.errorMessage = errorMessage root.userBadEvent.active = true } } @@ -1125,8 +1129,22 @@ QtObject { onTriggered: { root.userBadEvent.active = false } + }, + + Action { + text: qsTr("Report") + + onTriggered: { + root.frontendMain.showBugReportAndPrefill( + root.userBadEvent.bugReportMsg. + arg( root.userBadEvent.description). + arg(root.userBadEvent.errorMessage) + ) + root.userBadEvent.active = false + } } ] + } property Notification genericError: Notification { @@ -1135,14 +1153,14 @@ QtObject { icon: "./icons/ic-exclamation-circle-filled.svg" type: Notification.NotificationType.Danger group: Notifications.Group.Dialogs - Connections { - target: Backend - function onGenericError(title, description) { - root.genericError.title = title - root.genericError.description = description - root.genericError.active = true; - } + Connections { + target: Backend + function onGenericError(title, description) { + root.genericError.title = title + root.genericError.description = description + root.genericError.active = true; } + } action: [ Action {