diff options
author | Viktor Vorona <viktor.vorona@sonarsource.com> | 2024-04-23 11:39:08 +0200 |
---|---|---|
committer | Matteo Mara <matteo.mara@sonarsource.com> | 2024-04-30 10:59:03 +0200 |
commit | 5c472713af0075201739c2e50663eefa01464fd6 (patch) | |
tree | dfef7ae740f744137c97e952906dbe96c8e6f0a7 /server/sonar-web/src/main | |
parent | b1926c0127b9765afd449c90f415027a4341caad (diff) | |
download | sonarqube-5c472713af0075201739c2e50663eefa01464fd6.tar.gz sonarqube-5c472713af0075201739c2e50663eefa01464fd6.zip |
SONAR-22049 Align throwGlobalError
Diffstat (limited to 'server/sonar-web/src/main')
50 files changed, 72 insertions, 55 deletions
diff --git a/server/sonar-web/src/main/js/api/alm-integrations.ts b/server/sonar-web/src/main/js/api/alm-integrations.ts index f7f6d92b086..a2a350eb073 100644 --- a/server/sonar-web/src/main/js/api/alm-integrations.ts +++ b/server/sonar-web/src/main/js/api/alm-integrations.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { get, getJSON, parseError, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { AzureProject, AzureRepository, diff --git a/server/sonar-web/src/main/js/api/alm-settings.ts b/server/sonar-web/src/main/js/api/alm-settings.ts index 9ec83e5fa2c..b32bb24d263 100644 --- a/server/sonar-web/src/main/js/api/alm-settings.ts +++ b/server/sonar-web/src/main/js/api/alm-settings.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { get, getJSON, HttpStatus, parseError, parseJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { AlmSettingsBindingDefinitions, AlmSettingsInstance, diff --git a/server/sonar-web/src/main/js/api/application.ts b/server/sonar-web/src/main/js/api/application.ts index 735195d97a7..9735e83ba08 100644 --- a/server/sonar-web/src/main/js/api/application.ts +++ b/server/sonar-web/src/main/js/api/application.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { Application, ApplicationPeriod } from '../types/application'; import { Visibility } from '../types/component'; diff --git a/server/sonar-web/src/main/js/api/branches.ts b/server/sonar-web/src/main/js/api/branches.ts index 99751048b73..a7884879428 100644 --- a/server/sonar-web/src/main/js/api/branches.ts +++ b/server/sonar-web/src/main/js/api/branches.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { Branch, PullRequest } from '../types/branch-like'; export function getBranches(project: string): Promise<Branch[]> { diff --git a/server/sonar-web/src/main/js/api/ce.ts b/server/sonar-web/src/main/js/api/ce.ts index 3760a5f3297..2a292c47aff 100644 --- a/server/sonar-web/src/main/js/api/ce.ts +++ b/server/sonar-web/src/main/js/api/ce.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { IndexationStatus } from '../types/indexation'; import { ActivityRequestParameters, Task, TaskWarning } from '../types/tasks'; import { Paging } from '../types/types'; diff --git a/server/sonar-web/src/main/js/api/component-report.ts b/server/sonar-web/src/main/js/api/component-report.ts index cc68b471a29..f54941ebdfd 100644 --- a/server/sonar-web/src/main/js/api/component-report.ts +++ b/server/sonar-web/src/main/js/api/component-report.ts @@ -17,9 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; import { getBaseUrl } from '../helpers/system'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { ComponentReportStatus } from '../types/component-report'; export function getReportStatus( diff --git a/server/sonar-web/src/main/js/api/components.ts b/server/sonar-web/src/main/js/api/components.ts index cc8eee3bb1c..b6f020aa7f7 100644 --- a/server/sonar-web/src/main/js/api/components.ts +++ b/server/sonar-web/src/main/js/api/components.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, RequestData } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { BranchParameters } from '../types/branch-like'; import { ComponentQualifier, diff --git a/server/sonar-web/src/main/js/api/editions.ts b/server/sonar-web/src/main/js/api/editions.ts index 5e144fa56a8..5d3d8c20444 100644 --- a/server/sonar-web/src/main/js/api/editions.ts +++ b/server/sonar-web/src/main/js/api/editions.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { License } from '../types/editions'; export function isValidLicense(): Promise<{ isValidLicense: boolean }> { diff --git a/server/sonar-web/src/main/js/api/github-provisioning.ts b/server/sonar-web/src/main/js/api/github-provisioning.ts index f650d9d729f..2e932886a8f 100644 --- a/server/sonar-web/src/main/js/api/github-provisioning.ts +++ b/server/sonar-web/src/main/js/api/github-provisioning.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import axios from 'axios'; -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { GitHubConfigurationStatus, GitHubMapping, GithubStatus } from '../types/provisioning'; const GITHUB_PERMISSION_MAPPINGS = '/api/v2/dop-translation/github-permission-mappings'; diff --git a/server/sonar-web/src/main/js/api/issues.ts b/server/sonar-web/src/main/js/api/issues.ts index 3036d4983b9..a87ad9ad1f5 100644 --- a/server/sonar-web/src/main/js/api/issues.ts +++ b/server/sonar-web/src/main/js/api/issues.ts @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import getCoverageStatus from '../components/SourceViewer/helpers/getCoverageStatus'; -import { throwGlobalError } from '../helpers/error'; import { get, getJSON, @@ -28,6 +27,7 @@ import { postJSON, RequestData, } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { FacetName, IssueResponse, ListIssuesResponse, RawIssuesResponse } from '../types/issues'; import { Dict, FacetValue, IssueChangelog, SnippetsByComponent, SourceLine } from '../types/types'; diff --git a/server/sonar-web/src/main/js/api/languages.ts b/server/sonar-web/src/main/js/api/languages.ts index 4ed807bece8..3c9f6c907c2 100644 --- a/server/sonar-web/src/main/js/api/languages.ts +++ b/server/sonar-web/src/main/js/api/languages.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { Language } from '../types/languages'; export function getLanguages(): Promise<Language[]> { diff --git a/server/sonar-web/src/main/js/api/measures.ts b/server/sonar-web/src/main/js/api/measures.ts index d1a15e79808..a2bb0470f23 100644 --- a/server/sonar-web/src/main/js/api/measures.ts +++ b/server/sonar-web/src/main/js/api/measures.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { BranchParameters } from '../types/branch-like'; import { MeasuresAndMetaWithMetrics, diff --git a/server/sonar-web/src/main/js/api/messages.ts b/server/sonar-web/src/main/js/api/messages.ts index 5c1672cfd41..1d03f17b8c0 100644 --- a/server/sonar-web/src/main/js/api/messages.ts +++ b/server/sonar-web/src/main/js/api/messages.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; export enum MessageTypes { GlobalNcd90 = 'GLOBAL_NCD_90', diff --git a/server/sonar-web/src/main/js/api/metrics.ts b/server/sonar-web/src/main/js/api/metrics.ts index bbce57c3f9a..09b966092c0 100644 --- a/server/sonar-web/src/main/js/api/metrics.ts +++ b/server/sonar-web/src/main/js/api/metrics.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { Metric } from '../types/types'; export interface MetricsResponse { diff --git a/server/sonar-web/src/main/js/api/navigation.ts b/server/sonar-web/src/main/js/api/navigation.ts index 96a3ee4485a..e41f88ec6c3 100644 --- a/server/sonar-web/src/main/js/api/navigation.ts +++ b/server/sonar-web/src/main/js/api/navigation.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { AppState } from '../types/appstate'; import { BranchParameters } from '../types/branch-like'; import { Extension, NavigationComponent } from '../types/types'; diff --git a/server/sonar-web/src/main/js/api/newCodeDefinition.ts b/server/sonar-web/src/main/js/api/newCodeDefinition.ts index 59adbda17dd..cf81abd3a2f 100644 --- a/server/sonar-web/src/main/js/api/newCodeDefinition.ts +++ b/server/sonar-web/src/main/js/api/newCodeDefinition.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { NewCodeDefinition, NewCodeDefinitionBranch, diff --git a/server/sonar-web/src/main/js/api/notifications.ts b/server/sonar-web/src/main/js/api/notifications.ts index 9d517587c00..bd0310dd9d8 100644 --- a/server/sonar-web/src/main/js/api/notifications.ts +++ b/server/sonar-web/src/main/js/api/notifications.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { AddRemoveNotificationParameters, NotificationsResponse } from '../types/notifications'; export function getNotifications(): Promise<NotificationsResponse> { diff --git a/server/sonar-web/src/main/js/api/permissions.ts b/server/sonar-web/src/main/js/api/permissions.ts index 142f2a46eb4..73e5c9be020 100644 --- a/server/sonar-web/src/main/js/api/permissions.ts +++ b/server/sonar-web/src/main/js/api/permissions.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON, RequestData } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { Visibility } from '../types/component'; import { Paging, diff --git a/server/sonar-web/src/main/js/api/plugins.ts b/server/sonar-web/src/main/js/api/plugins.ts index 767df180b4d..3531f8351f2 100644 --- a/server/sonar-web/src/main/js/api/plugins.ts +++ b/server/sonar-web/src/main/js/api/plugins.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { AvailablePlugin, InstalledPlugin, diff --git a/server/sonar-web/src/main/js/api/project-badges.ts b/server/sonar-web/src/main/js/api/project-badges.ts index deb5b2a2c5d..db811882fee 100644 --- a/server/sonar-web/src/main/js/api/project-badges.ts +++ b/server/sonar-web/src/main/js/api/project-badges.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; export function getProjectBadgesToken(project: string) { return getJSON('/api/project_badges/token', { project }) diff --git a/server/sonar-web/src/main/js/api/project-dump.ts b/server/sonar-web/src/main/js/api/project-dump.ts index e45dda92370..ed939039704 100644 --- a/server/sonar-web/src/main/js/api/project-dump.ts +++ b/server/sonar-web/src/main/js/api/project-dump.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { DumpStatus } from '../types/project-dump'; export function getStatus(componentKey: string): Promise<DumpStatus> { diff --git a/server/sonar-web/src/main/js/api/project-management.ts b/server/sonar-web/src/main/js/api/project-management.ts index f684e4b3750..65a162691d2 100644 --- a/server/sonar-web/src/main/js/api/project-management.ts +++ b/server/sonar-web/src/main/js/api/project-management.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { ComponentQualifier, Visibility } from '../types/component'; import { Paging } from '../types/types'; diff --git a/server/sonar-web/src/main/js/api/projectActivity.ts b/server/sonar-web/src/main/js/api/projectActivity.ts index f9c1a1f7d63..7a28e2499ca 100644 --- a/server/sonar-web/src/main/js/api/projectActivity.ts +++ b/server/sonar-web/src/main/js/api/projectActivity.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { BranchParameters } from '../types/branch-like'; import { Analysis, diff --git a/server/sonar-web/src/main/js/api/projectLinks.ts b/server/sonar-web/src/main/js/api/projectLinks.ts index dfd87f2aa5c..c8ca2d71960 100644 --- a/server/sonar-web/src/main/js/api/projectLinks.ts +++ b/server/sonar-web/src/main/js/api/projectLinks.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { ProjectLink } from '../types/types'; export function getProjectLinks(projectKey: string): Promise<ProjectLink[]> { diff --git a/server/sonar-web/src/main/js/api/quality-gates.ts b/server/sonar-web/src/main/js/api/quality-gates.ts index 25006b0464b..d35bd99116d 100644 --- a/server/sonar-web/src/main/js/api/quality-gates.ts +++ b/server/sonar-web/src/main/js/api/quality-gates.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { BranchParameters } from '../types/branch-like'; import { AddDeleteGroupPermissionsParameters, diff --git a/server/sonar-web/src/main/js/api/quality-profiles.ts b/server/sonar-web/src/main/js/api/quality-profiles.ts index b7a0d093ebf..6ab0d03048b 100644 --- a/server/sonar-web/src/main/js/api/quality-profiles.ts +++ b/server/sonar-web/src/main/js/api/quality-profiles.ts @@ -20,8 +20,8 @@ import { map } from 'lodash'; import { Exporter, ProfileChangelogEvent } from '../apps/quality-profiles/types'; import { csvEscape } from '../helpers/csv'; -import { throwGlobalError } from '../helpers/error'; import { RequestData, getJSON, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { CleanCodeAttributeCategory, SoftwareImpact } from '../types/clean-code-taxonomy'; import { Dict, Paging, ProfileInheritanceDetails, UserSelected } from '../types/types'; diff --git a/server/sonar-web/src/main/js/api/rules.ts b/server/sonar-web/src/main/js/api/rules.ts index 8ebba8c5578..9c7588ea5e8 100644 --- a/server/sonar-web/src/main/js/api/rules.ts +++ b/server/sonar-web/src/main/js/api/rules.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { HttpStatusCode } from 'axios'; -import { throwGlobalError } from '../helpers/error'; import { axiosToCatch, getJSON, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { CleanCodeAttribute, SoftwareImpact } from '../types/clean-code-taxonomy'; import { GetRulesAppResponse, SearchRulesResponse } from '../types/coding-rules'; import { SearchRulesQuery } from '../types/rules'; diff --git a/server/sonar-web/src/main/js/api/scim-provisioning.ts b/server/sonar-web/src/main/js/api/scim-provisioning.ts index eb21b34a062..abbc75667f0 100644 --- a/server/sonar-web/src/main/js/api/scim-provisioning.ts +++ b/server/sonar-web/src/main/js/api/scim-provisioning.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; export function fetchIsScimEnabled(): Promise<boolean> { return getJSON('/api/scim_management/status') diff --git a/server/sonar-web/src/main/js/api/security-hotspots.ts b/server/sonar-web/src/main/js/api/security-hotspots.ts index 044bcfc3572..813a3f756cc 100644 --- a/server/sonar-web/src/main/js/api/security-hotspots.ts +++ b/server/sonar-web/src/main/js/api/security-hotspots.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { BranchParameters } from '../types/branch-like'; import { Hotspot, diff --git a/server/sonar-web/src/main/js/api/settings.ts b/server/sonar-web/src/main/js/api/settings.ts index 21063ea2c93..3a092ee708c 100644 --- a/server/sonar-web/src/main/js/api/settings.ts +++ b/server/sonar-web/src/main/js/api/settings.ts @@ -19,8 +19,8 @@ */ import { omitBy } from 'lodash'; import { isCategoryDefinition } from '../apps/settings/utils'; -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON, RequestData } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { BranchParameters } from '../types/branch-like'; import { ExtendedSettingDefinition, diff --git a/server/sonar-web/src/main/js/api/system.ts b/server/sonar-web/src/main/js/api/system.ts index 50bc95278d6..5ad15dab742 100644 --- a/server/sonar-web/src/main/js/api/system.ts +++ b/server/sonar-web/src/main/js/api/system.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON, requestTryAndRepeatUntil } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { SystemUpgrade } from '../types/system'; import { SysInfoCluster, SysInfoStandalone, SysStatus } from '../types/types'; diff --git a/server/sonar-web/src/main/js/api/time-machine.ts b/server/sonar-web/src/main/js/api/time-machine.ts index 746f8b9e56c..6f88f067b24 100644 --- a/server/sonar-web/src/main/js/api/time-machine.ts +++ b/server/sonar-web/src/main/js/api/time-machine.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { BranchParameters } from '../types/branch-like'; import { MetricKey } from '../types/metrics'; import { Paging } from '../types/types'; diff --git a/server/sonar-web/src/main/js/api/user-tokens.ts b/server/sonar-web/src/main/js/api/user-tokens.ts index a1d2a267911..bc2080a6b76 100644 --- a/server/sonar-web/src/main/js/api/user-tokens.ts +++ b/server/sonar-web/src/main/js/api/user-tokens.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { NewUserToken, UserToken } from '../types/token'; /** List tokens for given user login */ diff --git a/server/sonar-web/src/main/js/api/users.ts b/server/sonar-web/src/main/js/api/users.ts index b4c75e57bf7..aff47526174 100644 --- a/server/sonar-web/src/main/js/api/users.ts +++ b/server/sonar-web/src/main/js/api/users.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import axios from 'axios'; -import { throwGlobalError } from '../helpers/error'; import { HttpStatus, axiosToCatch, getJSON, parseJSON, post } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { IdentityProvider, Paging } from '../types/types'; import { ChangePasswordResults, diff --git a/server/sonar-web/src/main/js/api/web-api.ts b/server/sonar-web/src/main/js/api/web-api.ts index 2d13632767c..89d1fdeedb1 100644 --- a/server/sonar-web/src/main/js/api/web-api.ts +++ b/server/sonar-web/src/main/js/api/web-api.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { OpenAPIV3 } from 'openapi-types'; -import { throwGlobalError } from '../helpers/error'; import { getJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { WebApi } from '../types/types'; interface RawDomain { diff --git a/server/sonar-web/src/main/js/api/webhooks.ts b/server/sonar-web/src/main/js/api/webhooks.ts index 784b1578cbf..52c616f5fc0 100644 --- a/server/sonar-web/src/main/js/api/webhooks.ts +++ b/server/sonar-web/src/main/js/api/webhooks.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../helpers/error'; import { getJSON, post, postJSON } from '../helpers/request'; +import { throwGlobalError } from '../sonar-aligned/helpers/error'; import { Paging } from '../types/types'; import { WebhookCreatePayload, diff --git a/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts b/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts index 366ab15e7d0..6d044b37041 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts +++ b/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts @@ -19,7 +19,6 @@ */ import { addGlobalSuccessMessage } from 'design-system'; -import { throwGlobalError } from '../../../helpers/error'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { get, @@ -32,6 +31,7 @@ import { postJSONBody, request, } from '../../../helpers/request'; +import { throwGlobalError } from '../../../sonar-aligned/helpers/error'; const exposeLibraries = () => { const global = window as any; diff --git a/server/sonar-web/src/main/js/apps/create/project/monorepo/MonorepoProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/monorepo/MonorepoProjectCreate.tsx index 4ab2ec6e2b8..fa1b4687773 100644 --- a/server/sonar-web/src/main/js/apps/create/project/monorepo/MonorepoProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/monorepo/MonorepoProjectCreate.tsx @@ -24,9 +24,9 @@ import { FormattedMessage } from 'react-intl'; import { GroupBase } from 'react-select'; import { getComponents } from '../../../../api/project-management'; import { useLocation, useRouter } from '../../../../components/hoc/withRouter'; -import { throwGlobalError } from '../../../../helpers/error'; import { LabelValueSelectOption } from '../../../../helpers/search'; import { useProjectBindingsQuery } from '../../../../queries/dop-translation'; +import { throwGlobalError } from '../../../../sonar-aligned/helpers/error'; import { AlmKeys } from '../../../../types/alm-settings'; import { DopSetting } from '../../../../types/dop-translation'; import { ImportProjectParam } from '../CreateProjectPage'; diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx index 4102f8cf9cc..6df91a24fa6 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx @@ -36,9 +36,9 @@ import { SingleValue } from 'react-select'; import { bulkChangeIssues, searchIssueTags } from '../../../api/issues'; import FormattingTips from '../../../components/common/FormattingTips'; import { isTransitionHidden, transitionRequiresComment } from '../../../components/issue/helpers'; -import { throwGlobalError } from '../../../helpers/error'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { withBranchStatusRefresh } from '../../../queries/branch'; +import { throwGlobalError } from '../../../sonar-aligned/helpers/error'; import { IssueTransition } from '../../../types/issues'; import { Issue, Paging } from '../../../types/types'; import AssigneeSelect from './AssigneeSelect'; diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx index d8cd4a408f1..3e44f7a4be5 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx @@ -37,9 +37,9 @@ import { } from '../../../components/SourceViewer/helpers/indexing'; import { WorkspaceContext } from '../../../components/workspace/context'; import { getBranchLikeQuery } from '../../../helpers/branch-like'; -import { throwGlobalError } from '../../../helpers/error'; import { translate } from '../../../helpers/l10n'; import { HttpStatus } from '../../../helpers/request'; +import { throwGlobalError } from '../../../sonar-aligned/helpers/error'; import { BranchLike } from '../../../types/branch-like'; import { isFile } from '../../../types/component'; import { IssueDeprecatedStatus } from '../../../types/issues'; diff --git a/server/sonar-web/src/main/js/apps/marketplace/utils.ts b/server/sonar-web/src/main/js/apps/marketplace/utils.ts index fd1e14059d8..5570167ab45 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/utils.ts +++ b/server/sonar-web/src/main/js/apps/marketplace/utils.ts @@ -19,9 +19,9 @@ */ import { findLastIndex, memoize } from 'lodash'; import { getInstalledPlugins, getUpdatesPlugins } from '../../api/plugins'; -import { throwGlobalError } from '../../helpers/error'; import { cleanQuery, parseAsString, serializeString } from '../../helpers/query'; import { isDefined } from '../../helpers/types'; +import { throwGlobalError } from '../../sonar-aligned/helpers/error'; import { InstalledPlugin, Plugin, Update } from '../../types/plugins'; import { RawQuery } from '../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/Header.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/Header.tsx index 154fa40466b..603ef9fbd44 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/Header.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/Header.tsx @@ -21,9 +21,9 @@ import { ButtonPrimary, FlagMessage, Spinner, Title } from 'design-system'; import React, { useState } from 'react'; import { createPermissionTemplate } from '../../../api/permissions'; import { Router, withRouter } from '../../../components/hoc/withRouter'; -import { throwGlobalError } from '../../../helpers/error'; import { translate } from '../../../helpers/l10n'; import { useGithubProvisioningEnabledQuery } from '../../../queries/identity-provider/github'; +import { throwGlobalError } from '../../../sonar-aligned/helpers/error'; import { PERMISSION_TEMPLATES_PATH } from '../utils'; import Form from './Form'; diff --git a/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx b/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx index c29f06ff088..fedbd54ef0e 100644 --- a/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx @@ -32,8 +32,8 @@ import withAvailableFeatures, { WithAvailableFeaturesProps, } from '../../app/components/available-features/withAvailableFeatures'; import withComponentContext from '../../app/components/componentContext/withComponentContext'; -import { throwGlobalError } from '../../helpers/error'; import { translate } from '../../helpers/l10n'; +import { throwGlobalError } from '../../sonar-aligned/helpers/error'; import { Feature } from '../../types/features'; import { DumpStatus, DumpTask } from '../../types/project-dump'; import { ActivityRequestParameters, TaskStatuses, TaskTypes } from '../../types/tasks'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/ApplicationCreation.tsx b/server/sonar-web/src/main/js/apps/projects/components/ApplicationCreation.tsx index 48a03357029..0c75e64d555 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ApplicationCreation.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ApplicationCreation.tsx @@ -24,10 +24,10 @@ import withAppStateContext from '../../../app/components/app-state/withAppStateC import withCurrentUserContext from '../../../app/components/current-user/withCurrentUserContext'; import CreateApplicationForm from '../../../app/components/extensions/CreateApplicationForm'; import { Router, withRouter } from '../../../components/hoc/withRouter'; -import { throwGlobalError } from '../../../helpers/error'; import { translate } from '../../../helpers/l10n'; import { getComponentAdminUrl, getComponentOverviewUrl } from '../../../helpers/urls'; import { hasGlobalPermission } from '../../../helpers/users'; +import { throwGlobalError } from '../../../sonar-aligned/helpers/error'; import { AppState } from '../../../types/appstate'; import { ComponentQualifier } from '../../../types/component'; import { Permissions } from '../../../types/permissions'; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectManagementApp.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectManagementApp.tsx index 94e0c495c6b..5500ba6eada 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectManagementApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectManagementApp.tsx @@ -31,9 +31,9 @@ import withCurrentUserContext from '../../app/components/current-user/withCurren import ListFooter from '../../components/controls/ListFooter'; import Suggestions from '../../components/embed-docs-modal/Suggestions'; import { toShortISO8601String } from '../../helpers/dates'; -import { throwGlobalError } from '../../helpers/error'; import { translate } from '../../helpers/l10n'; import { hasGlobalPermission } from '../../helpers/users'; +import { throwGlobalError } from '../../sonar-aligned/helpers/error'; import { Visibility } from '../../types/component'; import { Permissions } from '../../types/permissions'; import { SettingsKey } from '../../types/settings'; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx index aedbd1db09a..6052dafce1b 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx @@ -21,10 +21,10 @@ import { ActionsDropdown, ItemButton, ItemLink, PopupZLevel, Spinner } from 'des import React, { useState } from 'react'; import { getComponentNavigation } from '../../api/navigation'; import { Project } from '../../api/project-management'; -import { throwGlobalError } from '../../helpers/error'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { getComponentPermissionsUrl } from '../../helpers/urls'; import { useGithubProvisioningEnabledQuery } from '../../queries/identity-provider/github'; +import { throwGlobalError } from '../../sonar-aligned/helpers/error'; import { LoggedInUser } from '../../types/users'; import ApplyTemplate from '../permissions/project/components/ApplyTemplate'; import RestoreAccessModal from './RestoreAccessModal'; diff --git a/server/sonar-web/src/main/js/components/issue/__tests__/actions-test.ts b/server/sonar-web/src/main/js/components/issue/__tests__/actions-test.ts index 1b6ecbb6b17..1df47ac4ff2 100644 --- a/server/sonar-web/src/main/js/components/issue/__tests__/actions-test.ts +++ b/server/sonar-web/src/main/js/components/issue/__tests__/actions-test.ts @@ -17,13 +17,13 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../../../helpers/error'; import { parseIssueFromResponse } from '../../../helpers/issues'; import { mockComponent } from '../../../helpers/mocks/component'; import { mockIssue } from '../../../helpers/testMocks'; +import { throwGlobalError } from '../../../sonar-aligned/helpers/error'; import { updateIssue } from '../actions'; -jest.mock('../../../helpers/error', () => ({ throwGlobalError: jest.fn() })); +jest.mock('../../../sonar-aligned/helpers/error', () => ({ throwGlobalError: jest.fn() })); jest.mock('../../../helpers/issues', () => ({ parseIssueFromResponse: jest.fn(), diff --git a/server/sonar-web/src/main/js/components/issue/actions.ts b/server/sonar-web/src/main/js/components/issue/actions.ts index 84c75a2e15b..1d8c078b2ce 100644 --- a/server/sonar-web/src/main/js/components/issue/actions.ts +++ b/server/sonar-web/src/main/js/components/issue/actions.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { throwGlobalError } from '../../helpers/error'; import { parseIssueFromResponse } from '../../helpers/issues'; +import { throwGlobalError } from '../../sonar-aligned/helpers/error'; import { IssueResponse } from '../../types/issues'; import { Issue } from '../../types/types'; diff --git a/server/sonar-web/src/main/js/helpers/__tests__/error-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/error-test.ts index 495b93d3880..e99e03bfae9 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/error-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/error-test.ts @@ -19,7 +19,7 @@ */ import { addGlobalErrorMessage } from 'design-system'; -import { throwGlobalError } from '../error'; +import { throwGlobalError } from '../../sonar-aligned/helpers/error'; jest.mock('design-system', () => ({ addGlobalErrorMessage: jest.fn(), diff --git a/server/sonar-web/src/main/js/helpers/error.ts b/server/sonar-web/src/main/js/sonar-aligned/helpers/error.ts index 96199726f35..5dd04ec62b1 100644 --- a/server/sonar-web/src/main/js/helpers/error.ts +++ b/server/sonar-web/src/main/js/sonar-aligned/helpers/error.ts @@ -19,9 +19,18 @@ */ import { addGlobalErrorMessage } from 'design-system'; -import { parseError } from './request'; +import handleRequiredAuthentication from '../../helpers/handleRequiredAuthentication'; +import { HttpStatus, parseError } from '../../helpers/request'; -export function throwGlobalError(param: Response | any): Promise<Response | any> { +interface ThrowGlobalErrorOptions { + redirectUnauthorizedNoReasons?: boolean; + returnErrorReasons?: boolean; // used only in SC +} + +export function throwGlobalError( + param: Response | any, + options: ThrowGlobalErrorOptions = {}, +): Promise<Response | any> { if (param.response instanceof Response) { /* eslint-disable-next-line no-console */ console.warn('DEPRECATED: response should not be wrapped, pass it directly.'); @@ -30,9 +39,17 @@ export function throwGlobalError(param: Response | any): Promise<Response | any> if (param instanceof Response) { return parseError(param) - .then(addGlobalErrorMessage, () => { - /* ignore parsing errors */ - }) + .then( + (...args) => { + addGlobalErrorMessage(...args); + if (options.redirectUnauthorizedNoReasons && param.status === HttpStatus.Unauthorized) { + handleRequiredAuthentication(); + } + }, + () => { + /* ignore parsing errors */ + }, + ) .then(() => Promise.reject(param)); } |