feat(GODT-3121): QML request suggestions.

This commit is contained in:
Xavier Michelon 2023-11-28 17:05:49 +01:00
parent 3070912416
commit 2e2648fcd5
16 changed files with 62 additions and 7 deletions

View File

@ -354,6 +354,23 @@ Status GRPCService::SetMainExecutable(ServerContext *, StringValue const *reques
return Status::OK;
}
//****************************************************************************************************************************************************
/// \param[in] request The request.
/// \return The status for the call.
//****************************************************************************************************************************************************
grpc::Status GRPCService::RequestKnowledgeBaseSuggestions(ServerContext*, StringValue const* request, Empty*) {
app().log().info(QString("RequestKnowledgeBaseSuggestions: %1").arg(QString::fromStdString(request->value()).left(10) + "..."));
QList<bridgepp::KnowledgeBaseSuggestion> suggestions(3);
for (qsizetype i = 0; i < 3; ++i) {
suggestions.push_back( {
.title = QString("Suggested link %1").arg(i),
.url = "https://proton.me/support/bridge"
});
}
qtProxy_.sendDelayedEvent(newKnowledgeBaseSuggestionsEvent(suggestions));
return Status::OK;
}
//****************************************************************************************************************************************************
/// \param[in] request The request

View File

@ -67,6 +67,7 @@ public: // member functions.
grpc::Status ReportBug(::grpc::ServerContext *, ::grpc::ReportBugRequest const *request, ::google::protobuf::Empty *) override;
grpc::Status ForceLauncher(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::google::protobuf::Empty *) override;
grpc::Status SetMainExecutable(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::google::protobuf::Empty *) override;
grpc::Status RequestKnowledgeBaseSuggestions(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::google::protobuf::Empty *) override;
grpc::Status Login(::grpc::ServerContext *, ::grpc::LoginRequest const *request, ::google::protobuf::Empty *) override;
grpc::Status Login2FA(::grpc::ServerContext *, ::grpc::LoginRequest const *request, ::google::protobuf::Empty *) override;
grpc::Status Login2Passwords(::grpc::ServerContext *, ::grpc::LoginRequest const *request, ::google::protobuf::Empty *) override;

View File

@ -303,6 +303,16 @@ void QMLBackend::openExternalLink(QString const &url) {
}
//****************************************************************************************************************************************************
//
//****************************************************************************************************************************************************
void QMLBackend::requestKnowledgeBaseSuggestions() const {
HANDLE_EXCEPTION(
app().grpc().requestKnowledgeBaseSuggestions("Test");
)
}
//****************************************************************************************************************************************************
/// \return The value for the 'showOnStartup' property.
//****************************************************************************************************************************************************

View File

@ -66,6 +66,7 @@ public: // member functions.
Q_INVOKABLE void clearAnswers(); ///< Clear all collected answers.
Q_INVOKABLE bool isTLSCertificateInstalled(); ///< Check if the bridge certificate is installed in the OS keychain.
Q_INVOKABLE void openExternalLink(QString const & url = QString()); ///< Open a knowledge base article.
Q_INVOKABLE void requestKnowledgeBaseSuggestions() const; ///< Request knowledgebase article suggestions.
public: // Qt/QML properties. Note that the NOTIFY-er signal is required even for read-only properties (QML warning otherwise)
Q_PROPERTY(bool showOnStartup READ showOnStartup NOTIFY showOnStartupChanged)

View File

@ -5,11 +5,6 @@
<file>qml/AccountView.qml</file>
<file>qml/Banner.qml</file>
<file>qml/Bridge.qml</file>
<file>qml/BugCategoryView.qml</file>
<file>qml/BugQuestionView.qml</file>
<file>qml/BugReportFlow.qml</file>
<file>qml/BugReportView.qml</file>
<file>qml/CategoryItem.qml</file>
<file>qml/Configuration.qml</file>
<file>qml/ConfigurationItem.qml</file>
<file>qml/ContentWrapper.qml</file>
@ -89,6 +84,11 @@
<file>qml/Notifications/Notifications.qml</file>
<file>qml/Notifications/qmldir</file>
<file>qml/PortSettings.qml</file>
<file>qml/BugReport/BugCategoryView.qml</file>
<file>qml/BugReport/BugQuestionView.qml</file>
<file>qml/BugReport/BugReportFlow.qml</file>
<file>qml/BugReport/BugReportView.qml</file>
<file>qml/BugReport/CategoryItem.qml</file>
<file>qml/Proton/Action.qml</file>
<file>qml/Proton/ApplicationWindow.qml</file>
<file>qml/Proton/Button.qml</file>

View File

@ -14,6 +14,7 @@ import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Proton
import ".."
SettingsView {
id: root

View File

@ -14,6 +14,7 @@ import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Proton
import ".."
SettingsView {
id: root

View File

@ -15,6 +15,7 @@ import QtQuick.Layouts
import QtQuick.Controls
import Proton
import Notifications
import ".."
Item {
id: root
@ -77,6 +78,7 @@ Item {
root.showBugCategory();
}
onQuestionAnswered: {
Backend.requestKnowledgeBaseSuggestions();
root.showBugReport();
}
}

View File

@ -14,6 +14,7 @@ import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Proton
import ".."
SettingsView {
id: root

View File

@ -14,6 +14,7 @@ import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Proton
import ".."
Item {
id: root

View File

@ -15,6 +15,7 @@ import QtQuick.Layouts
import QtQuick.Controls
import Proton
import Notifications
import "BugReport"
Item {
id: root

View File

@ -18,6 +18,7 @@ import QtQuick.Controls
import Proton
import Notifications
import "SetupWizard"
import "BugReport"
ApplicationWindow {
id: root

View File

@ -247,6 +247,22 @@ SPStreamEvent newCertificateInstallFailedEvent() {
}
//****************************************************************************************************************************************************
/// \param[in] suggestions the suggestions
/// \return The event.
//****************************************************************************************************************************************************
SPStreamEvent newKnowledgeBaseSuggestionsEvent(QList<KnowledgeBaseSuggestion> const& suggestions) {
auto event = new grpc::KnowledgeBaseSuggestionsEvent;
for (KnowledgeBaseSuggestion const &suggestion: suggestions) {
grpc::KnowledgeBaseSuggestion *s = event->add_suggestions();
s->set_url(suggestion.url.toStdString());
s->set_title(suggestion.title.toStdString());
}
auto appEvent = new grpc::AppEvent;
appEvent->set_allocated_knowledgebasesuggestions(event);
return wrapAppEvent(appEvent);
}
//****************************************************************************************************************************************************
/// \return The event.
//****************************************************************************************************************************************************

View File

@ -22,6 +22,7 @@
#include "bridge.grpc.pb.h"
#include "GRPCUtils.h"
#include <bridgepp/GRPC/GRPCClient.h>
namespace bridgepp {
@ -39,6 +40,7 @@ SPStreamEvent newCertificateInstallSuccessEvent(); ///< Create a new Certificate
SPStreamEvent newCertificateInstallCanceledEvent(); ///< Create a new CertificateInstallCanceledEvent event.
SPStreamEvent newCertificateInstallFailedEvent(); ///< Create anew CertificateInstallFailedEvent event.
SPStreamEvent newShowMainWindowEvent(); ///< Create a new ShowMainWindowEvent event.
SPStreamEvent newKnowledgeBaseSuggestionsEvent(QList<KnowledgeBaseSuggestion> const& suggestions); ///< Create a new KnowledgeBaseSuggestions event.
// Login events
SPStreamEvent newLoginError(grpc::LoginErrorType error, QString const &message); ///< Create a new LoginError event.

View File

@ -571,7 +571,7 @@ grpc::Status GRPCClient::hostname(QString &outHostname) {
//****************************************************************************************************************************************************
/// \param[in] input The user input to analyze.
//****************************************************************************************************************************************************
grpc::Status GRPCClient::RequestKnowledgeBaseSuggestions(QString const &input) {
grpc::Status GRPCClient::requestKnowledgeBaseSuggestions(QString const &input) {
return this->logGRPCCallStatus(this->setString(&Bridge::Stub::RequestKnowledgeBaseSuggestions, input), __FUNCTION__);
}

View File

@ -102,7 +102,7 @@ public: // member functions.
grpc::Status releaseNotesPageLink(QUrl &outUrl); ///< Performs the 'releaseNotesPageLink' call.
grpc::Status landingPageLink(QUrl &outUrl); ///< Performs the 'landingPageLink' call.
grpc::Status hostname(QString &outHostname); ///< Performs the 'Hostname' call.
grpc::Status RequestKnowledgeBaseSuggestions(QString const &input); ///< Performs the 'RequestKnowledgeBaseSuggestions' call.
grpc::Status requestKnowledgeBaseSuggestions(QString const &input); ///< Performs the 'RequestKnowledgeBaseSuggestions' call.
signals: // app related signals
void internetStatus(bool isOn);