Axivion: Reuse resolveDashboardInfoUrl()

Change-Id: Ic8627be0353e7a789cd569030da91bb46751c885
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Jarek Kobus
2024-11-22 19:12:01 +01:00
parent 754bb5847f
commit fe2fe1a60d
2 changed files with 13 additions and 15 deletions

View File

@@ -1074,18 +1074,17 @@ void AxivionPerspective::resetDashboard()
bool AxivionPerspective::handleContextMenu(const QString &issue, const ItemViewEvent &e) bool AxivionPerspective::handleContextMenu(const QString &issue, const ItemViewEvent &e)
{ {
std::optional<Dto::TableInfoDto> tableInfoOpt = m_issuesWidget->currentTableInfo(); if (!currentDashboardInfo())
return false;
const std::optional<Dto::TableInfoDto> tableInfoOpt = m_issuesWidget->currentTableInfo();
if (!tableInfoOpt) if (!tableInfoOpt)
return false; return false;
const QString baseUri = tableInfoOpt->issueBaseViewUri.value_or(QString()); const QString baseUri = tableInfoOpt->issueBaseViewUri.value_or(QString());
if (baseUri.isEmpty()) if (baseUri.isEmpty())
return false; return false;
auto info = currentDashboardInfo();
if (!info)
return false;
QUrl issueBaseUrl = info->source.resolved(baseUri).resolved(issue); QUrl dashboardUrl = resolveDashboardInfoUrl(baseUri);
QUrl dashboardUrl = info->source.resolved(baseUri); QUrl issueBaseUrl = dashboardUrl.resolved(issue);
const IssueListSearch search = m_issuesWidget->searchFromUi(); const IssueListSearch search = m_issuesWidget->searchFromUi();
issueBaseUrl.setQuery(search.toUrlQuery(QueryMode::SimpleQuery)); issueBaseUrl.setQuery(search.toUrlQuery(QueryMode::SimpleQuery));
dashboardUrl.setQuery(search.toUrlQuery(QueryMode::FilterQuery)); dashboardUrl.setQuery(search.toUrlQuery(QueryMode::FilterQuery));
@@ -1147,11 +1146,9 @@ void AxivionPerspective::updateToolbarButtons()
void AxivionPerspective::openFilterHelp() void AxivionPerspective::openFilterHelp()
{ {
std::optional<DashboardInfo> dashboardInfo = currentDashboardInfo(); const std::optional<Dto::ProjectInfoDto> projInfo = projectInfo();
QTC_ASSERT(dashboardInfo, return);
std::optional<Dto::ProjectInfoDto> projInfo = projectInfo();
if (projInfo && projInfo->issueFilterHelp) if (projInfo && projInfo->issueFilterHelp)
QDesktopServices::openUrl(dashboardInfo->source.resolved(*projInfo->issueFilterHelp)); QDesktopServices::openUrl(resolveDashboardInfoUrl(*projInfo->issueFilterHelp));
} }
static QPointer<AxivionPerspective> theAxivionPerspective; static QPointer<AxivionPerspective> theAxivionPerspective;

View File

@@ -364,7 +364,7 @@ static QUrl constructUrl(const QString &projectName, const QString &subPath, con
return {}; return {};
const QByteArray encodedProjectName = QUrl::toPercentEncoding(projectName); const QByteArray encodedProjectName = QUrl::toPercentEncoding(projectName);
const QUrl path(QString{"api/projects/" + QString::fromUtf8(encodedProjectName) + '/'}); const QUrl path(QString{"api/projects/" + QString::fromUtf8(encodedProjectName) + '/'});
QUrl url = dd->m_dashboardInfo->source.resolved(path); QUrl url = resolveDashboardInfoUrl(path);
if (!subPath.isEmpty() && QTC_GUARD(!subPath.startsWith('/'))) if (!subPath.isEmpty() && QTC_GUARD(!subPath.startsWith('/')))
url = url.resolved(subPath); url = url.resolved(subPath);
if (!query.isEmpty()) if (!query.isEmpty())
@@ -396,6 +396,8 @@ static QByteArray contentTypeData(ContentType contentType)
QUrl resolveDashboardInfoUrl(const QUrl &resource) QUrl resolveDashboardInfoUrl(const QUrl &resource)
{ {
QTC_ASSERT(dd, return {});
QTC_ASSERT(dd->m_dashboardInfo, return {});
return dd->m_dashboardInfo->source.resolved(resource); return dd->m_dashboardInfo->source.resolved(resource);
} }
@@ -649,8 +651,7 @@ static Group authorizationRecipe()
return SetupResult::StopWithError; return SetupResult::StopWithError;
apiTokenStorage->credential = dashboardStorage->credential; apiTokenStorage->credential = dashboardStorage->credential;
apiTokenStorage->url apiTokenStorage->url = resolveDashboardInfoUrl(*dashboardDto.userApiTokenUrl);
= dd->m_dashboardInfo->source.resolved(*dashboardDto.userApiTokenUrl);
apiTokenStorage->csrfToken = dashboardDto.csrfToken.toUtf8(); apiTokenStorage->csrfToken = dashboardDto.csrfToken.toUtf8();
const Dto::ApiTokenCreationRequestDto requestDto{*passwordStorage, "IdePlugin", const Dto::ApiTokenCreationRequestDto requestDto{*passwordStorage, "IdePlugin",
apiTokenDescription(), 0}; apiTokenDescription(), 0};
@@ -832,8 +833,8 @@ Group projectInfoRecipe(const QString &projectName)
auto it = dd->m_dashboardInfo->projectUrls.constFind(targetProjectName); auto it = dd->m_dashboardInfo->projectUrls.constFind(targetProjectName);
if (it == dd->m_dashboardInfo->projectUrls.constEnd()) if (it == dd->m_dashboardInfo->projectUrls.constEnd())
it = dd->m_dashboardInfo->projectUrls.constBegin(); it = dd->m_dashboardInfo->projectUrls.constBegin();
taskTree.setRecipe( taskTree.setRecipe(fetchDataRecipe<Dto::ProjectInfoDto>(resolveDashboardInfoUrl(*it),
fetchDataRecipe<Dto::ProjectInfoDto>(dd->m_dashboardInfo->source.resolved(*it), handler)); handler));
return SetupResult::Continue; return SetupResult::Continue;
}; };