From 43832d162a17dddc79627333d32f70f11923a93d Mon Sep 17 00:00:00 2001 From: Ismail Cherri Date: Mon, 22 Apr 2024 18:02:41 +0200 Subject: [PATCH] SONAR-22049 Align the usage of withRouter high order component --- .../js/app/components/ComponentContainer.tsx | 2 +- .../main/js/app/components/PageTracker.tsx | 3 +- .../js/app/components/PluginRiskConsent.tsx | 4 +- .../__tests__/ComponentContainer-test.tsx | 15 ++++-- .../app-state/withAppStateContext.tsx | 2 +- .../withAvailableFeatures.tsx | 2 +- .../componentContext/withComponentContext.tsx | 2 +- .../current-user/withCurrentUserContext.tsx | 2 +- .../app/components/extensions/Extension.tsx | 4 +- .../components/global-search/GlobalSearch.tsx | 3 +- .../IndexationNotificationRenderer.tsx | 3 +- .../languages/withLanguagesContext.tsx | 2 +- .../components/metrics/withMetricsContext.tsx | 2 +- .../js/app/components/nav/component/Menu.tsx | 2 +- .../nav/component/branch-like/Menu.tsx | 6 ++- .../components/AuditAppRenderer.tsx | 3 +- .../components/BackgroundTasksApp.tsx | 5 +- .../ChangeAdminPasswordApp.tsx | 3 +- .../ChangeAdminPasswordAppRenderer.tsx | 3 +- .../main/js/apps/code/components/CodeApp.tsx | 3 +- .../apps/code/components/CodeAppRenderer.tsx | 2 +- .../js/apps/code/components/ComponentName.tsx | 4 +- .../main/js/apps/code/components/Search.tsx | 3 +- .../code/components/SourceViewerWrapper.tsx | 2 +- .../components/CodingRulesApp.tsx | 5 +- .../src/main/js/apps/coding-rules/query.ts | 3 +- .../src/main/js/apps/coding-rules/routes.tsx | 2 +- .../components/ComponentMeasuresApp.tsx | 3 +- .../components/MeasureContent.tsx | 2 +- .../components/MeasureOverviewContainer.tsx | 2 +- .../js/apps/component-measures/routes.tsx | 2 +- .../main/js/apps/component-measures/utils.ts | 2 +- .../project/Azure/AzureProjectAccordion.tsx | 2 +- .../project/Azure/AzureProjectCreate.tsx | 2 +- .../Azure/AzureProjectCreateRenderer.tsx | 3 +- .../project/Azure/AzureProjectsList.tsx | 2 +- .../BitbucketCloudProjectCreate.tsx | 2 +- .../BitbucketCloudProjectCreateRender.tsx | 2 +- .../BitbucketCloudSearchForm.tsx | 2 +- .../BitbucketImportRepositoryForm.tsx | 2 +- .../BitbucketProjectAccordion.tsx | 2 +- .../BitbucketProjectCreate.tsx | 2 +- .../apps/create/project/CreateProjectPage.tsx | 3 +- .../project/Github/GitHubProjectCreate.tsx | 2 +- .../Github/GitHubProjectCreateRenderer.tsx | 3 +- .../project/Gitlab/GitlabProjectCreate.tsx | 2 +- .../Gitlab/GitlabProjectCreateRenderer.tsx | 2 +- .../Gitlab/GitlabProjectSelectionForm.tsx | 2 +- .../components/NewCodeDefinitionSelection.tsx | 5 +- .../monorepo/MonorepoProjectCreate.tsx | 2 +- .../monorepo/MonorepoProjectHeader.tsx | 2 +- .../apps/create/project/useProjectCreate.tsx | 2 +- .../js/apps/issues/components/IssuesApp.tsx | 6 +-- .../js/apps/issues/sidebar/ListStyleFacet.tsx | 3 +- .../src/main/js/apps/issues/utils.ts | 3 +- .../src/main/js/apps/marketplace/App.tsx | 3 +- .../marketplace/MarketplaceAppContainer.tsx | 3 +- .../src/main/js/apps/marketplace/utils.ts | 2 +- .../branches/BranchOverviewRenderer.tsx | 2 +- .../branches/FirstAnalysisNextStepsNotif.tsx | 2 +- .../branches/MeasuresPanelNoNewCode.tsx | 4 +- .../src/main/js/apps/overview/utils.tsx | 3 +- .../components/ActionsCell.tsx | 5 +- .../components/Header.tsx | 3 +- .../components/NameCell.tsx | 2 +- .../components/PermissionTemplatesApp.tsx | 3 +- .../components/ProjectActivityApp.tsx | 2 +- .../src/main/js/apps/projectActivity/utils.ts | 3 +- .../src/main/js/apps/projectDeletion/Form.tsx | 3 +- .../badges/__tests__/utils-test.ts | 2 +- .../main/js/apps/projectKey/ProjectKeyApp.tsx | 3 +- .../apps/projects/components/AllProjects.tsx | 4 +- .../components/ApplicationCreation.tsx | 3 +- .../components/DefaultPageSelector.tsx | 2 +- .../components/EmptyFavoriteSearch.tsx | 2 +- .../projects/components/EmptyInstance.tsx | 3 +- .../projects/components/FavoriteFilter.tsx | 2 +- .../apps/projects/components/PageHeader.tsx | 2 +- .../apps/projects/components/PageSidebar.tsx | 3 +- .../components/ProjectCreationMenuItem.tsx | 2 +- .../__tests__/CreateApplication-test.tsx | 2 +- .../__tests__/DefaultPageSelector-test.tsx | 2 +- .../apps/projects/filters/CoverageFilter.tsx | 2 +- .../projects/filters/DuplicationsFilter.tsx | 2 +- .../apps/projects/filters/LanguagesFilter.tsx | 3 +- .../filters/MaintainabilityFilter.tsx | 2 +- .../apps/projects/filters/NewLinesFilter.tsx | 2 +- .../filters/NewMaintainabilityFilter.tsx | 2 +- .../projects/filters/NewReliabilityFilter.tsx | 2 +- .../projects/filters/NewSecurityFilter.tsx | 2 +- .../apps/projects/filters/QualifierFilter.tsx | 2 +- .../projects/filters/QualityGateFilter.tsx | 3 +- .../apps/projects/filters/RangeFacetBase.tsx | 2 +- .../js/apps/projects/filters/RatingFacet.tsx | 2 +- .../projects/filters/ReliabilityFilter.tsx | 2 +- .../apps/projects/filters/SecurityFilter.tsx | 2 +- .../projects/filters/SecurityReviewFilter.tsx | 3 +- .../js/apps/projects/filters/SizeFilter.tsx | 2 +- .../js/apps/projects/filters/TagsFilter.tsx | 5 +- .../src/main/js/apps/projects/query.ts | 3 +- .../components/CopyQualityGateForm.tsx | 2 +- .../components/CreateQualityGateForm.tsx | 2 +- .../components/DeleteQualityGateForm.tsx | 2 +- .../components/RenameQualityGateForm.tsx | 2 +- .../changelog/ChangelogContainer.tsx | 3 +- .../compare/ComparisonContainer.tsx | 2 +- .../components/ProfileActions.tsx | 3 +- .../components/ProfileContainer.tsx | 2 +- .../details/ProfileHeader.tsx | 2 +- .../home/CreateProfileForm.tsx | 2 +- .../quality-profiles/home/LanguageSelect.tsx | 2 +- .../apps/quality-profiles/home/PageHeader.tsx | 2 +- .../qualityProfilesContext.tsx | 4 +- .../main/js/apps/quality-profiles/utils.ts | 2 +- .../security-hotspots/SecurityHotspotsApp.tsx | 3 +- .../js/apps/sessions/components/Login.tsx | 2 +- .../sessions/components/LoginContainer.tsx | 3 +- .../js/apps/settings/components/Languages.tsx | 3 +- .../components/SettingsAppRenderer.tsx | 3 +- .../settings/components/SettingsSearch.tsx | 3 +- .../components/SubCategoryDefinitionsList.tsx | 3 +- .../almIntegration/AlmIntegration.tsx | 3 +- .../authentication/Authentication.tsx | 2 +- .../js/apps/system/components/SystemApp.tsx | 3 +- .../src/main/js/apps/system/utils.ts | 2 +- .../sonar-web/src/main/js/apps/users/utils.ts | 2 +- .../js/apps/web-api/components/Action.tsx | 2 +- .../main/js/apps/web-api/components/Menu.tsx | 2 +- .../js/apps/web-api/components/WebApiApp.tsx | 3 +- .../src/main/js/apps/web-api/utils.ts | 3 +- .../SourceViewer/helpers/loadIssues.ts | 3 +- .../main/js/components/hoc/whenLoggedIn.tsx | 2 +- .../components/hoc/withCLanguageFeature.tsx | 2 +- .../components/hoc/withIndexationContext.tsx | 2 +- .../components/hoc/withKeyboardNavigation.tsx | 2 +- .../js/components/hoc/withNotifications.tsx | 2 +- .../main/js/components/hoc/withScrollTo.tsx | 2 +- .../issue/components/IssueMessage.tsx | 2 +- .../NCDAutoUpdateMessage.tsx | 2 +- .../tutorials/TutorialSelection.tsx | 3 +- .../main/js/helpers/__tests__/urls-test.ts | 4 +- server/sonar-web/src/main/js/helpers/query.ts | 2 +- .../src/main/js/helpers/testMocks.ts | 5 +- .../main/js/helpers/testReactTestingUtils.tsx | 2 +- server/sonar-web/src/main/js/helpers/urls.ts | 50 +------------------ .../sonar-web/src/main/js/queries/branch.tsx | 4 +- .../components/hoc/__tests__/utils-test.ts | 0 .../components/hoc/utils.ts | 2 + .../components/hoc/withRouter.tsx | 34 ++++++------- .../helpers/__tests__/urls-test.ts | 38 ++++++++++++++ .../main/js/sonar-aligned/helpers/router.ts | 37 ++++++++++++++ .../src/main/js/sonar-aligned/helpers/urls.ts | 39 ++++++++++++--- .../src/main/js/sonar-aligned/types/router.ts | 41 +++++++++++++++ .../sonar-web/src/main/js/types/extension.ts | 2 +- server/sonar-web/src/main/js/types/types.ts | 2 - 155 files changed, 392 insertions(+), 242 deletions(-) rename server/sonar-web/src/main/js/{ => sonar-aligned}/components/hoc/__tests__/utils-test.ts (100%) rename server/sonar-web/src/main/js/{ => sonar-aligned}/components/hoc/utils.ts (97%) rename server/sonar-web/src/main/js/{ => sonar-aligned}/components/hoc/withRouter.tsx (79%) create mode 100644 server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/urls-test.ts create mode 100644 server/sonar-web/src/main/js/sonar-aligned/helpers/router.ts create mode 100644 server/sonar-web/src/main/js/sonar-aligned/types/router.ts diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx index b8edf5e2c4d..0e96137e0be 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx @@ -23,11 +23,11 @@ import * as React from 'react'; import { createPortal } from 'react-dom'; import { Helmet } from 'react-helmet-async'; import { Outlet } from 'react-router-dom'; +import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter'; import { validateProjectAlmBinding } from '../../api/alm-settings'; import { getTasksForComponent } from '../../api/ce'; import { getComponentData } from '../../api/components'; import { getComponentNavigation } from '../../api/navigation'; -import { useLocation, useRouter } from '../../components/hoc/withRouter'; import { translateWithParameters } from '../../helpers/l10n'; import { HttpStatus } from '../../helpers/request'; import { getPortfolioUrl, getProjectUrl, getPullRequestUrl } from '../../helpers/urls'; diff --git a/server/sonar-web/src/main/js/app/components/PageTracker.tsx b/server/sonar-web/src/main/js/app/components/PageTracker.tsx index 65c341f9b70..94a20c98e3c 100644 --- a/server/sonar-web/src/main/js/app/components/PageTracker.tsx +++ b/server/sonar-web/src/main/js/app/components/PageTracker.tsx @@ -19,7 +19,8 @@ */ import * as React from 'react'; import { Helmet } from 'react-helmet-async'; -import { Location, withRouter } from '../../components/hoc/withRouter'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location } from '~sonar-aligned/types/router'; import { installScript } from '../../helpers/extensions'; import { getWebAnalyticsPageHandlerFromCache } from '../../helpers/extensionsHandler'; import { getInstance } from '../../helpers/system'; diff --git a/server/sonar-web/src/main/js/app/components/PluginRiskConsent.tsx b/server/sonar-web/src/main/js/app/components/PluginRiskConsent.tsx index 3d781f422f2..01e8dd143d6 100644 --- a/server/sonar-web/src/main/js/app/components/PluginRiskConsent.tsx +++ b/server/sonar-web/src/main/js/app/components/PluginRiskConsent.tsx @@ -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 { ButtonPrimary, Card, CenteredLayout, Title } from 'design-system'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Router } from '~sonar-aligned/types/router'; import { setSimpleSettingValue } from '../../api/settings'; import { whenLoggedIn } from '../../components/hoc/whenLoggedIn'; -import { Router, withRouter } from '../../components/hoc/withRouter'; import { translate } from '../../helpers/l10n'; import { getBaseUrl } from '../../helpers/system'; import { hasGlobalPermission } from '../../helpers/users'; diff --git a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx index dc1f1781e7e..c617493d56d 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx @@ -21,11 +21,11 @@ import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React, { useContext } from 'react'; import { Route } from 'react-router-dom'; +import * as withRouter from '~sonar-aligned/components/hoc/withRouter'; import { validateProjectAlmBinding } from '../../../api/alm-settings'; import { getTasksForComponent } from '../../../api/ce'; import { getComponentData } from '../../../api/components'; import { getComponentNavigation } from '../../../api/navigation'; -import * as withRouter from '../../../components/hoc/withRouter'; import { mockProjectAlmBindingConfigurationErrors } from '../../../helpers/mocks/alm-settings'; import { mockBranch, mockPullRequest } from '../../../helpers/mocks/branch-like'; import { mockComponent } from '../../../helpers/mocks/component'; @@ -72,9 +72,9 @@ jest.mock('../../utils/handleRequiredAuthorization', () => ({ default: jest.fn(), })); -jest.mock('../../../components/hoc/withRouter', () => ({ +jest.mock('~sonar-aligned/components/hoc/withRouter', () => ({ __esModule: true, - ...jest.requireActual('../../../components/hoc/withRouter'), + ...jest.requireActual('~sonar-aligned/components/hoc/withRouter'), })); const ui = { @@ -466,6 +466,9 @@ describe('tutorials', () => { jest.spyOn(withRouter, 'useRouter').mockReturnValue({ replace: mockedReplace, push: jest.fn(), + navigate: jest.fn(), + searchParams: new URLSearchParams(), + setSearchParams: jest.fn(), }); renderComponentContainer( @@ -515,6 +518,9 @@ describe('tutorials', () => { jest.spyOn(withRouter, 'useRouter').mockReturnValue({ replace: mockedReplace, push: jest.fn(), + navigate: jest.fn(), + searchParams: new URLSearchParams(), + setSearchParams: jest.fn(), }); jest.useFakeTimers(); @@ -568,6 +574,9 @@ describe('tutorials', () => { jest.spyOn(withRouter, 'useRouter').mockReturnValue({ replace: mockedReplace, push: jest.fn(), + navigate: jest.fn(), + searchParams: new URLSearchParams(), + setSearchParams: jest.fn(), }); jest.useFakeTimers(); diff --git a/server/sonar-web/src/main/js/app/components/app-state/withAppStateContext.tsx b/server/sonar-web/src/main/js/app/components/app-state/withAppStateContext.tsx index b1236d9bc1e..811c6b249b0 100644 --- a/server/sonar-web/src/main/js/app/components/app-state/withAppStateContext.tsx +++ b/server/sonar-web/src/main/js/app/components/app-state/withAppStateContext.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { getWrappedDisplayName } from '../../../components/hoc/utils'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { AppState } from '../../../types/appstate'; import { AppStateContext } from './AppStateContext'; diff --git a/server/sonar-web/src/main/js/app/components/available-features/withAvailableFeatures.tsx b/server/sonar-web/src/main/js/app/components/available-features/withAvailableFeatures.tsx index 96e4d17232e..36355f33366 100644 --- a/server/sonar-web/src/main/js/app/components/available-features/withAvailableFeatures.tsx +++ b/server/sonar-web/src/main/js/app/components/available-features/withAvailableFeatures.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { getWrappedDisplayName } from '../../../components/hoc/utils'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { Feature } from '../../../types/features'; import { AvailableFeaturesContext } from './AvailableFeaturesContext'; diff --git a/server/sonar-web/src/main/js/app/components/componentContext/withComponentContext.tsx b/server/sonar-web/src/main/js/app/components/componentContext/withComponentContext.tsx index 5fc508076e6..c2b4a9acce7 100644 --- a/server/sonar-web/src/main/js/app/components/componentContext/withComponentContext.tsx +++ b/server/sonar-web/src/main/js/app/components/componentContext/withComponentContext.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { getWrappedDisplayName } from '../../../components/hoc/utils'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { ComponentContextShape, ComponentQualifier } from '../../../types/component'; import { ComponentContext } from './ComponentContext'; diff --git a/server/sonar-web/src/main/js/app/components/current-user/withCurrentUserContext.tsx b/server/sonar-web/src/main/js/app/components/current-user/withCurrentUserContext.tsx index 5e8fa2ff2f6..f5643d57cfd 100644 --- a/server/sonar-web/src/main/js/app/components/current-user/withCurrentUserContext.tsx +++ b/server/sonar-web/src/main/js/app/components/current-user/withCurrentUserContext.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { getWrappedDisplayName } from '../../../components/hoc/utils'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { CurrentUserContext, CurrentUserContextInterface } from './CurrentUserContext'; export default function withCurrentUserContext

( diff --git a/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx b/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx index 92941228fff..99ecd9893e4 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx +++ b/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - import { withTheme } from '@emotion/react'; import { QueryClient } from '@tanstack/react-query'; import { addGlobalErrorMessage, Theme } from 'design-system'; @@ -25,7 +24,8 @@ import { isEqual } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { injectIntl, WrappedComponentProps } from 'react-intl'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, Router } from '~sonar-aligned/types/router'; import { getExtensionStart } from '../../../helpers/extensions'; import { translate } from '../../../helpers/l10n'; import { getCurrentL10nBundle } from '../../../helpers/l10nBundle'; diff --git a/server/sonar-web/src/main/js/app/components/global-search/GlobalSearch.tsx b/server/sonar-web/src/main/js/app/components/global-search/GlobalSearch.tsx index f614f5314c6..be60a163d75 100644 --- a/server/sonar-web/src/main/js/app/components/global-search/GlobalSearch.tsx +++ b/server/sonar-web/src/main/js/app/components/global-search/GlobalSearch.tsx @@ -29,11 +29,12 @@ import { } from 'design-system'; import { debounce, uniqBy } from 'lodash'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Router } from '~sonar-aligned/types/router'; import { getSuggestions } from '../../../api/components'; import FocusOutHandler from '../../../components/controls/FocusOutHandler'; import OutsideClickHandler from '../../../components/controls/OutsideClickHandler'; import Tooltip from '../../../components/controls/Tooltip'; -import { Router, withRouter } from '../../../components/hoc/withRouter'; import { PopupPlacement } from '../../../components/ui/popups'; import { isInput, isShortcut } from '../../../helpers/keyboardEventHelpers'; import { KeyboardKeys } from '../../../helpers/keycodes'; diff --git a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx index 5bb714c9697..36d70efcb95 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* eslint-disable react/no-unused-prop-types */ - import styled from '@emotion/styled'; import { FlagErrorIcon, @@ -32,9 +31,9 @@ import { } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import DocumentationLink from '../../../components/common/DocumentationLink'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { queryToSearch } from '../../../helpers/urls'; import { IndexationNotificationType } from '../../../types/indexation'; import { TaskStatuses, TaskTypes } from '../../../types/tasks'; diff --git a/server/sonar-web/src/main/js/app/components/languages/withLanguagesContext.tsx b/server/sonar-web/src/main/js/app/components/languages/withLanguagesContext.tsx index aa22c91e81a..26ab1594769 100644 --- a/server/sonar-web/src/main/js/app/components/languages/withLanguagesContext.tsx +++ b/server/sonar-web/src/main/js/app/components/languages/withLanguagesContext.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { getWrappedDisplayName } from '../../../components/hoc/utils'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { Languages } from '../../../types/languages'; import { LanguagesContext } from './LanguagesContext'; diff --git a/server/sonar-web/src/main/js/app/components/metrics/withMetricsContext.tsx b/server/sonar-web/src/main/js/app/components/metrics/withMetricsContext.tsx index ab6eb5aa354..d2a502d4ce3 100644 --- a/server/sonar-web/src/main/js/app/components/metrics/withMetricsContext.tsx +++ b/server/sonar-web/src/main/js/app/components/metrics/withMetricsContext.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { getWrappedDisplayName } from '../../../components/hoc/utils'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { Dict, Metric } from '../../../types/types'; import { MetricsContext } from './MetricsContext'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx index fda6f759b77..f5db2e2a13d 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx @@ -26,8 +26,8 @@ import { PopupZLevel, } from 'design-system'; import * as React from 'react'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; -import { useLocation } from '../../../../components/hoc/withRouter'; import { DEFAULT_ISSUES_QUERY } from '../../../../components/shared/utils'; import { isPullRequest } from '../../../../helpers/branch-like'; import { hasMessage, translate, translateWithParameters } from '../../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx index 41c75853d57..24b448c766c 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx @@ -19,8 +19,10 @@ */ import { DropdownMenu, InputSearch, ItemDivider, Link } from 'design-system'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; import { isBranch } from '~sonar-aligned/helpers/branch-like'; -import { Router, withRouter } from '../../../../../components/hoc/withRouter'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; +import { Router } from '~sonar-aligned/types/router'; import { getBrancheLikesAsTree, isPullRequest, @@ -28,7 +30,7 @@ import { } from '../../../../../helpers/branch-like'; import { KeyboardKeys } from '../../../../../helpers/keycodes'; import { translate } from '../../../../../helpers/l10n'; -import { getBranchLikeUrl, queryToSearch } from '../../../../../helpers/urls'; +import { getBranchLikeUrl } from '../../../../../helpers/urls'; import { BranchLike, BranchLikeTree } from '../../../../../types/branch-like'; import { ComponentQualifier } from '../../../../../types/component'; import { Component } from '../../../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/audit-logs/components/AuditAppRenderer.tsx b/server/sonar-web/src/main/js/apps/audit-logs/components/AuditAppRenderer.tsx index 98b3de92e9c..539b576752e 100644 --- a/server/sonar-web/src/main/js/apps/audit-logs/components/AuditAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/audit-logs/components/AuditAppRenderer.tsx @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - import { Link, RadioButtonGroup } from '@sonarsource/echoes-react'; import { subDays } from 'date-fns'; import { @@ -30,10 +29,10 @@ import { import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; import { now } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; -import { queryToSearch } from '../../../helpers/urls'; import '../style.css'; import { HousekeepingPolicy, RangeOption } from '../utils'; import DownloadButton from './DownloadButton'; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx index f462ab82d38..b5539eb3fcc 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx @@ -22,6 +22,8 @@ import { LargeCenteredLayout, PageContentFontWrapper } from 'design-system'; import { debounce } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, RawQuery, Router } from '~sonar-aligned/types/router'; import { cancelAllTasks, cancelTask as cancelTaskAPI, @@ -32,12 +34,11 @@ import { import withComponentContext from '../../../app/components/componentContext/withComponentContext'; import ListFooter from '../../../components/controls/ListFooter'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import { toShortISO8601String } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; import { parseAsDate } from '../../../helpers/query'; import { Task, TaskStatuses } from '../../../types/tasks'; -import { Component, Paging, RawQuery } from '../../../types/types'; +import { Component, Paging } from '../../../types/types'; import { CURRENTS, DEBOUNCE_DELAY, DEFAULT_FILTERS, PAGE_SIZE } from '../constants'; import { Query, mapFiltersToParameters, updateTask } from '../utils'; import Header from './Header'; diff --git a/server/sonar-web/src/main/js/apps/change-admin-password/ChangeAdminPasswordApp.tsx b/server/sonar-web/src/main/js/apps/change-admin-password/ChangeAdminPasswordApp.tsx index ad311fe81b6..708fd0eb11b 100644 --- a/server/sonar-web/src/main/js/apps/change-admin-password/ChangeAdminPasswordApp.tsx +++ b/server/sonar-web/src/main/js/apps/change-admin-password/ChangeAdminPasswordApp.tsx @@ -18,9 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location } from '~sonar-aligned/types/router'; import { changePassword } from '../../api/users'; import withAppStateContext from '../../app/components/app-state/withAppStateContext'; -import { Location, withRouter } from '../../components/hoc/withRouter'; import { AppState } from '../../types/appstate'; import ChangeAdminPasswordAppRenderer from './ChangeAdminPasswordAppRenderer'; import { DEFAULT_ADMIN_LOGIN, DEFAULT_ADMIN_PASSWORD } from './constants'; diff --git a/server/sonar-web/src/main/js/apps/change-admin-password/ChangeAdminPasswordAppRenderer.tsx b/server/sonar-web/src/main/js/apps/change-admin-password/ChangeAdminPasswordAppRenderer.tsx index 43a11c52981..1ce5f38e4ec 100644 --- a/server/sonar-web/src/main/js/apps/change-admin-password/ChangeAdminPasswordAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/change-admin-password/ChangeAdminPasswordAppRenderer.tsx @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - import { LinkStandalone } from '@sonarsource/echoes-react'; import { ButtonPrimary, @@ -34,7 +33,7 @@ import { } from 'design-system'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; -import { Location } from '../../components/hoc/withRouter'; +import { Location } from '~sonar-aligned/types/router'; import { translate } from '../../helpers/l10n'; import { getReturnUrl } from '../../helpers/urls'; import Unauthorized from '../sessions/components/Unauthorized'; diff --git a/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx b/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx index 9773a641bb9..fcb3b6cd505 100644 --- a/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx @@ -18,9 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, Router } from '~sonar-aligned/types/router'; import withComponentContext from '../../../app/components/componentContext/withComponentContext'; import withMetricsContext from '../../../app/components/metrics/withMetricsContext'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import { CodeScope, getCodeUrl, getProjectUrl } from '../../../helpers/urls'; import { WithBranchLikesProps, useBranchesQuery } from '../../../queries/branch'; import { ComponentQualifier, isPortfolioLike } from '../../../types/component'; diff --git a/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx b/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx index 1cb824488c1..54f38997cee 100644 --- a/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx @@ -30,10 +30,10 @@ import { difference, intersection } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import HelpTooltip from '~sonar-aligned/components/controls/HelpTooltip'; +import { Location } from '~sonar-aligned/types/router'; import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget'; import ListFooter from '../../../components/controls/ListFooter'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; -import { Location } from '../../../components/hoc/withRouter'; import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage'; import { CCT_SOFTWARE_QUALITY_METRICS, OLD_TAXONOMY_METRICS } from '../../../helpers/constants'; import { KeyboardKeys } from '../../../helpers/keycodes'; diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx index ac401b378b0..22d5b0c07fd 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx @@ -17,14 +17,14 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - import { LinkHighlight, LinkStandalone } from '@sonarsource/echoes-react'; import { Badge, BranchIcon, LightLabel, Note, QualifierIcon } from 'design-system'; import * as React from 'react'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { translate } from '../../../helpers/l10n'; import { isDefined } from '../../../helpers/types'; -import { CodeScope, getComponentOverviewUrl, queryToSearch } from '../../../helpers/urls'; +import { CodeScope, getComponentOverviewUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier, diff --git a/server/sonar-web/src/main/js/apps/code/components/Search.tsx b/server/sonar-web/src/main/js/apps/code/components/Search.tsx index bf0bd2bc9e2..b99f1b76f81 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Search.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Search.tsx @@ -21,9 +21,10 @@ import classNames from 'classnames'; import { InputSearch, Spinner, ToggleButton } from 'design-system'; import { isEmpty, omit } from 'lodash'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; +import { Location, Router } from '~sonar-aligned/types/router'; import { getTree } from '../../../api/components'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; diff --git a/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx b/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx index 1e0d6bd8ceb..2e23d1a35e3 100644 --- a/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx @@ -18,9 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Location } from '~sonar-aligned/types/router'; import SourceViewer from '../../../components/SourceViewer/SourceViewer'; import withKeyboardNavigation from '../../../components/hoc/withKeyboardNavigation'; -import { Location } from '../../../components/hoc/withRouter'; import { BranchLike } from '../../../types/branch-like'; import { Measure } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesApp.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesApp.tsx index 94eaa811692..e9b9f0b09e3 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesApp.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesApp.tsx @@ -30,6 +30,8 @@ import { import { keyBy } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, RawQuery, Router } from '~sonar-aligned/types/router'; import { Profile, searchQualityProfiles } from '../../../api/quality-profiles'; import { getRulesApp, searchRules } from '../../../api/rules'; import { getValue } from '../../../api/settings'; @@ -37,14 +39,13 @@ import withCurrentUserContext from '../../../app/components/current-user/withCur import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget'; import ListFooter from '../../../components/controls/ListFooter'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import '../../../components/search-navigator.css'; import { isInput, isShortcut } from '../../../helpers/keyboardEventHelpers'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { SecurityStandard } from '../../../types/security'; import { SettingsKey } from '../../../types/settings'; -import { Dict, Paging, RawQuery, Rule, RuleActivation } from '../../../types/types'; +import { Dict, Paging, Rule, RuleActivation } from '../../../types/types'; import { CurrentUser, isLoggedIn } from '../../../types/users'; import { FiltersHeader } from '../../issues/sidebar/FiltersHeader'; import { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/query.ts b/server/sonar-web/src/main/js/apps/coding-rules/query.ts index 09716f644d8..5a4659072ff 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/query.ts +++ b/server/sonar-web/src/main/js/apps/coding-rules/query.ts @@ -17,6 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RawQuery } from '~sonar-aligned/types/router'; import { cleanQuery, parseAsArray, @@ -35,7 +36,7 @@ import { SoftwareImpactSeverity, SoftwareQuality, } from '../../types/clean-code-taxonomy'; -import { Dict, RawQuery, RuleInheritance } from '../../types/types'; +import { Dict, RuleInheritance } from '../../types/types'; export interface Query { activation: boolean | undefined; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/routes.tsx b/server/sonar-web/src/main/js/apps/coding-rules/routes.tsx index 89b98af44d0..8ac74338daa 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/routes.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/routes.tsx @@ -19,7 +19,7 @@ */ import React, { useEffect } from 'react'; import { Route, useLocation, useNavigate } from 'react-router-dom'; -import { RawQuery } from '../../types/types'; +import { RawQuery } from '~sonar-aligned/types/router'; import CodingRulesApp from './components/CodingRulesApp'; import { parseQuery, serializeQuery } from './query'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx index f05615a4f67..57fb020d3ed 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx @@ -32,12 +32,13 @@ import { keyBy } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import HelpTooltip from '~sonar-aligned/components/controls/HelpTooltip'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; +import { Location, Router } from '~sonar-aligned/types/router'; import { getMeasuresWithPeriod } from '../../../api/measures'; import { getAllMetrics } from '../../../api/metrics'; import { ComponentContext } from '../../../app/components/componentContext/ComponentContext'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import { enhanceMeasure } from '../../../components/measure/utils'; import '../../../components/search-navigator.css'; import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx index 20013d6cbfe..2d217fc8a1c 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx @@ -20,11 +20,11 @@ import { Highlight, KeyboardHint } from 'design-system'; import * as React from 'react'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; +import { Router } from '~sonar-aligned/types/router'; import { getComponentTree } from '../../../api/components'; import { getMeasures } from '../../../api/measures'; import SourceViewer from '../../../components/SourceViewer/SourceViewer'; import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget'; -import { Router } from '../../../components/hoc/withRouter'; import FilesCounter from '../../../components/ui/FilesCounter'; import { isSameBranchLike } from '../../../helpers/branch-like'; import { getComponentMeasureUniqueKey } from '../../../helpers/component'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx index 737c7520db1..9455a77c612 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx @@ -19,8 +19,8 @@ */ import * as React from 'react'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; +import { Router } from '~sonar-aligned/types/router'; import { getComponentShow } from '../../../api/components'; -import { Router } from '../../../components/hoc/withRouter'; import { isSameBranchLike } from '../../../helpers/branch-like'; import { getProjectUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/routes.tsx b/server/sonar-web/src/main/js/apps/component-measures/routes.tsx index 267ad6b1bc1..a547a34802e 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/routes.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/routes.tsx @@ -19,9 +19,9 @@ */ import React from 'react'; import { Navigate, Route, useParams, useSearchParams } from 'react-router-dom'; +import { searchParamsToQuery } from '~sonar-aligned/helpers/router'; import NavigateWithParams from '../../app/utils/NavigateWithParams'; import { omitNil } from '../../helpers/request'; -import { searchParamsToQuery } from '../../helpers/urls'; import ComponentMeasuresApp from './components/ComponentMeasuresApp'; const routes = () => ( diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.ts b/server/sonar-web/src/main/js/apps/component-measures/utils.ts index c9fbfe80f03..497e1ff9231 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/utils.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/utils.ts @@ -19,6 +19,7 @@ */ import { groupBy, memoize, sortBy, toPairs } from 'lodash'; import { isBranch } from '~sonar-aligned/helpers/branch-like'; +import { RawQuery } from '~sonar-aligned/types/router'; import { enhanceMeasure } from '../../components/measure/utils'; import { isPullRequest } from '../../helpers/branch-like'; import { @@ -54,7 +55,6 @@ import { Measure, MeasureEnhanced, Metric, - RawQuery, } from '../../types/types'; import { bubbles } from './config/bubbles'; import { domains } from './config/domains'; diff --git a/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectAccordion.tsx b/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectAccordion.tsx index 72ebbb98a26..dad9932e31d 100644 --- a/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectAccordion.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectAccordion.tsx @@ -20,10 +20,10 @@ import { Accordion, FlagMessage, Link, SearchHighlighter, Spinner } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import ListFooter from '../../../../components/controls/ListFooter'; import { translate } from '../../../../helpers/l10n'; import { getBaseUrl } from '../../../../helpers/system'; -import { queryToSearch } from '../../../../helpers/urls'; import { AzureProject, AzureRepository } from '../../../../types/alm-integration'; import AlmRepoItem from '../components/AlmRepoItem'; import { CreateProjectModes } from '../types'; diff --git a/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreate.tsx index ef78748573a..576e5bd092e 100644 --- a/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreate.tsx @@ -20,12 +20,12 @@ import { LabelValueSelectOption } from 'design-system'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { GroupBase } from 'react-select'; +import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter'; import { getAzureProjects, getAzureRepositories, searchAzureRepositories, } from '../../../../api/alm-integrations'; -import { useLocation, useRouter } from '../../../../components/hoc/withRouter'; import { AzureProject, AzureRepository } from '../../../../types/alm-integration'; import { AlmSettingsInstance } from '../../../../types/alm-settings'; import { DopSetting } from '../../../../types/dop-translation'; diff --git a/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreateRenderer.tsx b/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreateRenderer.tsx index ee74ec14b1c..95092bb61eb 100644 --- a/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreateRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreateRenderer.tsx @@ -27,10 +27,11 @@ import { } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { useAppState } from '../../../../app/components/app-state/withAppStateContext'; import { AvailableFeaturesContext } from '../../../../app/components/available-features/AvailableFeaturesContext'; import { translate } from '../../../../helpers/l10n'; -import { getGlobalSettingsUrl, queryToSearch } from '../../../../helpers/urls'; +import { getGlobalSettingsUrl } from '../../../../helpers/urls'; import { AzureProject, AzureRepository } from '../../../../types/alm-integration'; import { AlmKeys, AlmSettingsInstance } from '../../../../types/alm-settings'; import { Feature } from '../../../../types/features'; diff --git a/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectsList.tsx b/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectsList.tsx index 8bb9844a973..38caef1274c 100644 --- a/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectsList.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectsList.tsx @@ -21,9 +21,9 @@ import { FlagMessage, Link } from 'design-system'; import { uniqBy } from 'lodash'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import ListFooter from '../../../../components/controls/ListFooter'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; -import { queryToSearch } from '../../../../helpers/urls'; import { AzureProject, AzureRepository } from '../../../../types/alm-integration'; import { Dict } from '../../../../types/types'; import { CreateProjectModes } from '../types'; diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreate.tsx index bb008260269..56c40b24f6b 100644 --- a/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreate.tsx @@ -19,8 +19,8 @@ */ import { LabelValueSelectOption } from 'design-system'; import React, { useCallback, useMemo, useState } from 'react'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import { searchForBitbucketCloudRepositories } from '../../../../api/alm-integrations'; -import { useLocation } from '../../../../components/hoc/withRouter'; import { BitbucketCloudRepository } from '../../../../types/alm-integration'; import { AlmKeys } from '../../../../types/alm-settings'; import { DopSetting } from '../../../../types/dop-translation'; diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreateRender.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreateRender.tsx index b38aaa8dadc..76d6b8ec5c8 100644 --- a/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreateRender.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreateRender.tsx @@ -21,9 +21,9 @@ import { Link, Spinner } from '@sonarsource/echoes-react'; import { LightPrimary, Title } from 'design-system'; import React, { useContext } from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { AvailableFeaturesContext } from '../../../../app/components/available-features/AvailableFeaturesContext'; import { translate } from '../../../../helpers/l10n'; -import { queryToSearch } from '../../../../helpers/urls'; import { BitbucketCloudRepository } from '../../../../types/alm-integration'; import { AlmKeys, AlmSettingsInstance } from '../../../../types/alm-settings'; import { Feature } from '../../../../types/features'; diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudSearchForm.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudSearchForm.tsx index 35183531dd8..65d07e2f050 100644 --- a/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudSearchForm.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudSearchForm.tsx @@ -20,10 +20,10 @@ import { FlagMessage, InputSearch, LightPrimary, Link } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import ListFooter from '../../../../components/controls/ListFooter'; import { translate } from '../../../../helpers/l10n'; import { getBaseUrl } from '../../../../helpers/system'; -import { queryToSearch } from '../../../../helpers/urls'; import { BitbucketCloudRepository } from '../../../../types/alm-integration'; import AlmRepoItem from '../components/AlmRepoItem'; import { REPOSITORY_PAGE_SIZE } from '../constants'; diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketImportRepositoryForm.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketImportRepositoryForm.tsx index eb73a856c73..41cba5a4ef8 100644 --- a/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketImportRepositoryForm.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketImportRepositoryForm.tsx @@ -20,8 +20,8 @@ import { FlagMessage, InputSearch, Link } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { translate } from '../../../../helpers/l10n'; -import { queryToSearch } from '../../../../helpers/urls'; import { BitbucketProject, BitbucketProjectRepositories, diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectAccordion.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectAccordion.tsx index b6671796359..cd59f80c057 100644 --- a/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectAccordion.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectAccordion.tsx @@ -20,9 +20,9 @@ import { Accordion, FlagMessage, Link } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; import { getBaseUrl } from '../../../../helpers/system'; -import { queryToSearch } from '../../../../helpers/urls'; import { BitbucketProject, BitbucketRepository } from '../../../../types/alm-integration'; import AlmRepoItem from '../components/AlmRepoItem'; import { CreateProjectModes } from '../types'; diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectCreate.tsx index a5e25a15aeb..21067c5e982 100644 --- a/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectCreate.tsx @@ -18,12 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Location, Router } from '~sonar-aligned/types/router'; import { getBitbucketServerProjects, getBitbucketServerRepositories, searchForBitbucketServerRepositories, } from '../../../../api/alm-integrations'; -import { Location, Router } from '../../../../components/hoc/withRouter'; import { BitbucketProject, BitbucketProjectRepositories, diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx index 6515ac7850e..5870119ab8b 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx @@ -21,12 +21,13 @@ import classNames from 'classnames'; import { LargeCenteredLayout } from 'design-system'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, Router } from '~sonar-aligned/types/router'; import { getDopSettings } from '../../../api/dop-translation'; import withAvailableFeatures, { WithAvailableFeaturesProps, } from '../../../app/components/available-features/withAvailableFeatures'; import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { AlmKeys, AlmSettingsInstance } from '../../../types/alm-settings'; import { DopSetting } from '../../../types/dop-translation'; diff --git a/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreate.tsx index 6e17618d3f7..1c9d5f744ca 100644 --- a/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreate.tsx @@ -19,8 +19,8 @@ */ import { LabelValueSelectOption } from 'design-system'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter'; import { getGithubOrganizations, getGithubRepositories } from '../../../../api/alm-integrations'; -import { useLocation, useRouter } from '../../../../components/hoc/withRouter'; import { GithubOrganization, GithubRepository } from '../../../../types/alm-integration'; import { AlmInstanceBase, AlmKeys } from '../../../../types/alm-settings'; import { DopSetting } from '../../../../types/dop-translation'; diff --git a/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreateRenderer.tsx b/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreateRenderer.tsx index 1c7c0df9f55..4c8445b803b 100644 --- a/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreateRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreateRenderer.tsx @@ -18,16 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* eslint-disable react/no-unused-prop-types */ - import { Link, Spinner } from '@sonarsource/echoes-react'; import { DarkLabel, FlagMessage, InputSelect, LightPrimary, Title } from 'design-system'; import React, { useContext, useEffect, useState } from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { useAppState } from '../../../../app/components/app-state/withAppStateContext'; import { AvailableFeaturesContext } from '../../../../app/components/available-features/AvailableFeaturesContext'; import { translate } from '../../../../helpers/l10n'; import { LabelValueSelectOption } from '../../../../helpers/search'; -import { queryToSearch } from '../../../../helpers/urls'; import { GithubOrganization, GithubRepository } from '../../../../types/alm-integration'; import { AlmKeys, AlmSettingsInstance } from '../../../../types/alm-settings'; import { Feature } from '../../../../types/features'; diff --git a/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreate.tsx index b6792272ed7..d82e0eca756 100644 --- a/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreate.tsx @@ -19,8 +19,8 @@ */ import { LabelValueSelectOption } from 'design-system'; import React, { useCallback, useMemo } from 'react'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import { getGitlabProjects } from '../../../../api/alm-integrations'; -import { useLocation } from '../../../../components/hoc/withRouter'; import { GitlabProject } from '../../../../types/alm-integration'; import { AlmKeys } from '../../../../types/alm-settings'; import { DopSetting } from '../../../../types/dop-translation'; diff --git a/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreateRenderer.tsx b/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreateRenderer.tsx index 4b965923cdd..1ae69012bf7 100644 --- a/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreateRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreateRenderer.tsx @@ -21,9 +21,9 @@ import { Link, Spinner } from '@sonarsource/echoes-react'; import { LightPrimary, Title } from 'design-system'; import React, { useContext, useEffect, useState } from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { AvailableFeaturesContext } from '../../../../app/components/available-features/AvailableFeaturesContext'; import { translate } from '../../../../helpers/l10n'; -import { queryToSearch } from '../../../../helpers/urls'; import { GitlabProject } from '../../../../types/alm-integration'; import { AlmInstanceBase, AlmKeys, AlmSettingsInstance } from '../../../../types/alm-settings'; import { Feature } from '../../../../types/features'; diff --git a/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectSelectionForm.tsx b/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectSelectionForm.tsx index 2f42596321c..a78e407a33a 100644 --- a/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectSelectionForm.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectSelectionForm.tsx @@ -21,11 +21,11 @@ import { Link } from '@sonarsource/echoes-react'; import { FlagMessage, InputSearch, LightPrimary } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import ListFooter from '../../../../components/controls/ListFooter'; import Tooltip from '../../../../components/controls/Tooltip'; import { translate } from '../../../../helpers/l10n'; import { getBaseUrl } from '../../../../helpers/system'; -import { queryToSearch } from '../../../../helpers/urls'; import { GitlabProject } from '../../../../types/alm-integration'; import { Paging } from '../../../../types/types'; import AlmRepoItem from '../components/AlmRepoItem'; diff --git a/server/sonar-web/src/main/js/apps/create/project/components/NewCodeDefinitionSelection.tsx b/server/sonar-web/src/main/js/apps/create/project/components/NewCodeDefinitionSelection.tsx index 9f90b8bc8a4..11b0c391cab 100644 --- a/server/sonar-web/src/main/js/apps/create/project/components/NewCodeDefinitionSelection.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/components/NewCodeDefinitionSelection.tsx @@ -34,11 +34,12 @@ import * as React from 'react'; import { useEffect } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; import { useNavigate, unstable_usePrompt as usePrompt } from 'react-router-dom'; -import { useLocation } from '../../../../components/hoc/withRouter'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import NewCodeDefinitionSelector from '../../../../components/new-code-definition/NewCodeDefinitionSelector'; import { useDocUrl } from '../../../../helpers/docs'; import { translate } from '../../../../helpers/l10n'; -import { getProjectUrl, queryToSearch } from '../../../../helpers/urls'; +import { getProjectUrl } from '../../../../helpers/urls'; import { MutationArg, useImportProjectMutation, 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 92885d35dba..c766eca3c50 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 @@ -22,9 +22,9 @@ import { BlueGreySeparator, ButtonPrimary, ButtonSecondary } from 'design-system import React, { useEffect, useRef } from 'react'; import { FormattedMessage } from 'react-intl'; import { GroupBase } from 'react-select'; +import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter'; import { throwGlobalError } from '~sonar-aligned/helpers/error'; import { getComponents } from '../../../../api/project-management'; -import { useLocation, useRouter } from '../../../../components/hoc/withRouter'; import { LabelValueSelectOption } from '../../../../helpers/search'; import { useProjectBindingsQuery } from '../../../../queries/dop-translation'; import { AlmKeys } from '../../../../types/alm-settings'; diff --git a/server/sonar-web/src/main/js/apps/create/project/monorepo/MonorepoProjectHeader.tsx b/server/sonar-web/src/main/js/apps/create/project/monorepo/MonorepoProjectHeader.tsx index d4ba81dc8bb..1c1dad76528 100644 --- a/server/sonar-web/src/main/js/apps/create/project/monorepo/MonorepoProjectHeader.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/monorepo/MonorepoProjectHeader.tsx @@ -21,7 +21,7 @@ import { LinkStandalone } from '@sonarsource/echoes-react'; import { LightPrimary, Title } from 'design-system/lib'; import React from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; -import { useLocation } from '../../../../components/hoc/withRouter'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import { useDocUrl } from '../../../../helpers/docs'; export function MonorepoProjectHeader() { diff --git a/server/sonar-web/src/main/js/apps/create/project/useProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/useProjectCreate.tsx index d4df7a6fd2a..1c6c34e3c3e 100644 --- a/server/sonar-web/src/main/js/apps/create/project/useProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/useProjectCreate.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { useCallback, useEffect, useMemo, useState } from 'react'; -import { useLocation, useRouter } from '../../../components/hoc/withRouter'; +import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter'; import { isDefined } from '../../../helpers/types'; import { AlmInstanceBase, AlmKeys } from '../../../types/alm-settings'; import { DopSetting } from '../../../types/dop-translation'; diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx index 8d9ba6ee153..2ef265fa609 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - import styled from '@emotion/styled'; import { Checkbox, Spinner } from '@sonarsource/echoes-react'; import classNames from 'classnames'; @@ -35,7 +34,9 @@ import { keyBy, omit, without } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { FormattedMessage } from 'react-intl'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; +import { Location, RawQuery, Router } from '~sonar-aligned/types/router'; import { listIssues, searchIssues } from '../../../api/issues'; import { getRuleDetails } from '../../../api/rules'; import withComponentContext from '../../../app/components/componentContext/withComponentContext'; @@ -49,7 +50,6 @@ import withIndexationContext, { WithIndexationContextProps, } from '../../../components/hoc/withIndexationContext'; import withIndexationGuard from '../../../components/hoc/withIndexationGuard'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import IssueTabViewer from '../../../components/rules/IssueTabViewer'; import '../../../components/search-navigator.css'; import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils'; @@ -72,7 +72,7 @@ import { ReferencedRule, } from '../../../types/issues'; import { SecurityStandard } from '../../../types/security'; -import { Component, Dict, Issue, Paging, RawQuery, RuleDetails } from '../../../types/types'; +import { Component, Dict, Issue, Paging, RuleDetails } from '../../../types/types'; import { CurrentUser, UserBase } from '../../../types/users'; import * as actions from '../actions'; import SubnavigationIssuesList from '../issues-subnavigation/SubnavigationIssuesList'; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ListStyleFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/ListStyleFacet.tsx index 5aff62af9dc..0053437ec14 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/ListStyleFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ListStyleFacet.tsx @@ -21,13 +21,14 @@ import { FacetBox, FacetItem, FlagMessage, InputSearch, Note } from 'design-syst import { max, sortBy, values, without } from 'lodash'; import * as React from 'react'; import { formatMeasure } from '~sonar-aligned/helpers/measures'; +import { RawQuery } from '~sonar-aligned/types/router'; import ListFooter from '../../../components/controls/ListFooter'; import Tooltip from '../../../components/controls/Tooltip'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { queriesEqual } from '../../../helpers/query'; import { isDefined } from '../../../helpers/types'; import { MetricType } from '../../../types/metrics'; -import { Dict, Paging, RawQuery } from '../../../types/types'; +import { Dict, Paging } from '../../../types/types'; import { FacetItemsList } from './FacetItemsList'; import { ListStyleFacetFooter } from './ListStyleFacetFooter'; import { MultipleSelectionHint } from './MultipleSelectionHint'; diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts index 863b73c80fe..d5c3eb316c1 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -19,6 +19,7 @@ */ import { intersection, isArray, uniq } from 'lodash'; import { formatMeasure } from '~sonar-aligned/helpers/measures'; +import { RawQuery } from '~sonar-aligned/types/router'; import { getUsers } from '../../api/users'; import { DEFAULT_ISSUES_QUERY } from '../../components/shared/utils'; import { @@ -49,7 +50,7 @@ import { } from '../../types/issues'; import { MetricType } from '../../types/metrics'; import { SecurityStandard } from '../../types/security'; -import { Dict, Flow, FlowType, Issue, Paging, RawQuery } from '../../types/types'; +import { Dict, Flow, FlowType, Issue, Paging } from '../../types/types'; import { RestUser } from '../../types/users'; const OWASP_ASVS_4_0 = 'owaspAsvs-4.0'; diff --git a/server/sonar-web/src/main/js/apps/marketplace/App.tsx b/server/sonar-web/src/main/js/apps/marketplace/App.tsx index c122f26873a..2046602b6d7 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/App.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/App.tsx @@ -29,12 +29,13 @@ import { sortBy, uniqBy } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { FormattedMessage } from 'react-intl'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, Router } from '~sonar-aligned/types/router'; import { getAvailablePlugins, getInstalledPlugins } from '../../api/plugins'; import { getValue, setSimpleSettingValue } from '../../api/settings'; import DocumentationLink from '../../components/common/DocumentationLink'; import ListFooter from '../../components/controls/ListFooter'; import Suggestions from '../../components/embed-docs-modal/Suggestions'; -import { Location, Router, withRouter } from '../../components/hoc/withRouter'; import { translate } from '../../helpers/l10n'; import { EditionKey } from '../../types/editions'; import { PendingPluginResult, Plugin, RiskConsent } from '../../types/plugins'; diff --git a/server/sonar-web/src/main/js/apps/marketplace/MarketplaceAppContainer.tsx b/server/sonar-web/src/main/js/apps/marketplace/MarketplaceAppContainer.tsx index ea5b733f08c..8425258e660 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/MarketplaceAppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/MarketplaceAppContainer.tsx @@ -18,9 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location } from '~sonar-aligned/types/router'; import AdminContext from '../../app/components/AdminContext'; import withAppStateContext from '../../app/components/app-state/withAppStateContext'; -import { Location, withRouter } from '../../components/hoc/withRouter'; import { AppState } from '../../types/appstate'; import { EditionKey } from '../../types/editions'; import { GlobalSettingKeys } from '../../types/settings'; 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 bfa98d64ec9..c1e53f6dac6 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/utils.ts +++ b/server/sonar-web/src/main/js/apps/marketplace/utils.ts @@ -19,11 +19,11 @@ */ import { findLastIndex, memoize } from 'lodash'; import { throwGlobalError } from '~sonar-aligned/helpers/error'; +import { RawQuery } from '~sonar-aligned/types/router'; import { getInstalledPlugins, getUpdatesPlugins } from '../../api/plugins'; import { cleanQuery, parseAsString, serializeString } from '../../helpers/query'; import { isDefined } from '../../helpers/types'; import { InstalledPlugin, Plugin, Update } from '../../types/plugins'; -import { RawQuery } from '../../types/types'; export interface Query { filter: string; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx index c2ed85529d7..4d63589d17b 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx @@ -25,8 +25,8 @@ import { PageContentFontWrapper, } from 'design-system'; import * as React from 'react'; +import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter'; import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget'; -import { useLocation, useRouter } from '../../../components/hoc/withRouter'; import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage'; import { parseDate } from '../../../helpers/dates'; import { areCCTMeasuresComputed, isDiffMetric } from '../../../helpers/measures'; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/FirstAnalysisNextStepsNotif.tsx b/server/sonar-web/src/main/js/apps/overview/branches/FirstAnalysisNextStepsNotif.tsx index 88737d1605f..d6b9a67ffbd 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/FirstAnalysisNextStepsNotif.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/FirstAnalysisNextStepsNotif.tsx @@ -20,10 +20,10 @@ import { Link } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import withCurrentUserContext from '../../../app/components/current-user/withCurrentUserContext'; import DismissableAlert from '../../../components/ui/DismissableAlert'; import { translate } from '../../../helpers/l10n'; -import { queryToSearch } from '../../../helpers/urls'; import { useProjectBindingQuery } from '../../../queries/devops-integration'; import { ComponentQualifier } from '../../../types/component'; import { Component } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx index cae55e0304f..9b9d97189d9 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx @@ -17,16 +17,16 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - import { Link } from '@sonarsource/echoes-react'; import { Note, getTabPanelId } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import DocumentationLink from '../../../components/common/DocumentationLink'; import { Image } from '../../../components/common/Image'; import { translate } from '../../../helpers/l10n'; -import { CodeScope, queryToSearch } from '../../../helpers/urls'; +import { CodeScope } from '../../../helpers/urls'; import { Branch } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { NewCodeDefinitionType } from '../../../types/new-code-definition'; diff --git a/server/sonar-web/src/main/js/apps/overview/utils.tsx b/server/sonar-web/src/main/js/apps/overview/utils.tsx index fb824c69b06..211f0e76ed0 100644 --- a/server/sonar-web/src/main/js/apps/overview/utils.tsx +++ b/server/sonar-web/src/main/js/apps/overview/utils.tsx @@ -21,6 +21,7 @@ import { memoize } from 'lodash'; import React from 'react'; import { IntlShape } from 'react-intl'; import { formatMeasure } from '~sonar-aligned/helpers/measures'; +import { RawQuery } from '~sonar-aligned/types/router'; import { ISSUETYPE_METRIC_KEYS_MAP } from '../../helpers/issues'; import { translate } from '../../helpers/l10n'; import { parseAsString } from '../../helpers/query'; @@ -29,7 +30,7 @@ import { IssueType } from '../../types/issues'; import { MetricKey, MetricType } from '../../types/metrics'; import { AnalysisMeasuresVariations, MeasureHistory } from '../../types/project-activity'; import { QualityGateStatusConditionEnhanced } from '../../types/quality-gates'; -import { Dict, RawQuery } from '../../types/types'; +import { Dict } from '../../types/types'; export const BRANCH_OVERVIEW_METRICS: string[] = [ // quality gate diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx index f36ebc7a9db..8e7c7aac799 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx @@ -20,14 +20,15 @@ import { ActionsDropdown, ItemButton, ItemLink, PopupZLevel } from 'design-system'; import { difference } from 'lodash'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; +import { Router } from '~sonar-aligned/types/router'; import { deletePermissionTemplate, setDefaultPermissionTemplate, updatePermissionTemplate, } from '../../../api/permissions'; -import { Router, withRouter } from '../../../components/hoc/withRouter'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { queryToSearch } from '../../../helpers/urls'; import { PermissionTemplate } from '../../../types/types'; import { PERMISSION_TEMPLATES_PATH } from '../utils'; import DeleteForm from './DeleteForm'; 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 c085f194ea6..0f6e9b53a6a 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 @@ -19,9 +19,10 @@ */ import { ButtonPrimary, FlagMessage, Spinner, Title } from 'design-system'; import React, { useState } from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; import { throwGlobalError } from '~sonar-aligned/helpers/error'; +import { Router } from '~sonar-aligned/types/router'; import { createPermissionTemplate } from '../../../api/permissions'; -import { Router, withRouter } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { useGithubProvisioningEnabledQuery } from '../../../queries/identity-provider/github'; import { PERMISSION_TEMPLATES_PATH } from '../utils'; diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.tsx index 2fb96524707..9d3c7df3bf3 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.tsx @@ -19,7 +19,7 @@ */ import { CodeSnippet, ContentCell, Link } from 'design-system'; import * as React from 'react'; -import { queryToSearch } from '../../../helpers/urls'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { PermissionTemplate } from '../../../types/types'; import { PERMISSION_TEMPLATES_PATH } from '../utils'; import Defaults from './Defaults'; diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/PermissionTemplatesApp.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/PermissionTemplatesApp.tsx index 7deeabbea6a..451c29772d8 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/PermissionTemplatesApp.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/PermissionTemplatesApp.tsx @@ -19,10 +19,11 @@ */ import * as React from 'react'; import { Helmet } from 'react-helmet-async'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location } from '~sonar-aligned/types/router'; import { getPermissionTemplates } from '../../../api/permissions'; import withAppStateContext from '../../../app/components/app-state/withAppStateContext'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; -import { Location, withRouter } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { AppState } from '../../../types/appstate'; import { Permission, PermissionTemplate } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx index bce7c1cc2d8..1b5f437449a 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; import { useComponent, @@ -30,7 +31,6 @@ import { getHistoryMetrics, isCustomGraph, } from '../../../components/activity-graph/utils'; -import { useLocation, useRouter } from '../../../components/hoc/withRouter'; import { parseDate } from '../../../helpers/dates'; import useApplicationLeakQuery from '../../../queries/applications'; import { useBranchesQuery } from '../../../queries/branch'; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts b/server/sonar-web/src/main/js/apps/projectActivity/utils.ts index 171b70d1efe..214e0322146 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts +++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.ts @@ -19,6 +19,7 @@ */ import { startOfDay } from 'date-fns'; import { isEqual, uniq } from 'lodash'; +import { RawQuery } from '~sonar-aligned/types/router'; import { DEFAULT_GRAPH } from '../../components/activity-graph/utils'; import { parseDate } from '../../helpers/dates'; import { MEASURES_REDIRECTION } from '../../helpers/measures'; @@ -33,7 +34,7 @@ import { } from '../../helpers/query'; import { MetricKey } from '../../types/metrics'; import { GraphType, ParsedAnalysis } from '../../types/project-activity'; -import { Dict, RawQuery } from '../../types/types'; +import { Dict } from '../../types/types'; export interface Query { category: string; diff --git a/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx b/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx index ee777e8da5d..8da90b6c0dd 100644 --- a/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx +++ b/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx @@ -20,10 +20,11 @@ import { DangerButtonPrimary, addGlobalSuccessMessage } from 'design-system'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Router } from '~sonar-aligned/types/router'; import { deleteApplication } from '../../api/application'; import { deletePortfolio, deleteProject } from '../../api/project-management'; import ConfirmButton from '../../components/controls/ConfirmButton'; -import { Router, withRouter } from '../../components/hoc/withRouter'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { isApplication, isPortfolioLike } from '../../types/component'; import { Component } from '../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/projectInformation/badges/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/projectInformation/badges/__tests__/utils-test.ts index bc62bf78127..54e6db99d16 100644 --- a/server/sonar-web/src/main/js/apps/projectInformation/badges/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/projectInformation/badges/__tests__/utils-test.ts @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { Location } from '../../../../components/hoc/withRouter'; +import { Location } from '~sonar-aligned/types/router'; import { BadgeOptions, BadgeType, getBadgeSnippet, getBadgeUrl } from '../utils'; jest.mock('../../../../helpers/urls', () => ({ diff --git a/server/sonar-web/src/main/js/apps/projectKey/ProjectKeyApp.tsx b/server/sonar-web/src/main/js/apps/projectKey/ProjectKeyApp.tsx index 19d288117fb..d7bb648fc4b 100644 --- a/server/sonar-web/src/main/js/apps/projectKey/ProjectKeyApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectKey/ProjectKeyApp.tsx @@ -20,10 +20,11 @@ import { LargeCenteredLayout, PageContentFontWrapper, Title } from 'design-system'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Router } from '~sonar-aligned/types/router'; import { changeKey } from '../../api/components'; import RecentHistory from '../../app/components/RecentHistory'; import withComponentContext from '../../app/components/componentContext/withComponentContext'; -import { Router, withRouter } from '../../components/hoc/withRouter'; import { translate } from '../../helpers/l10n'; import { Component } from '../../types/types'; import UpdateForm from './UpdateForm'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx index 97500dae71d..738c3cbaf5f 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx @@ -31,13 +31,14 @@ import { keyBy, mapValues, omitBy, pick } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { useSearchParams } from 'react-router-dom'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, RawQuery, Router } from '~sonar-aligned/types/router'; import { searchProjects } from '../../../api/components'; import withAppStateContext from '../../../app/components/app-state/withAppStateContext'; import withCurrentUserContext from '../../../app/components/current-user/withCurrentUserContext'; import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget'; import ScreenPositionHelper from '../../../components/common/ScreenPositionHelper'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import '../../../components/search-navigator.css'; import handleRequiredAuthentication from '../../../helpers/handleRequiredAuthentication'; import { translate } from '../../../helpers/l10n'; @@ -46,7 +47,6 @@ import { isDefined } from '../../../helpers/types'; import { AppState } from '../../../types/appstate'; import { ComponentQualifier } from '../../../types/component'; import { MetricKey } from '../../../types/metrics'; -import { RawQuery } from '../../../types/types'; import { CurrentUser, isLoggedIn } from '../../../types/users'; import { Query, hasFilterParams, parseUrlQuery } from '../query'; import '../styles.css'; 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 e3787b1a6e2..a2ad67b9f0c 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 @@ -19,12 +19,13 @@ */ import { ButtonSecondary } from 'design-system'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; import { throwGlobalError } from '~sonar-aligned/helpers/error'; +import { Router } from '~sonar-aligned/types/router'; import { getComponentNavigation } from '../../../api/navigation'; import withAppStateContext from '../../../app/components/app-state/withAppStateContext'; import withCurrentUserContext from '../../../app/components/current-user/withCurrentUserContext'; import CreateApplicationForm from '../../../app/components/extensions/CreateApplicationForm'; -import { Router, withRouter } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { getComponentAdminUrl, getComponentOverviewUrl } from '../../../helpers/urls'; import { hasGlobalPermission } from '../../../helpers/users'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx b/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx index 4b717d9ecb6..5fb41e705e1 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx @@ -19,9 +19,9 @@ */ import * as React from 'react'; import { useNavigate } from 'react-router-dom'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import { searchProjects } from '../../../api/components'; import withCurrentUserContext from '../../../app/components/current-user/withCurrentUserContext'; -import { useLocation } from '../../../components/hoc/withRouter'; import { get } from '../../../helpers/storage'; import { hasGlobalPermission } from '../../../helpers/users'; import { CurrentUser, isLoggedIn } from '../../../types/users'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/EmptyFavoriteSearch.tsx b/server/sonar-web/src/main/js/apps/projects/components/EmptyFavoriteSearch.tsx index 9d1faa3e990..f31d32c87cf 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/EmptyFavoriteSearch.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/EmptyFavoriteSearch.tsx @@ -20,8 +20,8 @@ import { FishVisual, Highlight, StandoutLink } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { translate } from '../../../helpers/l10n'; -import { queryToSearch } from '../../../helpers/urls'; import { Dict } from '../../../types/types'; import { Query } from '../query'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx b/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx index fca28425603..93d52649d90 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx @@ -19,7 +19,8 @@ */ import { ButtonPrimary, FishVisual, Highlight } from 'design-system'; import * as React from 'react'; -import { Router, withRouter } from '../../../components/hoc/withRouter'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Router } from '~sonar-aligned/types/router'; import { translate } from '../../../helpers/l10n'; import { hasGlobalPermission } from '../../../helpers/users'; import { Permissions } from '../../../types/permissions'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx index 58c37097330..85b7d5b5e78 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx @@ -19,8 +19,8 @@ */ import { ToggleButton } from 'design-system'; import * as React from 'react'; +import { withRouter, WithRouterProps } from '~sonar-aligned/components/hoc/withRouter'; import withCurrentUserContext from '../../../app/components/current-user/withCurrentUserContext'; -import { withRouter, WithRouterProps } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { save } from '../../../helpers/storage'; import { CurrentUser, isLoggedIn } from '../../../types/users'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx index af495b13897..4f939c92d32 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx @@ -19,10 +19,10 @@ */ import { InputSearch, LightLabel, LightPrimary } from 'design-system'; import * as React from 'react'; +import { RawQuery } from '~sonar-aligned/types/router'; import HomePageSelect from '../../../components/controls/HomePageSelect'; import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; -import { RawQuery } from '../../../types/types'; import { CurrentUser, isLoggedIn } from '../../../types/users'; import ApplicationCreation from './ApplicationCreation'; import PerspectiveSelect from './PerspectiveSelect'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx index 393d73cb013..f598577b81a 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx @@ -20,8 +20,9 @@ import { BasicSeparator, DangerButtonSecondary, StyledPageTitle } from 'design-system'; import { flatMap } from 'lodash'; import * as React from 'react'; +import { RawQuery } from '~sonar-aligned/types/router'; import { translate } from '../../../helpers/l10n'; -import { Dict, RawQuery } from '../../../types/types'; +import { Dict } from '../../../types/types'; import CoverageFilter from '../filters/CoverageFilter'; import DuplicationsFilter from '../filters/DuplicationsFilter'; import LanguagesFilter from '../filters/LanguagesFilter'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenuItem.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenuItem.tsx index 85e45472453..6b47f36b6d2 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenuItem.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenuItem.tsx @@ -20,9 +20,9 @@ import { ItemLink } from 'design-system'; import * as React from 'react'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { Image } from '../../../components/common/Image'; import { translate } from '../../../helpers/l10n'; -import { queryToSearch } from '../../../helpers/urls'; import { AlmKeys } from '../../../types/alm-settings'; export interface ProjectCreationMenuItemProps { diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/CreateApplication-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/CreateApplication-test.tsx index a0715208b1c..b27d521398a 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/CreateApplication-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/CreateApplication-test.tsx @@ -19,12 +19,12 @@ */ import userEvent from '@testing-library/user-event'; import * as React from 'react'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { createApplication } from '../../../../api/application'; import { getComponentNavigation } from '../../../../api/navigation'; import { mockAppState, mockLoggedInUser, mockRouter } from '../../../../helpers/testMocks'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; import { byRole, byText } from '../../../../helpers/testSelector'; -import { queryToSearch } from '../../../../helpers/urls'; import { ComponentQualifier, Visibility } from '../../../../types/component'; import { FCProps } from '../../../../types/misc'; import { LoggedInUser } from '../../../../types/users'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx index d2d7d8ceffc..054d0c39570 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx @@ -20,8 +20,8 @@ import { render, screen } from '@testing-library/react'; import * as React from 'react'; import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import { searchProjects } from '../../../../api/components'; -import { useLocation } from '../../../../components/hoc/withRouter'; import { get } from '../../../../helpers/storage'; import { mockCurrentUser, mockLoggedInUser } from '../../../../helpers/testMocks'; import { hasGlobalPermission } from '../../../../helpers/users'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx index 4697482312e..73f4796e5a1 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx @@ -19,10 +19,10 @@ */ import { CoverageIndicator } from 'design-system'; import * as React from 'react'; +import { RawQuery } from '~sonar-aligned/types/router'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getCoverageRatingAverageValue, getCoverageRatingLabel } from '../../../helpers/ratings'; import { MetricKey } from '../../../types/metrics'; -import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import RangeFacetBase from './RangeFacetBase'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx index 964020f6985..cada4bc8483 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx @@ -19,9 +19,9 @@ */ import { DuplicationsIndicator } from 'design-system'; import * as React from 'react'; +import { RawQuery } from '~sonar-aligned/types/router'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { duplicationValueToRating, getDuplicationsRatingLabel } from '../../../helpers/ratings'; -import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import RangeFacetBase from './RangeFacetBase'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx index 94ad678d7fd..95be64a967f 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx @@ -19,11 +19,12 @@ */ import { uniqBy } from 'lodash'; import * as React from 'react'; +import { RawQuery } from '~sonar-aligned/types/router'; import withLanguagesContext from '../../../app/components/languages/withLanguagesContext'; import { translate } from '../../../helpers/l10n'; import { highlightTerm } from '../../../helpers/search'; import { Language, Languages } from '../../../types/languages'; -import { Dict, RawQuery } from '../../../types/types'; +import { Dict } from '../../../types/types'; import { ListStyleFacet } from '../../issues/sidebar/ListStyleFacet'; import { Facet } from '../types'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx index f4112f04ab9..b383a368fd3 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { RawQuery } from '../../../types/types'; +import { RawQuery } from '~sonar-aligned/types/router'; import { Facet } from '../types'; import RatingFacet from './RatingFacet'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx index 4ff410e104e..4bc25a02e0f 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx @@ -18,10 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { RawQuery } from '~sonar-aligned/types/router'; import { translate } from '../../../helpers/l10n'; import { getSizeRatingLabel } from '../../../helpers/ratings'; import { MetricKey } from '../../../types/metrics'; -import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import RangeFacetBase from './RangeFacetBase'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx index f0a77f52f81..7ecdbd101ab 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { RawQuery } from '../../../types/types'; +import { RawQuery } from '~sonar-aligned/types/router'; import { Facet } from '../types'; import RatingFacet from './RatingFacet'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx index 73a6a35bb55..ab38d55005c 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { RawQuery } from '../../../types/types'; +import { RawQuery } from '~sonar-aligned/types/router'; import { Facet } from '../types'; import RatingFacet from './RatingFacet'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx index bcfd064aafc..43bded56cec 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { RawQuery } from '../../../types/types'; +import { RawQuery } from '~sonar-aligned/types/router'; import { Facet } from '../types'; import RatingFacet from './RatingFacet'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/QualifierFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/QualifierFilter.tsx index 99ad08c449c..561806853bb 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/QualifierFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/QualifierFilter.tsx @@ -19,10 +19,10 @@ */ import { FacetBox, FacetItem } from 'design-system'; import * as React from 'react'; +import { RawQuery } from '~sonar-aligned/types/router'; import { translate } from '../../../helpers/l10n'; import { isDefined } from '../../../helpers/types'; import { ComponentQualifier } from '../../../types/component'; -import { RawQuery } from '../../../types/types'; import { FacetItemsList } from '../../issues/sidebar/FacetItemsList'; import { formatFacetStat } from '../../issues/utils'; import { Facet } from '../types'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx index 43eae115217..0d7bf5234bd 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx @@ -21,9 +21,10 @@ import { FacetBox, FacetItem, HelperHintIcon, QualityGateIndicator } from 'desig import { without } from 'lodash'; import * as React from 'react'; import HelpTooltip from '~sonar-aligned/components/controls/HelpTooltip'; +import { RawQuery } from '~sonar-aligned/types/router'; import { translate } from '../../../helpers/l10n'; import { isDefined } from '../../../helpers/types'; -import { RawQuery, Status } from '../../../types/types'; +import { Status } from '../../../types/types'; import { FacetItemsList } from '../../issues/sidebar/FacetItemsList'; import { formatFacetStat } from '../../issues/utils'; import { Facet } from '../types'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/RangeFacetBase.tsx b/server/sonar-web/src/main/js/apps/projects/filters/RangeFacetBase.tsx index 3e683acee77..e11d3046248 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/RangeFacetBase.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/RangeFacetBase.tsx @@ -20,9 +20,9 @@ import classNames from 'classnames'; import { FacetBox, FacetItem, HighlightedFacetItems, LightLabel } from 'design-system'; import * as React from 'react'; +import { RawQuery } from '~sonar-aligned/types/router'; import { translate } from '../../../helpers/l10n'; import { isDefined } from '../../../helpers/types'; -import { RawQuery } from '../../../types/types'; import { FacetItemsList } from '../../issues/sidebar/FacetItemsList'; import { formatFacetStat } from '../../issues/utils'; import { Facet } from '../types'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/RatingFacet.tsx b/server/sonar-web/src/main/js/apps/projects/filters/RatingFacet.tsx index 9fd89a2fb4d..fe816e6f24f 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/RatingFacet.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/RatingFacet.tsx @@ -20,9 +20,9 @@ import { MetricsRatingBadge, RatingEnum } from 'design-system'; import * as React from 'react'; import { formatMeasure } from '~sonar-aligned/helpers/measures'; +import { RawQuery } from '~sonar-aligned/types/router'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { MetricType } from '../../../types/metrics'; -import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import RangeFacetBase from './RangeFacetBase'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx index 0bb65a005e3..82f29a5f837 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { RawQuery } from '../../../types/types'; +import { RawQuery } from '~sonar-aligned/types/router'; import { Facet } from '../types'; import RatingFacet from './RatingFacet'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx index 6a0ee55f8f0..1adb18ec05d 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { RawQuery } from '../../../types/types'; +import { RawQuery } from '~sonar-aligned/types/router'; import { Facet } from '../types'; import RatingFacet from './RatingFacet'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SecurityReviewFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SecurityReviewFilter.tsx index 99f97f9221a..45350adbac8 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SecurityReviewFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SecurityReviewFilter.tsx @@ -20,9 +20,10 @@ import { MetricsRatingBadge, RatingEnum } from 'design-system'; import * as React from 'react'; import { formatMeasure } from '~sonar-aligned/helpers/measures'; +import { RawQuery } from '~sonar-aligned/types/router'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { MetricType } from '../../../types/metrics'; -import { Dict, RawQuery } from '../../../types/types'; +import { Dict } from '../../../types/types'; import { Facet } from '../types'; import RangeFacetBase from './RangeFacetBase'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx index fe5e316dbe7..33ff77ced18 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx @@ -19,9 +19,9 @@ */ import { SizeIndicator } from 'design-system'; import * as React from 'react'; +import { RawQuery } from '~sonar-aligned/types/router'; import { translate } from '../../../helpers/l10n'; import { getSizeRatingAverageValue, getSizeRatingLabel } from '../../../helpers/ratings'; -import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import RangeFacetBase from './RangeFacetBase'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx index 1892f732949..44e54f6a8f2 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx @@ -19,11 +19,12 @@ */ import { size } from 'lodash'; import * as React from 'react'; +import { RawQuery } from '~sonar-aligned/types/router'; import { searchProjectTags } from '../../../api/components'; -import { ListStyleFacet } from '../../../apps/issues/sidebar/ListStyleFacet'; import { translate } from '../../../helpers/l10n'; import { highlightTerm } from '../../../helpers/search'; -import { Dict, RawQuery } from '../../../types/types'; +import { Dict } from '../../../types/types'; +import { ListStyleFacet } from '../../issues/sidebar/ListStyleFacet'; import { Facet } from '../types'; interface Props { diff --git a/server/sonar-web/src/main/js/apps/projects/query.ts b/server/sonar-web/src/main/js/apps/projects/query.ts index f1a039b03e2..978b0991430 100644 --- a/server/sonar-web/src/main/js/apps/projects/query.ts +++ b/server/sonar-web/src/main/js/apps/projects/query.ts @@ -17,8 +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 { RawQuery } from '~sonar-aligned/types/router'; import { ComponentQualifier } from '../../types/component'; -import { Dict, RawQuery } from '../../types/types'; +import { Dict } from '../../types/types'; type Level = 'ERROR' | 'WARN' | 'OK'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx index 8e85a55c22a..ee09f47d308 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx @@ -19,7 +19,7 @@ */ import { ButtonPrimary, FormField, InputField, Modal } from 'design-system'; import * as React from 'react'; -import { useRouter } from '../../../components/hoc/withRouter'; +import { useRouter } from '~sonar-aligned/components/hoc/withRouter'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; import { getQualityGateUrl } from '../../../helpers/urls'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/CreateQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/CreateQualityGateForm.tsx index 1f774a239f1..05d5ddc3f1c 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/CreateQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/CreateQualityGateForm.tsx @@ -19,7 +19,7 @@ */ import { ButtonSecondary, FormField, InputField, Modal } from 'design-system'; import * as React from 'react'; -import { useRouter } from '../../../components/hoc/withRouter'; +import { useRouter } from '~sonar-aligned/components/hoc/withRouter'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; import { getQualityGateUrl } from '../../../helpers/urls'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx index eda9ced21e1..3c92d5e320a 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx @@ -19,7 +19,7 @@ */ import { DangerButtonPrimary, Modal } from 'design-system'; import * as React from 'react'; -import { useRouter } from '../../../components/hoc/withRouter'; +import { useRouter } from '~sonar-aligned/components/hoc/withRouter'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getQualityGatesUrl } from '../../../helpers/urls'; import { useDeleteQualityGateMutation } from '../../../queries/quality-gates'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx index cf7bdcea560..49977a45bc0 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx @@ -20,7 +20,7 @@ import { ButtonPrimary, FormField, InputField, Modal } from 'design-system'; import * as React from 'react'; -import { useRouter } from '../../../components/hoc/withRouter'; +import { useRouter } from '~sonar-aligned/components/hoc/withRouter'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; import { getQualityGateUrl } from '../../../helpers/urls'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx index 230e0c86b99..1680149c4ab 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx @@ -19,8 +19,9 @@ */ import { ButtonSecondary, Spinner } from 'design-system'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, Router } from '~sonar-aligned/types/router'; import { ChangelogResponse, getProfileChangelog } from '../../../api/quality-profiles'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import { parseDate, toISO8601WithOffsetString } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; import { withQualityProfilesContext } from '../qualityProfilesContext'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx index 4732e7ce6db..aed914a746c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx @@ -19,7 +19,7 @@ */ import { Spinner } from 'design-system'; import * as React from 'react'; -import { useLocation, useRouter } from '../../../components/hoc/withRouter'; +import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter'; import { useProfilesCompareQuery } from '../../../queries/quality-profiles'; import { useGetValueQuery } from '../../../queries/settings'; import { SettingsKey } from '../../../types/settings'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx index d463b47f6cd..92132eabcb1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx @@ -30,6 +30,8 @@ import { } from 'design-system'; import { some } from 'lodash'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Router } from '~sonar-aligned/types/router'; import { changeProfileParent, copyProfile, @@ -38,7 +40,6 @@ import { renameProfile, setDefaultProfile, } from '../../../api/quality-profiles'; -import { Router, withRouter } from '../../../components/hoc/withRouter'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/system'; import { getRulesUrl } from '../../../helpers/urls'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx index 04ead9dd627..0aef030ff90 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx @@ -20,7 +20,7 @@ import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { Outlet, useSearchParams } from 'react-router-dom'; -import { useLocation } from '../../../components/hoc/withRouter'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import ProfileHeader from '../details/ProfileHeader'; import { useQualityProfilesContext } from '../qualityProfilesContext'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.tsx index c82c1e5b429..615ce883cf3 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.tsx @@ -20,7 +20,7 @@ import { Badge, Breadcrumbs, HoverLink, Link, PageContentFontWrapper } from 'design-system'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; -import { useLocation } from '../../../components/hoc/withRouter'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import DateFromNow from '../../../components/intl/DateFromNow'; import { AdminPageHeader } from '../../../components/ui/AdminPageHeader'; import { translate, translateWithParameters } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx index 42cda967548..de64d5e3cef 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx @@ -37,13 +37,13 @@ import * as React from 'react'; import { useRef } from 'react'; import { useIntl } from 'react-intl'; import { SingleValue } from 'react-select'; +import { Location } from '~sonar-aligned/types/router'; import { changeProfileParent, copyProfile, createQualityProfile, getImporters, } from '../../../api/quality-profiles'; -import { Location } from '../../../components/hoc/withRouter'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { parseAsOptionalString } from '../../../helpers/query'; import { useProfileInheritanceQuery } from '../../../queries/quality-profiles'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/LanguageSelect.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/LanguageSelect.tsx index 5afa7fd15c6..13ba07cab46 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/LanguageSelect.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/LanguageSelect.tsx @@ -20,7 +20,7 @@ import { LabelValueSelectOption, SearchSelectDropdown } from 'design-system'; import * as React from 'react'; import { useIntl } from 'react-intl'; -import { useRouter } from '../../../components/hoc/withRouter'; +import { useRouter } from '~sonar-aligned/components/hoc/withRouter'; import { PROFILE_PATH } from '../constants'; import { getProfilesForLanguagePath } from '../utils'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx index e8e267ac792..6edfcedc602 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx @@ -20,8 +20,8 @@ import { ButtonPrimary, ButtonSecondary, FlagMessage, Link } from 'design-system'; import * as React from 'react'; import { useIntl } from 'react-intl'; +import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter'; import { Actions } from '../../../api/quality-profiles'; -import { useLocation, useRouter } from '../../../components/hoc/withRouter'; import { useDocUrl } from '../../../helpers/docs'; import { translate } from '../../../helpers/l10n'; import { Profile } from '../types'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/qualityProfilesContext.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/qualityProfilesContext.tsx index 307f0b0167f..d6d3a5e4e84 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/qualityProfilesContext.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/qualityProfilesContext.tsx @@ -19,10 +19,10 @@ */ import React from 'react'; import { useOutletContext } from 'react-router-dom'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { Actions } from '../../api/quality-profiles'; -import { Exporter, Profile } from '../../apps/quality-profiles/types'; -import { getWrappedDisplayName } from '../../components/hoc/utils'; import { Language } from '../../types/languages'; +import { Exporter, Profile } from './types'; export interface QualityProfilesContextProps { actions: Actions; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts b/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts index 1e8a6bd0c73..77e0af58ed4 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts +++ b/server/sonar-web/src/main/js/apps/quality-profiles/utils.ts @@ -19,9 +19,9 @@ */ import { differenceInYears } from 'date-fns'; import { sortBy } from 'lodash'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { Profile as BaseProfile } from '../../api/quality-profiles'; import { isValidDate, parseDate } from '../../helpers/dates'; -import { queryToSearch } from '../../helpers/urls'; import { PROFILE_COMPARE_PATH, PROFILE_PATH } from './constants'; import { Profile } from './types'; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx index c0ab9f2e220..c7a59014fd6 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx @@ -20,13 +20,14 @@ import { flatMap, range } from 'lodash'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; +import { Location, Router } from '~sonar-aligned/types/router'; import { getMeasures } from '../../api/measures'; import { getSecurityHotspotList, getSecurityHotspots } from '../../api/security-hotspots'; import withComponentContext from '../../app/components/componentContext/withComponentContext'; import withCurrentUserContext from '../../app/components/current-user/withCurrentUserContext'; import withIndexationGuard from '../../components/hoc/withIndexationGuard'; -import { Location, Router, withRouter } from '../../components/hoc/withRouter'; import { getLeakValue } from '../../components/measure/utils'; import { isPullRequest, isSameBranchLike } from '../../helpers/branch-like'; import { isInput } from '../../helpers/keyboardEventHelpers'; diff --git a/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx b/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx index ab22b747608..c5f6dd41bbe 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx @@ -30,8 +30,8 @@ import { } from 'design-system'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; +import { Location } from '~sonar-aligned/types/router'; import { Image } from '../../../components/common/Image'; -import { Location } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { sanitizeUserInput } from '../../../helpers/sanitize'; import { getReturnUrl } from '../../../helpers/urls'; diff --git a/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx b/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx index ffa535c4ab3..6340b62f60f 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx @@ -20,10 +20,11 @@ import { addGlobalErrorMessage } from 'design-system'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location } from '~sonar-aligned/types/router'; import { logIn } from '../../../api/auth'; import { getLoginMessage } from '../../../api/settings'; import { getIdentityProviders } from '../../../api/users'; -import { Location, withRouter } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { getReturnUrl } from '../../../helpers/urls'; import { IdentityProvider } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/Languages.tsx b/server/sonar-web/src/main/js/apps/settings/components/Languages.tsx index 2f449fd4a15..851c2ef1d13 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/Languages.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/Languages.tsx @@ -20,7 +20,8 @@ import { PopupZLevel, SearchSelectDropdown, SubHeading } from 'design-system'; import * as React from 'react'; import { Options } from 'react-select'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, Router } from '~sonar-aligned/types/router'; import { translate } from '../../../helpers/l10n'; import { CATEGORY_OVERRIDES, LANGUAGES_CATEGORY } from '../constants'; import { getCategoryName } from '../utils'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/SettingsAppRenderer.tsx b/server/sonar-web/src/main/js/apps/settings/components/SettingsAppRenderer.tsx index 81eb038cc9e..b93fae4b819 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/SettingsAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/SettingsAppRenderer.tsx @@ -22,8 +22,9 @@ import { LargeCenteredLayout, PageContentFontWrapper, themeBorder } from 'design import { uniqBy } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location } from '~sonar-aligned/types/router'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; -import { Location, withRouter } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { ExtendedSettingDefinition } from '../../../types/settings'; import { Component } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/SettingsSearch.tsx b/server/sonar-web/src/main/js/apps/settings/components/SettingsSearch.tsx index e91128e2d7a..9ae187d43b7 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/SettingsSearch.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/SettingsSearch.tsx @@ -20,7 +20,8 @@ import { debounce, keyBy } from 'lodash'; import lunr, { LunrIndex } from 'lunr'; import * as React from 'react'; -import { Router, withRouter } from '../../../components/hoc/withRouter'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Router } from '~sonar-aligned/types/router'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { ExtendedSettingDefinition } from '../../../types/settings'; import { Component, Dict } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx b/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx index c5e2614aecf..6ed1d1d1987 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx @@ -20,7 +20,8 @@ import { BasicSeparator, Note, SubTitle } from 'design-system'; import { groupBy, sortBy } from 'lodash'; import * as React from 'react'; -import { Location, withRouter } from '../../../components/hoc/withRouter'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location } from '~sonar-aligned/types/router'; import { sanitizeStringRestricted } from '../../../helpers/sanitize'; import { SettingDefinitionAndValue } from '../../../types/settings'; import { Component } from '../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx index b1c3c3c504c..4f60586bf1b 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx @@ -19,6 +19,8 @@ */ import { noop } from 'lodash'; import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, Router } from '~sonar-aligned/types/router'; import { countBoundProjects, deleteConfiguration, @@ -28,7 +30,6 @@ import { import withAvailableFeatures, { WithAvailableFeaturesProps, } from '../../../../app/components/available-features/withAvailableFeatures'; -import { Location, Router, withRouter } from '../../../../components/hoc/withRouter'; import { AlmBindingDefinitionBase, AlmKeys, diff --git a/server/sonar-web/src/main/js/apps/settings/components/authentication/Authentication.tsx b/server/sonar-web/src/main/js/apps/settings/components/authentication/Authentication.tsx index 5358118d64a..9ca2271d965 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/authentication/Authentication.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/authentication/Authentication.tsx @@ -24,12 +24,12 @@ import { FlagMessage, SubTitle, ToggleButton, getTabId, getTabPanelId } from 'de import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { useSearchParams } from 'react-router-dom'; +import { searchParamsToQuery } from '~sonar-aligned/helpers/router'; import withAvailableFeatures, { WithAvailableFeaturesProps, } from '../../../../app/components/available-features/withAvailableFeatures'; import { Image } from '../../../../components/common/Image'; import { translate } from '../../../../helpers/l10n'; -import { searchParamsToQuery } from '../../../../helpers/urls'; import { AlmKeys } from '../../../../types/alm-settings'; import { Feature } from '../../../../types/features'; import { ExtendedSettingDefinition } from '../../../../types/settings'; diff --git a/server/sonar-web/src/main/js/apps/system/components/SystemApp.tsx b/server/sonar-web/src/main/js/apps/system/components/SystemApp.tsx index 6afb506ca26..664c36e0cb5 100644 --- a/server/sonar-web/src/main/js/apps/system/components/SystemApp.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/SystemApp.tsx @@ -20,10 +20,11 @@ import { LargeCenteredLayout, PageContentFontWrapper } from 'design-system'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, Router } from '~sonar-aligned/types/router'; import { getSystemInfo } from '../../../api/system'; import UpdateNotification from '../../../app/components/update-notification/UpdateNotification'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { SysInfoCluster, SysInfoStandalone } from '../../../types/types'; import '../styles.css'; diff --git a/server/sonar-web/src/main/js/apps/system/utils.ts b/server/sonar-web/src/main/js/apps/system/utils.ts index edda3871235..7e5727e35c7 100644 --- a/server/sonar-web/src/main/js/apps/system/utils.ts +++ b/server/sonar-web/src/main/js/apps/system/utils.ts @@ -19,9 +19,9 @@ */ import { each, memoize, omit, omitBy, pickBy, sortBy } from 'lodash'; import { formatMeasure } from '~sonar-aligned/helpers/measures'; +import { RawQuery } from '~sonar-aligned/types/router'; import { cleanQuery, parseAsArray, parseAsString, serializeStringArray } from '../../helpers/query'; import { - RawQuery, SysInfoAppNode, SysInfoBase, SysInfoCluster, diff --git a/server/sonar-web/src/main/js/apps/users/utils.ts b/server/sonar-web/src/main/js/apps/users/utils.ts index a595f3c099f..419131862f5 100644 --- a/server/sonar-web/src/main/js/apps/users/utils.ts +++ b/server/sonar-web/src/main/js/apps/users/utils.ts @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { memoize } from 'lodash'; +import { RawQuery } from '~sonar-aligned/types/router'; import { cleanQuery, parseAsString, serializeString } from '../../helpers/query'; -import { RawQuery } from '../../types/types'; export interface Query { search: string; diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx b/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx index 017c0096f98..ba335923437 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx @@ -19,8 +19,8 @@ */ import { Badge, Card, LinkBox, LinkIcon, SubHeading, Tabs } from 'design-system'; import * as React from 'react'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { queryToSearch } from '../../../helpers/urls'; import { WebApi } from '../../../types/types'; import { getActionKey, serializeQuery } from '../utils'; import ActionChangelog from './ActionChangelog'; diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx b/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx index 5943362405d..4431c54f42f 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx @@ -20,7 +20,7 @@ import { SubnavigationGroup, SubnavigationItem } from 'design-system'; import * as React from 'react'; import { useNavigate } from 'react-router-dom'; -import { queryToSearch } from '../../../helpers/urls'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { WebApi } from '../../../types/types'; import { Query, actionsFilter, isDomainPathActive, serializeQuery } from '../utils'; import DeprecatedBadge from './DeprecatedBadge'; diff --git a/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx b/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx index e75cd5e728e..5cb0fd1201a 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx @@ -29,10 +29,11 @@ import { maxBy } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { Params, useParams } from 'react-router-dom'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location, Router } from '~sonar-aligned/types/router'; import { fetchWebApi } from '../../../api/web-api'; import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; -import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { WebApi } from '../../../types/types'; import '../styles/web-api.css'; diff --git a/server/sonar-web/src/main/js/apps/web-api/utils.ts b/server/sonar-web/src/main/js/apps/web-api/utils.ts index 538b00439b6..63fb68f4b3f 100644 --- a/server/sonar-web/src/main/js/apps/web-api/utils.ts +++ b/server/sonar-web/src/main/js/apps/web-api/utils.ts @@ -18,13 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { memoize } from 'lodash'; +import { RawQuery } from '~sonar-aligned/types/router'; import { cleanQuery, parseAsOptionalBoolean, parseAsString, serializeString, } from '../../helpers/query'; -import { RawQuery, WebApi } from '../../types/types'; +import { WebApi } from '../../types/types'; export interface Query { search: string; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts index a6f137121f5..4e7652255b6 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts @@ -18,10 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; +import { RawQuery } from '~sonar-aligned/types/router'; import { listIssues, searchIssues } from '../../../api/issues'; import { parseIssueFromResponse } from '../../../helpers/issues'; import { BranchLike } from '../../../types/branch-like'; -import { Issue, RawQuery } from '../../../types/types'; +import { Issue } from '../../../types/types'; import { DEFAULT_ISSUES_QUERY } from '../../shared/utils'; // maximum possible value diff --git a/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx b/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx index 9b242e469fa..3065ca26ae7 100644 --- a/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx +++ b/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx @@ -18,10 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import withCurrentUserContext from '../../app/components/current-user/withCurrentUserContext'; import handleRequiredAuthentication from '../../helpers/handleRequiredAuthentication'; import { CurrentUser, isLoggedIn } from '../../types/users'; -import { getWrappedDisplayName } from './utils'; export function whenLoggedIn

(WrappedComponent: React.ComponentType>) { class Wrapper extends React.Component

{ diff --git a/server/sonar-web/src/main/js/components/hoc/withCLanguageFeature.tsx b/server/sonar-web/src/main/js/components/hoc/withCLanguageFeature.tsx index c4a3f46f4be..135a77637bb 100644 --- a/server/sonar-web/src/main/js/components/hoc/withCLanguageFeature.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withCLanguageFeature.tsx @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { LanguagesContext } from '../../app/components/languages/LanguagesContext'; -import { getWrappedDisplayName } from './utils'; export function withCLanguageFeature

( WrappedComponent: React.ComponentType< diff --git a/server/sonar-web/src/main/js/components/hoc/withIndexationContext.tsx b/server/sonar-web/src/main/js/components/hoc/withIndexationContext.tsx index a8727277a0c..add93b45545 100644 --- a/server/sonar-web/src/main/js/components/hoc/withIndexationContext.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withIndexationContext.tsx @@ -18,9 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { IndexationContext } from '../../app/components/indexation/IndexationContext'; import { IndexationContextInterface } from '../../types/indexation'; -import { getWrappedDisplayName } from './utils'; export interface WithIndexationContextProps { indexationContext: IndexationContextInterface; diff --git a/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx b/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx index ed9bc1cdf3b..867e79c0dad 100644 --- a/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx @@ -18,11 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { getComponentMeasureUniqueKey } from '../../helpers/component'; import { isInput, isShortcut } from '../../helpers/keyboardEventHelpers'; import { KeyboardKeys } from '../../helpers/keycodes'; import { ComponentMeasure } from '../../types/types'; -import { getWrappedDisplayName } from './utils'; export interface WithKeyboardNavigationProps { components?: ComponentMeasure[]; diff --git a/server/sonar-web/src/main/js/components/hoc/withNotifications.tsx b/server/sonar-web/src/main/js/components/hoc/withNotifications.tsx index 5e96d0dcc1b..e1472c9ed4e 100644 --- a/server/sonar-web/src/main/js/components/hoc/withNotifications.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withNotifications.tsx @@ -19,13 +19,13 @@ */ import { uniqWith } from 'lodash'; import * as React from 'react'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; import { addNotification, getNotifications, removeNotification } from '../../api/notifications'; import { Notification, NotificationGlobalType, NotificationProjectType, } from '../../types/notifications'; -import { getWrappedDisplayName } from './utils'; interface State { channels: string[]; diff --git a/server/sonar-web/src/main/js/components/hoc/withScrollTo.tsx b/server/sonar-web/src/main/js/components/hoc/withScrollTo.tsx index 5578e86670f..73723ef90db 100644 --- a/server/sonar-web/src/main/js/components/hoc/withScrollTo.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withScrollTo.tsx @@ -19,7 +19,7 @@ */ import * as React from 'react'; import { findDOMNode } from 'react-dom'; -import { getWrappedDisplayName } from './utils'; +import { getWrappedDisplayName } from '~sonar-aligned/components/hoc/utils'; export interface WithScrollToProps { selected?: boolean; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx index f9a6771ba97..f3e26bb78a2 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx @@ -19,6 +19,7 @@ */ import { IssueMessageHighlighting, StandoutLink } from 'design-system'; import * as React from 'react'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like'; import { getComponentIssuesUrl } from '~sonar-aligned/helpers/urls'; import { ComponentContext } from '../../../app/components/componentContext/ComponentContext'; @@ -27,7 +28,6 @@ import { translate } from '../../../helpers/l10n'; import { getIssuesUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; import { Issue } from '../../../types/types'; -import { useLocation } from '../../hoc/withRouter'; export interface IssueMessageProps { issue: Issue; diff --git a/server/sonar-web/src/main/js/components/new-code-definition/NCDAutoUpdateMessage.tsx b/server/sonar-web/src/main/js/components/new-code-definition/NCDAutoUpdateMessage.tsx index e1e8dc53d1e..22d291acf67 100644 --- a/server/sonar-web/src/main/js/components/new-code-definition/NCDAutoUpdateMessage.tsx +++ b/server/sonar-web/src/main/js/components/new-code-definition/NCDAutoUpdateMessage.tsx @@ -20,11 +20,11 @@ import { Banner, Link } from 'design-system'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { MessageTypes, checkMessageDismissed, setMessageDismissed } from '../../api/messages'; import { CurrentUserContextInterface } from '../../app/components/current-user/CurrentUserContext'; import withCurrentUserContext from '../../app/components/current-user/withCurrentUserContext'; import { NEW_CODE_PERIOD_CATEGORY } from '../../apps/settings/constants'; -import { queryToSearch } from '../../helpers/urls'; import { useNewCodeDefinitionQuery } from '../../queries/newCodeDefinition'; import { Component } from '../../types/types'; import { diff --git a/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx b/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx index 920de7f5f4a..71e77125e2b 100644 --- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx @@ -18,6 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; +import { Location } from '~sonar-aligned/types/router'; import { getAlmSettingsNoCatch } from '../../api/alm-settings'; import { getScannableProjects } from '../../api/components'; import { getValue } from '../../api/settings'; @@ -29,7 +31,6 @@ import { Permissions } from '../../types/permissions'; import { SettingsKey } from '../../types/settings'; import { Component } from '../../types/types'; import { LoggedInUser } from '../../types/users'; -import { Location, withRouter } from '../hoc/withRouter'; import TutorialSelectionRenderer from './TutorialSelectionRenderer'; import { TutorialModes } from './types'; diff --git a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts index ee5c09bdd05..9baea69ab1d 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { searchParamsToQuery } from '~sonar-aligned/helpers/router'; import { getComponentIssuesUrl, getComponentSecurityHotspotsUrl, + queryToSearch, } from '~sonar-aligned/helpers/urls'; import { DEFAULT_ISSUES_QUERY } from '../../components/shared/utils'; import { AlmKeys } from '../../types/alm-settings'; @@ -47,8 +49,6 @@ import { getQualityGatesUrl, getReturnUrl, isRelativeUrl, - queryToSearch, - searchParamsToQuery, stripTrailingSlash, } from '../urls'; diff --git a/server/sonar-web/src/main/js/helpers/query.ts b/server/sonar-web/src/main/js/helpers/query.ts index cea27a09602..535bdbff08f 100644 --- a/server/sonar-web/src/main/js/helpers/query.ts +++ b/server/sonar-web/src/main/js/helpers/query.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { isEqual, isNil, omitBy } from 'lodash'; -import { RawQuery } from '../types/types'; +import { RawQuery } from '~sonar-aligned/types/router'; import { isValidDate, parseDate, toISO8601WithOffsetString, toShortISO8601String } from './dates'; export function queriesEqual(a: RawQuery, b: RawQuery): boolean { diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts index 313cb7f03bd..4e9f2400902 100644 --- a/server/sonar-web/src/main/js/helpers/testMocks.ts +++ b/server/sonar-web/src/main/js/helpers/testMocks.ts @@ -19,12 +19,12 @@ */ import { omit } from 'lodash'; import { To } from 'react-router-dom'; +import { Location, Router } from '~sonar-aligned/types/router'; import { CompareResponse } from '../api/quality-profiles'; import { RuleDescriptionSections } from '../apps/coding-rules/rule'; import { REST_RULE_KEYS_TO_OLD_KEYS } from '../apps/coding-rules/utils'; import { Exporter, Profile, ProfileChangelogEvent } from '../apps/quality-profiles/types'; import { LogsLevels } from '../apps/system/utils'; -import { Location, Router } from '../components/hoc/withRouter'; import { AppState } from '../types/appstate'; import { CleanCodeAttribute, @@ -592,9 +592,12 @@ export function mockRouter( goBack: jest.fn(), goForward: jest.fn(), isActive: jest.fn(), + navigate: jest.fn(), push: jest.fn(), replace: jest.fn(), + searchParams: new URLSearchParams(), setRouteLeaveHook: jest.fn(), + setSearchParams: jest.fn(), ...overrides, } as Router; } diff --git a/server/sonar-web/src/main/js/helpers/testReactTestingUtils.tsx b/server/sonar-web/src/main/js/helpers/testReactTestingUtils.tsx index b8e7bcf983d..2faaba061de 100644 --- a/server/sonar-web/src/main/js/helpers/testReactTestingUtils.tsx +++ b/server/sonar-web/src/main/js/helpers/testReactTestingUtils.tsx @@ -36,6 +36,7 @@ import { createRoutesFromElements, parsePath, } from 'react-router-dom'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import AdminContext from '../app/components/AdminContext'; import AppStateContextProvider from '../app/components/app-state/AppStateContextProvider'; import { AvailableFeaturesContext } from '../app/components/available-features/AvailableFeaturesContext'; @@ -44,7 +45,6 @@ import CurrentUserContextProvider from '../app/components/current-user/CurrentUs import IndexationContextProvider from '../app/components/indexation/IndexationContextProvider'; import { LanguagesContext } from '../app/components/languages/LanguagesContext'; import { MetricsContext } from '../app/components/metrics/MetricsContext'; -import { useLocation } from '../components/hoc/withRouter'; import { AppState } from '../types/appstate'; import { ComponentContextShape } from '../types/component'; import { Feature } from '../types/features'; diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts index 05053a9f659..ce1ce5d5710 100644 --- a/server/sonar-web/src/main/js/helpers/urls.ts +++ b/server/sonar-web/src/main/js/helpers/urls.ts @@ -17,16 +17,16 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { isArray, mapValues, omitBy } from 'lodash'; import { Path, To } from 'react-router-dom'; import { getBranchLikeQuery, isBranch, isMainBranch } from '~sonar-aligned/helpers/branch-like'; +import { queryToSearch } from '~sonar-aligned/helpers/urls'; import { getProfilePath } from '../apps/quality-profiles/utils'; import { DEFAULT_ISSUES_QUERY } from '../components/shared/utils'; import { BranchLike, BranchParameters } from '../types/branch-like'; import { ComponentQualifier, isApplication, isPortfolioLike } from '../types/component'; import { MeasurePageView } from '../types/measures'; import { GraphType } from '../types/project-activity'; -import { Dict, RawQuery } from '../types/types'; +import { Dict } from '../types/types'; import { HomePage } from '../types/users'; import { isPullRequest } from './branch-like'; import { serializeOptionalBoolean } from './query'; @@ -48,35 +48,6 @@ export type Query = Location['query']; const PROJECT_BASE_URL = '/dashboard'; -export function queryToSearch(query: RawQuery = {}) { - const arrayParams: Array<{ key: string; values: string[] }> = []; - - const stringParams = mapValues(query, (value, key) => { - // array values are added afterwards - if (isArray(value)) { - arrayParams.push({ key, values: value }); - return ''; - } - - return value != null ? `${value}` : ''; - }); - const filteredParams = omitBy(stringParams, (v: string) => v.length === 0); - const searchParams = new URLSearchParams(filteredParams); - - /* - * Add each value separately - * e.g. author: ['a', 'b'] should be serialized as - * author=a&author=b - */ - arrayParams.forEach(({ key, values }) => { - values.forEach((value) => { - searchParams.append(key, value); - }); - }); - - return `?${searchParams.toString()}`; -} - export function getComponentOverviewUrl( componentKey: string, componentQualifier: ComponentQualifier | string, @@ -422,23 +393,6 @@ export function isRelativeUrl(url?: string): boolean { return Boolean(url && regex.test(url)); } -export function searchParamsToQuery(searchParams: URLSearchParams, omitKey: string[] = []) { - const result: RawQuery = {}; - - searchParams.forEach((value, key) => { - if (omitKey.includes(key)) { - return; - } - if (result[key]) { - result[key] = ([] as string[]).concat(result[key], value); - } else { - result[key] = value; - } - }); - - return result; -} - export function convertToTo(link: string | Location) { if (linkIsLocation(link)) { return { pathname: link.pathname, search: queryToSearch(link.query) } as Partial; diff --git a/server/sonar-web/src/main/js/queries/branch.tsx b/server/sonar-web/src/main/js/queries/branch.tsx index e8bd6e1b252..642f58db08f 100644 --- a/server/sonar-web/src/main/js/queries/branch.tsx +++ b/server/sonar-web/src/main/js/queries/branch.tsx @@ -22,7 +22,9 @@ import { debounce, flatten } from 'lodash'; import * as React from 'react'; import { useCallback, useContext } from 'react'; import { useSearchParams } from 'react-router-dom'; +import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import { isBranch } from '~sonar-aligned/helpers/branch-like'; +import { searchParamsToQuery } from '~sonar-aligned/helpers/router'; import { deleteBranch, deletePullRequest, @@ -35,10 +37,8 @@ import { import { dismissAnalysisWarning, getAnalysisStatus } from '../api/ce'; import { getQualityGateProjectStatus } from '../api/quality-gates'; import { AvailableFeaturesContext } from '../app/components/available-features/AvailableFeaturesContext'; -import { useLocation } from '../components/hoc/withRouter'; import { isPullRequest } from '../helpers/branch-like'; import { extractStatusConditionsFromProjectStatus } from '../helpers/qualityGates'; -import { searchParamsToQuery } from '../helpers/urls'; import { Branch, BranchLike } from '../types/branch-like'; import { isApplication, isPortfolioLike, isProject } from '../types/component'; import { Feature } from '../types/features'; diff --git a/server/sonar-web/src/main/js/components/hoc/__tests__/utils-test.ts b/server/sonar-web/src/main/js/sonar-aligned/components/hoc/__tests__/utils-test.ts similarity index 100% rename from server/sonar-web/src/main/js/components/hoc/__tests__/utils-test.ts rename to server/sonar-web/src/main/js/sonar-aligned/components/hoc/__tests__/utils-test.ts diff --git a/server/sonar-web/src/main/js/components/hoc/utils.ts b/server/sonar-web/src/main/js/sonar-aligned/components/hoc/utils.ts similarity index 97% rename from server/sonar-web/src/main/js/components/hoc/utils.ts rename to server/sonar-web/src/main/js/sonar-aligned/components/hoc/utils.ts index 8d1aa3556f7..48fa468256a 100644 --- a/server/sonar-web/src/main/js/components/hoc/utils.ts +++ b/server/sonar-web/src/main/js/sonar-aligned/components/hoc/utils.ts @@ -17,6 +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 React from 'react'; + export function getWrappedDisplayName

( WrappedComponent: React.ComponentType>, hocName: string, diff --git a/server/sonar-web/src/main/js/components/hoc/withRouter.tsx b/server/sonar-web/src/main/js/sonar-aligned/components/hoc/withRouter.tsx similarity index 79% rename from server/sonar-web/src/main/js/components/hoc/withRouter.tsx rename to server/sonar-web/src/main/js/sonar-aligned/components/hoc/withRouter.tsx index f3146e3d014..6fded2817b5 100644 --- a/server/sonar-web/src/main/js/components/hoc/withRouter.tsx +++ b/server/sonar-web/src/main/js/sonar-aligned/components/hoc/withRouter.tsx @@ -18,26 +18,19 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { useMemo } from 'react'; import { - Location as LocationRouter, Params, useLocation as useLocationRouter, useNavigate, useParams, + useSearchParams, } from 'react-router-dom'; -import { queryToSearch, searchParamsToQuery } from '../../helpers/urls'; -import { RawQuery } from '../../types/types'; +import { searchParamsToQuery } from '../../helpers/router'; +import { queryToSearch } from '../../helpers/urls'; +import { Location, Router } from '../../types/router'; import { getWrappedDisplayName } from './utils'; -export interface Location extends LocationRouter { - query: RawQuery; -} - -export interface Router { - replace: (location: string | Partial) => void; - push: (location: string | Partial) => void; -} - export interface WithRouterProps { location: Location; params: Params; @@ -47,7 +40,7 @@ export interface WithRouterProps { export function withRouter

>( WrappedComponent: React.ComponentType>, ): React.ComponentType>> { - function ComponentWithRouterProp(props: P) { + function ComponentWithRouterProp(props: Readonly

) { const router = useRouter(); const params = useParams(); const location = useLocation(); @@ -63,8 +56,9 @@ export function withRouter

>( export function useRouter() { const navigate = useNavigate(); + const [searchParams, setSearchParams] = useSearchParams(); - const router = React.useMemo( + return React.useMemo( () => ({ replace: (path: string | Partial) => { if ((path as Location).query) { @@ -78,15 +72,19 @@ export function useRouter() { } navigate(path); }, + navigate, + searchParams, + setSearchParams, }), - [navigate], + [navigate, searchParams, setSearchParams], ); - - return router; } export function useLocation() { const location = useLocationRouter(); - return { ...location, query: searchParamsToQuery(new URLSearchParams(location.search)) }; + return useMemo( + () => ({ ...location, query: searchParamsToQuery(new URLSearchParams(location.search)) }), + [location], + ); } diff --git a/server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/urls-test.ts b/server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/urls-test.ts new file mode 100644 index 00000000000..89b2961baf4 --- /dev/null +++ b/server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/urls-test.ts @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { queryToSearch } from '../urls'; + +describe('queryToSearch', () => { + it('should return query by default', () => { + expect(queryToSearch()).toBe('?'); + }); + + it('should return query with string values', () => { + expect(queryToSearch({ key: 'value' })).toBe('?key=value'); + }); + + it('should remove empty values', () => { + expect(queryToSearch({ key: 'value', anotherKey: '' })).toBe('?key=value'); + }); + + it('should return query with array values', () => { + expect(queryToSearch({ key: ['value1', 'value2'] })).toBe('?key=value1&key=value2'); + }); +}); diff --git a/server/sonar-web/src/main/js/sonar-aligned/helpers/router.ts b/server/sonar-web/src/main/js/sonar-aligned/helpers/router.ts new file mode 100644 index 00000000000..9ac3547627b --- /dev/null +++ b/server/sonar-web/src/main/js/sonar-aligned/helpers/router.ts @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { RawQuery } from '../types/router'; + +export function searchParamsToQuery(searchParams: URLSearchParams, omitKey: string[] = []) { + const result: RawQuery = {}; + + searchParams.forEach((value, key) => { + if (omitKey.includes(key)) { + return; + } + if (result[key]) { + result[key] = ([] as string[]).concat(result[key], value); + } else { + result[key] = value; + } + }); + + return result; +} diff --git a/server/sonar-web/src/main/js/sonar-aligned/helpers/urls.ts b/server/sonar-web/src/main/js/sonar-aligned/helpers/urls.ts index 363729eba2b..37ec03bef81 100644 --- a/server/sonar-web/src/main/js/sonar-aligned/helpers/urls.ts +++ b/server/sonar-web/src/main/js/sonar-aligned/helpers/urls.ts @@ -17,18 +17,46 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { pick } from 'lodash'; -import { Query, queryToSearch } from '../../helpers/urls'; - +import { isArray, mapValues, omitBy, pick } from 'lodash'; import { Path } from 'react-router-dom'; +import { Query } from '../../helpers/urls'; import { BranchLike } from '../../types/branch-like'; import { SecurityStandard } from '../../types/security'; -import { getBranchLikeQuery } from './branch-like'; +import { getBranchLikeQuery } from '../helpers/branch-like'; +import { RawQuery } from '../types/router'; + +export function queryToSearch(query: RawQuery = {}) { + const arrayParams: Array<{ key: string; values: string[] }> = []; + + const stringParams = mapValues(query, (value, key) => { + // array values are added afterwards + if (isArray(value)) { + arrayParams.push({ key, values: value }); + return ''; + } + + return value != null ? `${value}` : ''; + }); + const filteredParams = omitBy(stringParams, (v: string) => v.length === 0); + const searchParams = new URLSearchParams(filteredParams); + + /* + * Add each value separately + * e.g. author: ['a', 'b'] should be serialized as + * author=a&author=b + */ + arrayParams.forEach(({ key, values }) => { + values.forEach((value) => { + searchParams.append(key, value); + }); + }); + + return `?${searchParams.toString()}`; +} /** * Generate URL for a component's issues page */ - export function getComponentIssuesUrl(componentKey: string, query?: Query): Path { return { pathname: '/project/issues', @@ -40,7 +68,6 @@ export function getComponentIssuesUrl(componentKey: string, query?: Query): Path /** * Generate URL for a component's security hotspot page */ - export function getComponentSecurityHotspotsUrl( componentKey: string, branchLike?: BranchLike, diff --git a/server/sonar-web/src/main/js/sonar-aligned/types/router.ts b/server/sonar-web/src/main/js/sonar-aligned/types/router.ts new file mode 100644 index 00000000000..5043d5ab1e9 --- /dev/null +++ b/server/sonar-web/src/main/js/sonar-aligned/types/router.ts @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { + Location as LocationRouter, + NavigateFunction, + URLSearchParamsInit, +} from 'react-router-dom'; + +export type RawQuery = Record; + +export interface Location extends LocationRouter { + query: RawQuery; +} + +export interface Router { + navigate: NavigateFunction; + replace: (location: string | Partial) => void; + push: (location: string | Partial) => void; + searchParams: URLSearchParams; + setSearchParams: ( + nextInit: URLSearchParamsInit, + navigateOptions?: { replace?: boolean; state?: any }, + ) => void; +} diff --git a/server/sonar-web/src/main/js/types/extension.ts b/server/sonar-web/src/main/js/types/extension.ts index b6f5d72de02..bf6ba7f7de1 100644 --- a/server/sonar-web/src/main/js/types/extension.ts +++ b/server/sonar-web/src/main/js/types/extension.ts @@ -21,7 +21,7 @@ import { Theme } from '@emotion/react'; import { QueryClient } from '@tanstack/react-query'; import { IntlShape } from 'react-intl'; -import { Location, Router } from '../components/hoc/withRouter'; +import { Location, Router } from '~sonar-aligned/types/router'; import { AppState } from './appstate'; import { BranchLike } from './branch-like'; import { L10nBundle } from './l10nBundle'; diff --git a/server/sonar-web/src/main/js/types/types.ts b/server/sonar-web/src/main/js/types/types.ts index b4c6c827a3c..31874615a18 100644 --- a/server/sonar-web/src/main/js/types/types.ts +++ b/server/sonar-web/src/main/js/types/types.ts @@ -538,8 +538,6 @@ export interface QualityGate extends QualityGatePreview { caycStatus?: CaycStatus; } -export type RawQuery = Dict; - export interface Rule { cleanCodeAttributeCategory?: CleanCodeAttributeCategory; cleanCodeAttribute?: CleanCodeAttribute; -- 2.39.5