From f8fbb1b5e152bf27efe2ea7ac9c8bdc2202c9cdc Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 11 Sep 2024 11:13:08 +0200 Subject: [PATCH] Axivion: Add projectInfoRecipe() Change-Id: I825ba27ed523654b81fd0b1b2b7d1e2acc6e4c11 Reviewed-by: Christian Stenger --- src/plugins/axivion/axivionplugin.cpp | 90 ++++++++++++++------------- src/plugins/axivion/axivionplugin.h | 2 + 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/src/plugins/axivion/axivionplugin.cpp b/src/plugins/axivion/axivionplugin.cpp index 5887a94cebf..125084fd7f0 100644 --- a/src/plugins/axivion/axivionplugin.cpp +++ b/src/plugins/axivion/axivionplugin.cpp @@ -818,6 +818,52 @@ Group dashboardInfoRecipe(const DashboardInfoHandler &handler) return root; } +Group projectInfoRecipe(const QString &projectName) +{ + const auto onSetup = [projectName] { + dd->clearAllMarks(); + dd->m_currentProjectInfo = {}; + dd->m_analysisVersion = {}; + if (!projectName.isEmpty()) + return SetupResult::Continue; + + updateDashboard(); + return SetupResult::StopWithSuccess; + }; + + const auto onTaskTreeSetup = [projectName](TaskTree &taskTree) { + if (!dd->m_dashboardInfo) { + MessageManager::writeDisrupting(QString("Axivion: %1") + .arg(Tr::tr("Fetching DashboardInfo error."))); + return SetupResult::StopWithError; + } + + const auto it = dd->m_dashboardInfo->projectUrls.constFind(projectName); + if (it == dd->m_dashboardInfo->projectUrls.constEnd()) { + MessageManager::writeDisrupting(QString("Axivion: %1") + .arg(Tr::tr("The DashboardInfo doesn't contain project \"%1\".").arg(projectName))); + return SetupResult::StopWithError; + } + + const auto handler = [](const Dto::ProjectInfoDto &data) { + dd->m_currentProjectInfo = data; + if (!dd->m_currentProjectInfo->versions.empty()) + setAnalysisVersion(dd->m_currentProjectInfo->versions.back().date); + updateDashboard(); + }; + + taskTree.setRecipe( + fetchDataRecipe(dd->m_dashboardInfo->source.resolved(*it), handler)); + return SetupResult::Continue; + }; + + return { + onGroupSetup(onSetup), + authorizationRecipe(), + TaskTreeTask(onTaskTreeSetup) + }; +} + Group issueTableRecipe(const IssueListSearch &search, const IssueTableHandler &handler) { QTC_ASSERT(dd->m_currentProjectInfo, return {}); // TODO: Call handler with unexpected? @@ -873,49 +919,7 @@ void AxivionPluginPrivate::fetchDashboardInfo(const DashboardInfoHandler &handle void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName) { - const auto onSetup = [this, projectName] { - clearAllMarks(); - m_currentProjectInfo = {}; - m_analysisVersion = {}; - if (!projectName.isEmpty()) - return SetupResult::Continue; - - updateDashboard(); - return SetupResult::StopWithSuccess; - }; - - const auto onTaskTreeSetup = [this, projectName](TaskTree &taskTree) { - if (!m_dashboardInfo) { - MessageManager::writeDisrupting(QString("Axivion: %1") - .arg(Tr::tr("Fetching DashboardInfo error."))); - return SetupResult::StopWithError; - } - - const auto it = m_dashboardInfo->projectUrls.constFind(projectName); - if (it == m_dashboardInfo->projectUrls.constEnd()) { - MessageManager::writeDisrupting(QString("Axivion: %1") - .arg(Tr::tr("The DashboardInfo doesn't contain project \"%1\".").arg(projectName))); - return SetupResult::StopWithError; - } - - const auto handler = [this](const Dto::ProjectInfoDto &data) { - m_currentProjectInfo = data; - if (!m_currentProjectInfo->versions.empty()) - setAnalysisVersion(m_currentProjectInfo->versions.back().date); - updateDashboard(); - }; - - taskTree.setRecipe( - fetchDataRecipe(m_dashboardInfo->source.resolved(*it), handler)); - return SetupResult::Continue; - }; - - const Group root { - onGroupSetup(onSetup), - authorizationRecipe(), - TaskTreeTask(onTaskTreeSetup) - }; - m_taskTreeRunner.start(root); + m_taskTreeRunner.start(projectInfoRecipe(projectName)); } Group tableInfoRecipe(const QString &prefix, const TableInfoHandler &handler) diff --git a/src/plugins/axivion/axivionplugin.h b/src/plugins/axivion/axivionplugin.h index 10535a3f2f0..ce1885f1435 100644 --- a/src/plugins/axivion/axivionplugin.h +++ b/src/plugins/axivion/axivionplugin.h @@ -63,6 +63,8 @@ public: using DashboardInfoHandler = std::function &)>; Tasking::Group dashboardInfoRecipe(const DashboardInfoHandler &handler = {}); +Tasking::Group projectInfoRecipe(const QString &projectName); + // TODO: Wrap into expected_str<>? using TableInfoHandler = std::function; Tasking::Group tableInfoRecipe(const QString &prefix, const TableInfoHandler &handler);