feat(GODT-2786): Init bug report flow description file.
This commit is contained in:
parent
80add80be2
commit
cbbab71f5c
|
@ -89,6 +89,7 @@ void QMLBackend::init(GRPCConfig const &serviceConfig) {
|
|||
this->setUseSSLForIMAP(sslForIMAP);
|
||||
this->setUseSSLForSMTP(sslForSMTP);
|
||||
this->retrieveUserList();
|
||||
this->retrieveBugReportFlow();
|
||||
}
|
||||
|
||||
|
||||
|
@ -210,6 +211,42 @@ bool QMLBackend::areSameFileOrFolder(QUrl const &lhs, QUrl const &rhs) const {
|
|||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] categoryId The id of the bug category.
|
||||
/// \return Set of question for this category.
|
||||
//****************************************************************************************************************************************************
|
||||
QVariantList QMLBackend::getQuestionSet(quint8 categoryId) const {
|
||||
return questionsSet_[categoryId];
|
||||
};
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] questionId The id of the question.
|
||||
/// \param[in] answer The answer to that question.
|
||||
//****************************************************************************************************************************************************
|
||||
void QMLBackend::setQuestionAnswer(quint8 questionId, QString const &answer) {
|
||||
this->answers_[questionId] = answer;
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] categoryId The id of the question set.
|
||||
/// \return concatenate answers for set of questions.
|
||||
//****************************************************************************************************************************************************
|
||||
QString QMLBackend::collectAnswer(quint8 categoryId) const {
|
||||
QString answers;
|
||||
QVariantList sets = this->getQuestionSet(categoryId);
|
||||
foreach(const QVariant& var, sets) {
|
||||
answers += " - ";
|
||||
answers += questions_[var.toInt()].toMap()["text"].toString();
|
||||
answers += " ";
|
||||
answers += answers_[var.toInt()];
|
||||
answers += "\n\r";
|
||||
}
|
||||
return answers;
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value for the 'showOnStartup' property.
|
||||
//****************************************************************************************************************************************************
|
||||
|
@ -581,6 +618,21 @@ QStringList QMLBackend::availableKeychain() const {
|
|||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value for the 'bugCategories' property.
|
||||
//****************************************************************************************************************************************************
|
||||
QStringList QMLBackend::bugCategories() const {
|
||||
return categories_;
|
||||
}
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value for the 'bugQuestions' property.
|
||||
//****************************************************************************************************************************************************
|
||||
QVariantList QMLBackend::bugQuestions() const {
|
||||
return questions_;
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value for the 'currentKeychain' property.
|
||||
//****************************************************************************************************************************************************
|
||||
|
@ -1169,6 +1221,31 @@ void QMLBackend::retrieveUserList() {
|
|||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void QMLBackend::retrieveBugReportFlow() {
|
||||
categories_.clear();
|
||||
questions_.clear();
|
||||
questionsSet_.clear();
|
||||
QString val;
|
||||
QFile file;
|
||||
file.setFileName(":qml/Resources/bug_report_flow.json");
|
||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
val = file.readAll();
|
||||
file.close();
|
||||
QJsonDocument d = QJsonDocument::fromJson(val.toUtf8());
|
||||
QJsonObject root = d.object();
|
||||
QJsonObject data = root.value(QString("data_v1.0.0")).toObject();
|
||||
QJsonArray categoriesJson = data.value(QString("categories")).toArray();
|
||||
foreach (const QJsonValue & v, categoriesJson) {
|
||||
categories_.append(v.toObject()["name"].toString());
|
||||
questionsSet_.append(v.toObject()["questions"].toArray().toVariantList());
|
||||
}
|
||||
questions_ = data.value(QString("questions")).toArray().toVariantList();
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
|
|
|
@ -57,6 +57,9 @@ public: // member functions.
|
|||
Q_INVOKABLE bool isPortFree(int port) const; ///< Check if a given network port is available.
|
||||
Q_INVOKABLE QString nativePath(QUrl const &url) const; ///< Retrieve the native path of a local URL.
|
||||
Q_INVOKABLE bool areSameFileOrFolder(QUrl const &lhs, QUrl const &rhs) const; ///< Check if two local URL point to the same file.
|
||||
Q_INVOKABLE QVariantList getQuestionSet(quint8 categoryId) const; ///< Retrieve the set of question for a given bug category.
|
||||
Q_INVOKABLE void setQuestionAnswer(quint8 questionId, QString const &answer); ///< Feed an answer for a given question.
|
||||
Q_INVOKABLE QString collectAnswer(quint8 categoryId) const; ///< Collect answer for a given set of questions.
|
||||
|
||||
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)
|
||||
|
@ -87,6 +90,8 @@ public: // Qt/QML properties. Note that the NOTIFY-er signal is required even fo
|
|||
Q_PROPERTY(QString currentEmailClient READ currentEmailClient NOTIFY currentEmailClientChanged)
|
||||
Q_PROPERTY(QStringList availableKeychain READ availableKeychain NOTIFY availableKeychainChanged)
|
||||
Q_PROPERTY(QString currentKeychain READ currentKeychain NOTIFY currentKeychainChanged)
|
||||
Q_PROPERTY(QStringList bugCategories READ bugCategories NOTIFY bugCategoriesChanged)
|
||||
Q_PROPERTY(QVariantList bugQuestions READ bugQuestions NOTIFY bugQuestionsChanged)
|
||||
Q_PROPERTY(UserList *users MEMBER users_ NOTIFY usersChanged)
|
||||
Q_PROPERTY(bool dockIconVisible READ dockIconVisible WRITE setDockIconVisible NOTIFY dockIconVisibleChanged)
|
||||
|
||||
|
@ -124,6 +129,8 @@ public: // Qt/QML properties. Note that the NOTIFY-er signal is required even fo
|
|||
QString currentEmailClient() const; ///< Getter for the 'currentEmail' property.
|
||||
QStringList availableKeychain() const; ///< Getter for the 'availableKeychain' property.
|
||||
QString currentKeychain() const; ///< Getter for the 'currentKeychain' property.
|
||||
QStringList bugCategories() const; ///< Getter for the 'bugCategories' property.
|
||||
QVariantList bugQuestions() const; ///< Getter for the 'bugQuestions' property.
|
||||
void setDockIconVisible(bool visible); ///< Setter for the 'dockIconVisible' property.
|
||||
bool dockIconVisible() const;; ///< Getter for the 'dockIconVisible' property.
|
||||
|
||||
|
@ -153,6 +160,8 @@ signals: // Signal used by the Qt property system. Many of them are unused but r
|
|||
void tagChanged(QString const &tag); ///<Signal for the change of the 'tag' property.
|
||||
void currentEmailClientChanged(QString const &email); ///<Signal for the change of the 'currentEmailClient' property.
|
||||
void currentKeychainChanged(QString const &keychain); ///<Signal for the change of the 'currentKeychain' property.
|
||||
void bugCategoriesChanged(QStringList const &bugCategories); ///<Signal for the change of the 'bugCategories' property.
|
||||
void bugQuestionsChanged(QVariantList const &bugQuestions); ///<Signal for the change of the 'bugQuestions' property.
|
||||
void availableKeychainChanged(QStringList const &keychains); ///<Signal for the change of the 'availableKeychain' property.
|
||||
void hostnameChanged(QString const &hostname); ///<Signal for the change of the 'hostname' property.
|
||||
void isAutostartOnChanged(bool value); ///<Signal for the change of the 'isAutostartOn' property.
|
||||
|
@ -269,6 +278,7 @@ private: // member functions
|
|||
void retrieveUserList(); ///< Retrieve the list of users via gRPC.
|
||||
void connectGrpcEvents(); ///< Connect gRPC that need to be forwarded to QML via backend signals
|
||||
void displayBadEventDialog(QString const& userID); ///< Displays the bad event dialog for a user.
|
||||
void retrieveBugReportFlow(); ///< Get the bug report flow description file and parse it.
|
||||
|
||||
private: // data members
|
||||
UserList *users_ { nullptr }; ///< The user list. Owned by backend.
|
||||
|
@ -284,6 +294,10 @@ private: // data members
|
|||
bool isInternetOn_ { true }; ///< Does bridge consider internet as on?
|
||||
QList<QString> badEventDisplayQueue_; ///< THe queue for displaying 'bad event feedback request dialog'.
|
||||
std::unique_ptr<TrayIcon> trayIcon_; ///< The tray icon for the application.
|
||||
QStringList categories_; ///< The list of Bug Category parsed from the description file.
|
||||
QVariantList questions_; ///< The list of Questions parsed from the description file.
|
||||
QList<QVariantList> questionsSet_; ///< Sets of questions per bug category.
|
||||
QMap<quint8, QString> answers_; ///< Map of QuestionId/Answer for the bug form.
|
||||
friend class AppController;
|
||||
};
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@
|
|||
<file>qml/Proton/TextField.qml</file>
|
||||
<file>qml/Proton/Toggle.qml</file>
|
||||
<file>qml/QuestionItem.qml</file>
|
||||
<file>qml/Resources/bug_report_flow.json</file>
|
||||
<file>qml/SettingsItem.qml</file>
|
||||
<file>qml/SettingsView.qml</file>
|
||||
<file>qml/SetupGuide.qml</file>
|
||||
|
@ -109,4 +110,4 @@
|
|||
<file>qml/Status.qml</file>
|
||||
<file>qml/WelcomeGuide.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
</RCC>
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"metadata": {
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"data_v1.0.0": {
|
||||
"categories": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "I can't receive mail",
|
||||
"questions": [0,1,2,3,4,5]
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "I can't send mail",
|
||||
"questions": [0,1,2,3,4,5]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Bridge is not starting",
|
||||
"questions": [0,1,2,3,4,5]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Bridge is slow",
|
||||
"questions": [0,1,2,3,4,5]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "None of the above",
|
||||
"questions": [0,1,2,3,4,5]
|
||||
}
|
||||
],
|
||||
"questions": [
|
||||
{
|
||||
"id": 0,
|
||||
"text": "Expected behavior",
|
||||
"tips": "What did you expect to happen?",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"text": "Result",
|
||||
"tips": "What happened instead?",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"text": "Steps to reproduce",
|
||||
"tips": "What were the step-by-step actions you took that led to this happening?",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"text": "Can you reproduce your issue?",
|
||||
"type": 2,
|
||||
"answerList": ["yes", "no", "I don't know"]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"text": "Do you have such software running?",
|
||||
"type": 3,
|
||||
"answerList": ["VPN", "anti-virus", "firewall", "cache cleaner", "None of this"]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"text": "Do want to share something more?",
|
||||
"tips": "Type here...",
|
||||
"type": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue