From: Viktor Vorona Date: Thu, 2 May 2024 13:19:58 +0000 (+0200) Subject: SONAR-22168 Align Component and mockComponent X-Git-Tag: 10.6.0.92116~145 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c56851e2ee25bebffd05980dcabd5ae31c8ee1a0;p=sonarqube.git SONAR-22168 Align Component and mockComponent --- diff --git a/server/sonar-web/build.gradle b/server/sonar-web/build.gradle index fa2fc83e024..cbb2a5b1b10 100644 --- a/server/sonar-web/build.gradle +++ b/server/sonar-web/build.gradle @@ -2,7 +2,7 @@ sonar { properties { property "sonar.projectName", "${projectTitle} :: Web" property "sonar.sources", "src/main/js" - property "sonar.exclusions", "src/main/js/**/__tests__/**,src/main/js/**/__mocks__/**,src/main/js/@types/**,src/main/js/helpers/mocks/**,src/main/js/api/mocks/**,src/main/js/helpers/testUtils.ts,src/main/js/helpers/testMocks.ts,src/main/js/helpers/testReactTestingUtils.tsx,src/main/js/helpers/testSelector.ts" + property "sonar.exclusions", "src/main/js/**/__tests__/**,src/main/js/**/__mocks__/**,src/main/js/@types/**,src/main/js/helpers/mocks/**,src/main/js/sonar-aligned/helpers/mocks/**,src/main/js/api/mocks/**,src/main/js/helpers/testUtils.ts,src/main/js/helpers/testMocks.ts,src/main/js/helpers/testReactTestingUtils.tsx,src/main/js/helpers/testSelector.ts" property "sonar.tests", "src/main/js" property "sonar.test.inclusions", "src/main/js/**/__tests__/**" property "sonar.coverage.exclusions", "src/main/js/api/**,src/main/js/**/routes.ts,src/main/js/app/index.ts,src/main/js/app/utils/startReactApp.tsx,src/main/js/components/icons/**" diff --git a/server/sonar-web/src/main/js/api/application.ts b/server/sonar-web/src/main/js/api/application.ts index 679961cfda1..aa60a842041 100644 --- a/server/sonar-web/src/main/js/api/application.ts +++ b/server/sonar-web/src/main/js/api/application.ts @@ -19,9 +19,9 @@ */ import { throwGlobalError } from '~sonar-aligned/helpers/error'; import { getJSON } from '~sonar-aligned/helpers/request'; +import { Visibility } from '~sonar-aligned/types/component'; import { post, postJSON } from '../helpers/request'; import { Application, ApplicationPeriod } from '../types/application'; -import { Visibility } from '../types/component'; export function getApplicationLeak( application: string, diff --git a/server/sonar-web/src/main/js/api/components.ts b/server/sonar-web/src/main/js/api/components.ts index a69392e7e9e..7c8ae1e2dc1 100644 --- a/server/sonar-web/src/main/js/api/components.ts +++ b/server/sonar-web/src/main/js/api/components.ts @@ -20,9 +20,9 @@ import { throwGlobalError } from '~sonar-aligned/helpers/error'; import { getJSON } from '~sonar-aligned/helpers/request'; import { BranchParameters } from '~sonar-aligned/types/branch-like'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; -import { post, RequestData } from '../helpers/request'; -import { TreeComponent, TreeComponentWithPath, Visibility } from '../types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; +import { RequestData, post } from '../helpers/request'; +import { TreeComponent, TreeComponentWithPath } from '../types/component'; import { ComponentMeasure, Dict, diff --git a/server/sonar-web/src/main/js/api/mocks/AlmIntegrationsServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/AlmIntegrationsServiceMock.ts index 6ba0e403484..33849598d1f 100644 --- a/server/sonar-web/src/main/js/api/mocks/AlmIntegrationsServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/AlmIntegrationsServiceMock.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { cloneDeep, uniqueId } from 'lodash'; +import { Visibility } from '~sonar-aligned/types/component'; import { mockAzureProject, mockAzureRepository, @@ -36,7 +37,6 @@ import { GithubRepository, GitlabProject, } from '../../types/alm-integration'; -import { Visibility } from '../../types/component'; import { Paging } from '../../types/types'; import { checkPersonalAccessTokenIsValid, diff --git a/server/sonar-web/src/main/js/api/mocks/ApplicationServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/ApplicationServiceMock.ts index bf84949827d..66203fbf897 100644 --- a/server/sonar-web/src/main/js/api/mocks/ApplicationServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/ApplicationServiceMock.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { cloneDeep } from 'lodash'; -import { Visibility } from '../../types/component'; +import { Visibility } from '~sonar-aligned/types/component'; import { getApplicationDetails, getApplicationLeak } from '../application'; jest.mock('../application'); diff --git a/server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts index 5806e296367..71cc1cbfe22 100644 --- a/server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts @@ -19,7 +19,7 @@ */ import { HttpStatusCode } from 'axios'; import { cloneDeep, countBy, pick, trim } from 'lodash'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { RuleDescriptionSections } from '../../apps/coding-rules/rule'; import { mapRestRuleToRule } from '../../apps/coding-rules/utils'; import { getStandards } from '../../helpers/security-standard'; @@ -31,7 +31,6 @@ import { mockRuleRepository, } from '../../helpers/testMocks'; import { RuleRepository, SearchRulesResponse } from '../../types/coding-rules'; -import { Visibility } from '../../types/component'; import { RawIssuesResponse } from '../../types/issues'; import { RuleStatus, SearchRulesQuery } from '../../types/rules'; import { SecurityStandard } from '../../types/security'; diff --git a/server/sonar-web/src/main/js/api/mocks/ComponentsServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/ComponentsServiceMock.ts index 2ca70ceb996..787556a810e 100644 --- a/server/sonar-web/src/main/js/api/mocks/ComponentsServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/ComponentsServiceMock.ts @@ -19,11 +19,12 @@ */ import { cloneDeep, pick } from 'lodash'; import { BranchParameters } from '~sonar-aligned/types/branch-like'; +import { Visibility } from '~sonar-aligned/types/component'; import { DEFAULT_METRICS } from '../../helpers/mocks/metrics'; import { HttpStatus, RequestData } from '../../helpers/request'; import { mockMetric } from '../../helpers/testMocks'; import { isDefined } from '../../helpers/types'; -import { TreeComponent, Visibility } from '../../types/component'; +import { TreeComponent } from '../../types/component'; import { Component, ComponentMeasure, diff --git a/server/sonar-web/src/main/js/api/mocks/PermissionsServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/PermissionsServiceMock.ts index 7c53a4da0f2..4236df00b27 100644 --- a/server/sonar-web/src/main/js/api/mocks/PermissionsServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/PermissionsServiceMock.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { chunk, cloneDeep, remove, uniq } from 'lodash'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { mockPermission, mockPermissionGroup, @@ -27,7 +27,6 @@ import { mockPermissionUser, } from '../../helpers/mocks/permissions'; import { PERMISSIONS_ORDER_FOR_PROJECT_TEMPLATE } from '../../helpers/permissions'; -import { Visibility } from '../../types/component'; import { Permissions } from '../../types/permissions'; import { Permission, PermissionGroup, PermissionTemplate, PermissionUser } from '../../types/types'; import { BaseSearchProjectsParameters } from '../components'; diff --git a/server/sonar-web/src/main/js/api/mocks/ProjectsManagementServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/ProjectsManagementServiceMock.ts index b6048242d6a..57c6ed0de05 100644 --- a/server/sonar-web/src/main/js/api/mocks/ProjectsManagementServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/ProjectsManagementServiceMock.ts @@ -18,9 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { cloneDeep } from 'lodash'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { mockProject } from '../../helpers/mocks/projects'; -import { Visibility } from '../../types/component'; import { SettingsKey } from '../../types/settings'; import { Project, diff --git a/server/sonar-web/src/main/js/api/mocks/data/projects.ts b/server/sonar-web/src/main/js/api/mocks/data/projects.ts index 966e6bae94d..fbffae15233 100644 --- a/server/sonar-web/src/main/js/api/mocks/data/projects.ts +++ b/server/sonar-web/src/main/js/api/mocks/data/projects.ts @@ -20,8 +20,7 @@ /* eslint-disable local-rules/use-metrickey-enum */ -import { ComponentQualifier } from '~sonar-aligned/types/component'; -import { Visibility } from '../../../types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { ComponentRaw } from '../../components'; export function mockProjects(): ComponentRaw[] { diff --git a/server/sonar-web/src/main/js/api/permissions.ts b/server/sonar-web/src/main/js/api/permissions.ts index e13899e8a1f..0dc048add92 100644 --- a/server/sonar-web/src/main/js/api/permissions.ts +++ b/server/sonar-web/src/main/js/api/permissions.ts @@ -19,8 +19,8 @@ */ import { throwGlobalError } from '~sonar-aligned/helpers/error'; import { getJSON } from '~sonar-aligned/helpers/request'; +import { Visibility } from '~sonar-aligned/types/component'; import { post, postJSON, RequestData } from '../helpers/request'; -import { Visibility } from '../types/component'; import { Paging, Permission, diff --git a/server/sonar-web/src/main/js/api/project-management.ts b/server/sonar-web/src/main/js/api/project-management.ts index 2cd0b6136bc..b86443c4729 100644 --- a/server/sonar-web/src/main/js/api/project-management.ts +++ b/server/sonar-web/src/main/js/api/project-management.ts @@ -19,9 +19,8 @@ */ import { throwGlobalError } from '~sonar-aligned/helpers/error'; import { getJSON } from '~sonar-aligned/helpers/request'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { post, postJSON } from '../helpers/request'; -import { Visibility } from '../types/component'; import { Paging } from '../types/types'; export interface BaseSearchProjectsParameters { 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 309d128a9f0..afd433e03e1 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 @@ -22,7 +22,7 @@ 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 { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { validateProjectAlmBinding } from '../../../api/alm-settings'; import { getTasksForComponent } from '../../../api/ce'; import { getComponentData } from '../../../api/components'; @@ -35,7 +35,6 @@ import { HttpStatus } from '../../../helpers/request'; import { renderAppRoutes, renderComponent } from '../../../helpers/testReactTestingUtils'; import { byRole, byText } from '../../../helpers/testSelector'; import { getProjectUrl, getPullRequestUrl } from '../../../helpers/urls'; -import { Visibility } from '../../../types/component'; import { TaskStatuses, TaskTypes } from '../../../types/tasks'; import handleRequiredAuthorization from '../../utils/handleRequiredAuthorization'; import ComponentContainer, { isSameBranch } from '../ComponentContainer'; diff --git a/server/sonar-web/src/main/js/app/components/extensions/CreateApplicationForm.tsx b/server/sonar-web/src/main/js/app/components/extensions/CreateApplicationForm.tsx index 74f8f67cafe..412f325edd5 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/CreateApplicationForm.tsx +++ b/server/sonar-web/src/main/js/app/components/extensions/CreateApplicationForm.tsx @@ -26,11 +26,10 @@ import { RadioButton, } from 'design-system'; import * as React from 'react'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { createApplication } from '../../../api/application'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; -import { Visibility } from '../../../types/component'; interface Props { onClose: () => void; diff --git a/server/sonar-web/src/main/js/apps/code/bucket.ts b/server/sonar-web/src/main/js/apps/code/bucket.ts index 75c7c87f4f9..9a3827b70a7 100644 --- a/server/sonar-web/src/main/js/apps/code/bucket.ts +++ b/server/sonar-web/src/main/js/apps/code/bucket.ts @@ -17,7 +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 { Breadcrumb, ComponentMeasure, Dict } from '../../types/types'; +import { Breadcrumb } from '~sonar-aligned/types/component'; +import { ComponentMeasure, Dict } from '../../types/types'; let bucket: Dict = {}; let childrenBucket: Dict<{ 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 a13db26792f..72e81423955 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 @@ -20,13 +20,13 @@ import * as React from 'react'; import { withRouter } from '~sonar-aligned/components/hoc/withRouter'; import { isPortfolioLike } from '~sonar-aligned/helpers/component'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { Breadcrumb, ComponentQualifier } from '~sonar-aligned/types/component'; import { Location, Router } from '~sonar-aligned/types/router'; import withComponentContext from '../../../app/components/componentContext/withComponentContext'; import withMetricsContext from '../../../app/components/metrics/withMetricsContext'; import { CodeScope, getCodeUrl, getProjectUrl } from '../../../helpers/urls'; import { WithBranchLikesProps, useBranchesQuery } from '../../../queries/branch'; -import { Breadcrumb, Component, ComponentMeasure, Dict, Metric } from '../../../types/types'; +import { Component, ComponentMeasure, Dict, Metric } from '../../../types/types'; import { addComponent, addComponentBreadcrumbs, clearBucket } from '../bucket'; import { loadMoreChildren, retrieveComponent, retrieveComponentChildren } from '../utils'; import CodeAppRenderer from './CodeAppRenderer'; 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 2724ae69aca..3f514a8e076 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 @@ -32,6 +32,7 @@ import { Helmet } from 'react-helmet-async'; import A11ySkipTarget from '~sonar-aligned/components/a11y/A11ySkipTarget'; import HelpTooltip from '~sonar-aligned/components/controls/HelpTooltip'; import { isPortfolioLike } from '~sonar-aligned/helpers/component'; +import { Breadcrumb } from '~sonar-aligned/types/component'; import { Location } from '~sonar-aligned/types/router'; import ListFooter from '../../../components/controls/ListFooter'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; @@ -42,7 +43,7 @@ import { translate } from '../../../helpers/l10n'; import { areCCTMeasuresComputed } from '../../../helpers/measures'; import { BranchLike } from '../../../types/branch-like'; import { isApplication } from '../../../types/component'; -import { Breadcrumb, Component, ComponentMeasure, Dict, Metric } from '../../../types/types'; +import { Component, ComponentMeasure, Dict, Metric } from '../../../types/types'; import { getCodeMetrics } from '../utils'; import CodeBreadcrumbs from './CodeBreadcrumbs'; import Components from './Components'; diff --git a/server/sonar-web/src/main/js/apps/code/components/CodeBreadcrumbs.tsx b/server/sonar-web/src/main/js/apps/code/components/CodeBreadcrumbs.tsx index a72965b31b0..91e44b3a0a7 100644 --- a/server/sonar-web/src/main/js/apps/code/components/CodeBreadcrumbs.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/CodeBreadcrumbs.tsx @@ -19,8 +19,9 @@ */ import { Breadcrumbs } from 'design-system'; import * as React from 'react'; +import { Breadcrumb } from '~sonar-aligned/types/component'; import { BranchLike } from '../../../types/branch-like'; -import { Breadcrumb, ComponentMeasure } from '../../../types/types'; +import { ComponentMeasure } from '../../../types/types'; import ComponentName from './ComponentName'; interface Props { diff --git a/server/sonar-web/src/main/js/apps/code/utils.ts b/server/sonar-web/src/main/js/apps/code/utils.ts index 31c82837035..69ca61edc07 100644 --- a/server/sonar-web/src/main/js/apps/code/utils.ts +++ b/server/sonar-web/src/main/js/apps/code/utils.ts @@ -19,12 +19,12 @@ */ import { getBranchLikeQuery, isPullRequest } from '~sonar-aligned/helpers/branch-like'; import { isPortfolioLike } from '~sonar-aligned/helpers/component'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { Breadcrumb, ComponentQualifier } from '~sonar-aligned/types/component'; import { MetricKey } from '~sonar-aligned/types/metrics'; import { getBreadcrumbs, getChildren, getComponent, getComponentData } from '../../api/components'; import { CCT_SOFTWARE_QUALITY_METRICS, OLD_TAXONOMY_METRICS } from '../../helpers/constants'; import { BranchLike } from '../../types/branch-like'; -import { Breadcrumb, ComponentMeasure } from '../../types/types'; +import { ComponentMeasure } from '../../types/types'; import { addComponent, addComponentBreadcrumbs, diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx index 4bc135d62bb..2f1bf24ba55 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx @@ -77,6 +77,7 @@ export function IssueSourceViewerHeader(props: Readonly) { const { data: branchData, isLoading: isLoadingBranches } = useBranchesQuery( component ?? { key: project, + name: projectName, qualifier: ComponentQualifier.Project, }, ); diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/PermissionsProjectApp.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/PermissionsProjectApp.tsx index 7cc89368bb6..b5b89e9db02 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/PermissionsProjectApp.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/PermissionsProjectApp.tsx @@ -21,6 +21,7 @@ import { LargeCenteredLayout, PageContentFontWrapper } from 'design-system'; import { noop, without } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; +import { Visibility } from '~sonar-aligned/types/component'; import * as api from '../../../../api/permissions'; import withComponentContext from '../../../../app/components/componentContext/withComponentContext'; import VisibilitySelector from '../../../../components/common/VisibilitySelector'; @@ -34,7 +35,7 @@ import { } from '../../../../helpers/permissions'; import { useIsGitHubProjectQuery } from '../../../../queries/devops-integration'; import { useGithubProvisioningEnabledQuery } from '../../../../queries/identity-provider/github'; -import { ComponentContextShape, Visibility } from '../../../../types/component'; +import { ComponentContextShape } from '../../../../types/component'; import { Permissions } from '../../../../types/permissions'; import { Component, Paging, PermissionGroup, PermissionUser } from '../../../../types/types'; import '../../styles.css'; diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/__tests__/PermissionsProject-it.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/__tests__/PermissionsProject-it.tsx index 5e4461aac92..6c048379bc7 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/__tests__/PermissionsProject-it.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/__tests__/PermissionsProject-it.tsx @@ -19,7 +19,7 @@ */ import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import AlmSettingsServiceMock from '../../../../../api/mocks/AlmSettingsServiceMock'; import GithubProvisioningServiceMock from '../../../../../api/mocks/GithubProvisioningServiceMock'; import PermissionsServiceMock from '../../../../../api/mocks/PermissionsServiceMock'; @@ -35,7 +35,7 @@ import { renderAppWithComponentContext, } from '../../../../../helpers/testReactTestingUtils'; import { AlmKeys } from '../../../../../types/alm-settings'; -import { ComponentContextShape, Visibility } from '../../../../../types/component'; +import { ComponentContextShape } from '../../../../../types/component'; import { Feature } from '../../../../../types/features'; import { Permissions } from '../../../../../types/permissions'; import { Component, PermissionGroup, PermissionUser, Provider } from '../../../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/permissions/test-utils.ts b/server/sonar-web/src/main/js/apps/permissions/test-utils.ts index 9bec30dc8bd..d382ec9e14d 100644 --- a/server/sonar-web/src/main/js/apps/permissions/test-utils.ts +++ b/server/sonar-web/src/main/js/apps/permissions/test-utils.ts @@ -20,8 +20,8 @@ import { waitFor } from '@testing-library/react'; import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; import selectEvent from 'react-select-event'; +import { Visibility } from '~sonar-aligned/types/component'; import { byRole, byText } from '../../helpers/testSelector'; -import { Visibility } from '../../types/component'; import { Permissions } from '../../types/permissions'; export function getPageObject(user: UserEvent) { diff --git a/server/sonar-web/src/main/js/apps/projectInformation/__tests__/ProjectInformationApp-it.tsx b/server/sonar-web/src/main/js/apps/projectInformation/__tests__/ProjectInformationApp-it.tsx index dabdddeda8f..7349466c79a 100644 --- a/server/sonar-web/src/main/js/apps/projectInformation/__tests__/ProjectInformationApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectInformation/__tests__/ProjectInformationApp-it.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { screen } from '@testing-library/react'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { MetricKey } from '~sonar-aligned/types/metrics'; import BranchesServiceMock from '../../../api/mocks/BranchesServiceMock'; import CodingRulesServiceMock from '../../../api/mocks/CodingRulesServiceMock'; @@ -31,7 +31,6 @@ import { mockComponent } from '../../../helpers/mocks/component'; import { mockCurrentUser, mockLoggedInUser, mockMeasure } from '../../../helpers/testMocks'; import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; import { byRole } from '../../../helpers/testSelector'; -import { Visibility } from '../../../types/component'; import { Component } from '../../../types/types'; import { CurrentUser } from '../../../types/users'; import routes from '../routes'; diff --git a/server/sonar-web/src/main/js/apps/projectInformation/about/AboutProject.tsx b/server/sonar-web/src/main/js/apps/projectInformation/about/AboutProject.tsx index 642955b8ca5..382bf84c832 100644 --- a/server/sonar-web/src/main/js/apps/projectInformation/about/AboutProject.tsx +++ b/server/sonar-web/src/main/js/apps/projectInformation/about/AboutProject.tsx @@ -20,10 +20,9 @@ import classNames from 'classnames'; import { BasicSeparator, SubTitle } from 'design-system'; import React, { PropsWithChildren, useEffect, useState } from 'react'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { getProjectLinks } from '../../../api/projectLinks'; import { translate } from '../../../helpers/l10n'; -import { Visibility } from '../../../types/component'; import { Component, Measure, ProjectLink } from '../../../types/types'; import MetaDescription from './components/MetaDescription'; import MetaKey from './components/MetaKey'; diff --git a/server/sonar-web/src/main/js/apps/projectInformation/about/components/MetaQualityProfiles.tsx b/server/sonar-web/src/main/js/apps/projectInformation/about/components/MetaQualityProfiles.tsx index 8153c194e7e..dc94c4d0417 100644 --- a/server/sonar-web/src/main/js/apps/projectInformation/about/components/MetaQualityProfiles.tsx +++ b/server/sonar-web/src/main/js/apps/projectInformation/about/components/MetaQualityProfiles.tsx @@ -19,13 +19,14 @@ */ import { Badge, Link, SubHeading } from 'design-system'; import React, { useContext, useEffect } from 'react'; +import { ComponentQualityProfile } from '~sonar-aligned/types/component'; import { searchRules } from '../../../../api/rules'; import { LanguagesContext } from '../../../../app/components/languages/LanguagesContext'; import Tooltip from '../../../../components/controls/Tooltip'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; import { getQualityProfileUrl } from '../../../../helpers/urls'; import { Languages } from '../../../../types/languages'; -import { ComponentQualityProfile, Dict } from '../../../../types/types'; +import { Dict } from '../../../../types/types'; interface Props { profiles: ComponentQualityProfile[]; diff --git a/server/sonar-web/src/main/js/apps/projectInformation/about/components/MetaVisibility.tsx b/server/sonar-web/src/main/js/apps/projectInformation/about/components/MetaVisibility.tsx index 8237ef6ce20..a6e5e2646a1 100644 --- a/server/sonar-web/src/main/js/apps/projectInformation/about/components/MetaVisibility.tsx +++ b/server/sonar-web/src/main/js/apps/projectInformation/about/components/MetaVisibility.tsx @@ -19,9 +19,9 @@ */ import { SubHeading } from 'design-system'; import * as React from 'react'; +import { Visibility } from '~sonar-aligned/types/component'; import PrivacyBadgeContainer from '../../../../components/common/PrivacyBadgeContainer'; import { translate } from '../../../../helpers/l10n'; -import { Visibility } from '../../../../types/component'; interface Props { qualifier: string; 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 832d7f41d6c..a55e30a8593 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 @@ -20,13 +20,12 @@ import userEvent from '@testing-library/user-event'; import * as React from 'react'; import { queryToSearchString } from '~sonar-aligned/helpers/urls'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; 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 { Visibility } from '../../../../types/component'; import { FCProps } from '../../../../types/misc'; import { LoggedInUser } from '../../../../types/users'; import { ApplicationCreation } from '../ApplicationCreation'; diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx index 1f5cfda2ca2..44fe864f3b7 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx @@ -19,11 +19,10 @@ */ import { screen } from '@testing-library/react'; import React from 'react'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { MetricKey } from '~sonar-aligned/types/metrics'; import { mockCurrentUser, mockLoggedInUser } from '../../../../../helpers/testMocks'; import { renderComponent } from '../../../../../helpers/testReactTestingUtils'; -import { Visibility } from '../../../../../types/component'; import { CurrentUser } from '../../../../../types/users'; import { Project } from '../../../types'; import ProjectCard from '../ProjectCard'; diff --git a/server/sonar-web/src/main/js/apps/projects/types.ts b/server/sonar-web/src/main/js/apps/projects/types.ts index 437faeb5870..4abea9916c0 100644 --- a/server/sonar-web/src/main/js/apps/projects/types.ts +++ b/server/sonar-web/src/main/js/apps/projects/types.ts @@ -17,8 +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 { ComponentQualifier } from '~sonar-aligned/types/component'; -import { Visibility } from '../../types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { Dict } from '../../types/types'; export interface Project { diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/ChangeDefaultVisibilityForm.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/ChangeDefaultVisibilityForm.tsx index 6f2eca87f86..5a37ed41b94 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/ChangeDefaultVisibilityForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/ChangeDefaultVisibilityForm.tsx @@ -20,9 +20,9 @@ import { RadioButtonGroup } from '@sonarsource/echoes-react'; import { ButtonPrimary, FlagMessage, Modal } from 'design-system'; import React, { useState } from 'react'; +import { Visibility } from '~sonar-aligned/types/component'; import { translate } from '../../helpers/l10n'; import { useGithubProvisioningEnabledQuery } from '../../queries/identity-provider/github'; -import { Visibility } from '../../types/component'; export interface Props { defaultVisibility: Visibility; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx index 18673aae3f6..c9c57fc28ca 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx @@ -21,8 +21,8 @@ import { ButtonPrimary, InteractiveIcon, PencilIcon, Title } from 'design-system import * as React from 'react'; import { useState } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; +import { Visibility } from '~sonar-aligned/types/component'; import { translate } from '../../helpers/l10n'; -import { Visibility } from '../../types/component'; import ChangeDefaultVisibilityForm from './ChangeDefaultVisibilityForm'; export interface Props { diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectManagementApp.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectManagementApp.tsx index ae10d3abb8c..aa3412d0a13 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectManagementApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectManagementApp.tsx @@ -22,6 +22,7 @@ import { debounce, uniq } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { throwGlobalError } from '~sonar-aligned/helpers/error'; +import { Visibility } from '~sonar-aligned/types/component'; import { Project, changeProjectDefaultVisibility, @@ -34,7 +35,6 @@ import Suggestions from '../../components/embed-docs-modal/Suggestions'; import { toShortISO8601String } from '../../helpers/dates'; import { translate } from '../../helpers/l10n'; import { hasGlobalPermission } from '../../helpers/users'; -import { Visibility } from '../../types/component'; import { Permissions } from '../../types/permissions'; import { SettingsKey } from '../../types/settings'; import { LoggedInUser } from '../../types/users'; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx index 4d4b1a230eb..8fe725ef816 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx @@ -32,12 +32,12 @@ import { sortBy } from 'lodash'; import * as React from 'react'; import { OptionProps, SingleValueProps, components } from 'react-select'; import HelpTooltip from '~sonar-aligned/components/controls/HelpTooltip'; +import { Visibility } from '~sonar-aligned/types/component'; import { Project } from '../../api/project-management'; import withAppStateContext from '../../app/components/app-state/withAppStateContext'; import { translate } from '../../helpers/l10n'; import { LabelValueSelectOption } from '../../helpers/search'; import { AppState } from '../../types/appstate'; -import { Visibility } from '../../types/component'; import BulkApplyTemplateModal from './BulkApplyTemplateModal'; import DeleteModal from './DeleteModal'; diff --git a/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx b/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx index a6a129f1003..cc9ebd48d7b 100644 --- a/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx +++ b/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx @@ -19,9 +19,9 @@ */ import classNames from 'classnames'; import * as React from 'react'; +import { Visibility } from '~sonar-aligned/types/component'; import Tooltip from '../../components/controls/Tooltip'; import { translate } from '../../helpers/l10n'; -import { Visibility } from '../../types/component'; interface PrivacyBadgeContainerProps { className?: string; diff --git a/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx b/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx index e3cfc540ab7..71c9b0e7242 100644 --- a/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx +++ b/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx @@ -20,8 +20,8 @@ import { RadioButtonGroup } from '@sonarsource/echoes-react'; import classNames from 'classnames'; import * as React from 'react'; +import { Visibility } from '~sonar-aligned/types/component'; import { translate } from '../../helpers/l10n'; -import { Visibility } from '../../types/component'; export interface VisibilitySelectorProps { canTurnToPrivate?: boolean; diff --git a/server/sonar-web/src/main/js/helpers/mocks/component.ts b/server/sonar-web/src/main/js/helpers/mocks/component.ts index 13b07c99188..b5f40a10449 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/component.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/component.ts @@ -17,9 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { MetricKey } from '~sonar-aligned/types/metrics'; -import { TreeComponent, Visibility } from '../../types/component'; +import { TreeComponent } from '../../types/component'; import { Component, ComponentMeasure, ComponentMeasureEnhanced } from '../../types/types'; import { mockMeasureEnhanced } from '../testMocks'; diff --git a/server/sonar-web/src/main/js/helpers/mocks/projects.ts b/server/sonar-web/src/main/js/helpers/mocks/projects.ts index a781055695f..2648066b96e 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/projects.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/projects.ts @@ -17,9 +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 { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, Visibility } from '~sonar-aligned/types/component'; import { Project } from '../../api/project-management'; -import { Visibility } from '../../types/component'; export function mockProject(overrides: Partial = {}): Project { return { diff --git a/server/sonar-web/src/main/js/queries/branch.tsx b/server/sonar-web/src/main/js/queries/branch.tsx index d2c6195cb24..5bca3426de3 100644 --- a/server/sonar-web/src/main/js/queries/branch.tsx +++ b/server/sonar-web/src/main/js/queries/branch.tsx @@ -26,6 +26,7 @@ import { useLocation } from '~sonar-aligned/components/hoc/withRouter'; import { isBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like'; import { isPortfolioLike } from '~sonar-aligned/helpers/component'; import { searchParamsToQuery } from '~sonar-aligned/helpers/router'; +import { LightComponent } from '~sonar-aligned/types/component'; import { deleteBranch, deletePullRequest, @@ -42,7 +43,7 @@ import { extractStatusConditionsFromProjectStatus } from '../helpers/qualityGate import { Branch, BranchLike } from '../types/branch-like'; import { isApplication, isProject } from '../types/component'; import { Feature } from '../types/features'; -import { Component, LightComponent } from '../types/types'; +import { Component } from '../types/types'; // This will prevent refresh when navigating from page to page. const BRANCHES_STALE_TIME = 30_000; diff --git a/server/sonar-web/src/main/js/sonar-aligned/helpers/mocks/component.ts b/server/sonar-web/src/main/js/sonar-aligned/helpers/mocks/component.ts new file mode 100644 index 00000000000..85d3136137e --- /dev/null +++ b/server/sonar-web/src/main/js/sonar-aligned/helpers/mocks/component.ts @@ -0,0 +1,40 @@ +/* + * 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 { ComponentBase, ComponentQualifier } from '../../types/component'; + +export function mockComponentBase(overrides: Partial = {}): ComponentBase { + return { + breadcrumbs: [], + key: 'my-project', + name: 'MyProject', + qualifier: ComponentQualifier.Project, + qualityGate: { isDefault: true, key: '30', name: 'Sonar way' }, + qualityProfiles: [ + { + deleted: false, + key: 'my-qp', + language: 'ts', + name: 'Sonar way', + }, + ], + tags: [], + ...overrides, + }; +} diff --git a/server/sonar-web/src/main/js/sonar-aligned/types/branch-like.ts b/server/sonar-web/src/main/js/sonar-aligned/types/branch-like.ts index 3b9405f23f9..3f075d402e7 100644 --- a/server/sonar-web/src/main/js/sonar-aligned/types/branch-like.ts +++ b/server/sonar-web/src/main/js/sonar-aligned/types/branch-like.ts @@ -34,8 +34,8 @@ export interface PullRequestBase { analysisDate?: string; base: string; branch: string; - key: string; isOrphan?: true; + key: string; status?: { qualityGateStatus: Status }; target: string; title: string; diff --git a/server/sonar-web/src/main/js/sonar-aligned/types/component.ts b/server/sonar-web/src/main/js/sonar-aligned/types/component.ts index 347769b5b9f..b7d178728e8 100644 --- a/server/sonar-web/src/main/js/sonar-aligned/types/component.ts +++ b/server/sonar-web/src/main/js/sonar-aligned/types/component.ts @@ -29,3 +29,38 @@ export enum ComponentQualifier { SubProject = 'BRC', TestFile = 'UTS', } +export interface Breadcrumb { + key: string; + name: string; + qualifier: string; +} +export interface LightComponent { + key: string; + name: string; + qualifier: string; +} +export enum Visibility { + Public = 'public', + Private = 'private', +} +export interface ComponentBase extends LightComponent { + alm?: { key: string; url: string }; + analysisDate?: string; + breadcrumbs: Breadcrumb[]; + description?: string; + isFavorite?: boolean; + leakPeriodDate?: string; + path?: string; + qualityGate?: { isDefault?: boolean; key: string | number; name: string }; + qualityProfiles?: ComponentQualityProfile[]; + refKey?: string; + tags?: string[]; + version?: string; + visibility?: Visibility; +} +export interface ComponentQualityProfile { + deleted?: boolean; + key: string; + language: string; + name: string; +} diff --git a/server/sonar-web/src/main/js/types/application.ts b/server/sonar-web/src/main/js/types/application.ts index 99f31af3843..1684dab86f2 100644 --- a/server/sonar-web/src/main/js/types/application.ts +++ b/server/sonar-web/src/main/js/types/application.ts @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { Visibility } from '~sonar-aligned/types/component'; import { Branch } from './branch-like'; -import { Visibility } from './component'; export interface ApplicationPeriod { date: string; diff --git a/server/sonar-web/src/main/js/types/component.ts b/server/sonar-web/src/main/js/types/component.ts index 48a85909af1..0855d59b3de 100644 --- a/server/sonar-web/src/main/js/types/component.ts +++ b/server/sonar-web/src/main/js/types/component.ts @@ -18,14 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { isPortfolioLike } from '~sonar-aligned/helpers/component'; -import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentQualifier, LightComponent, Visibility } from '~sonar-aligned/types/component'; import { Task } from './tasks'; -import { Component, LightComponent } from './types'; - -export enum Visibility { - Public = 'public', - Private = 'private', -} +import { Component } from './types'; export enum ProjectKeyValidationResult { Valid = 'valid', @@ -37,7 +32,6 @@ export enum ProjectKeyValidationResult { export interface TreeComponent extends LightComponent { id?: string; - name: string; path?: string; refId?: string; refKey?: string; diff --git a/server/sonar-web/src/main/js/types/types.ts b/server/sonar-web/src/main/js/types/types.ts index 16daeeb7c75..4737531b462 100644 --- a/server/sonar-web/src/main/js/types/types.ts +++ b/server/sonar-web/src/main/js/types/types.ts @@ -17,14 +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 { ComponentQualifier } from '~sonar-aligned/types/component'; +import { ComponentBase, ComponentQualifier } from '~sonar-aligned/types/component'; import { RuleDescriptionSection } from '../apps/coding-rules/rule'; import { CleanCodeAttribute, CleanCodeAttributeCategory, SoftwareImpact, } from './clean-code-taxonomy'; -import { Visibility } from './component'; import { IssueStatus, IssueTransition, MessageFormatting } from './issues'; import { NewCodeDefinitionType } from './new-code-definition'; import { UserActive, UserBase } from './users'; @@ -56,12 +55,6 @@ export interface AlmUnboundApplication { name: string; } -export interface Breadcrumb { - key: string; - name: string; - qualifier: string; -} - export namespace Chart { export interface Point { x: Date; @@ -76,26 +69,12 @@ export namespace Chart { } } -export interface Component extends LightComponent { - alm?: { key: string; url: string }; - analysisDate?: string; - breadcrumbs: Breadcrumb[]; +export interface Component extends ComponentBase { branch?: string; canBrowseAllChildProjects?: boolean; configuration?: ComponentConfiguration; - description?: string; extensions?: Extension[]; - isFavorite?: boolean; - leakPeriodDate?: string; - name: string; needIssueSync?: boolean; - path?: string; - refKey?: string; - qualityProfiles?: ComponentQualityProfile[]; - qualityGate?: { isDefault?: boolean; key: string; name: string }; - tags?: string[]; - version?: string; - visibility?: Visibility; } export interface NavigationComponent @@ -116,13 +95,6 @@ interface ComponentConfiguration { showUpdateKey?: boolean; } -export interface ComponentQualityProfile { - deleted?: boolean; - key: string; - language: string; - name: string; -} - export interface ComponentMeasureIntern { analysisDate?: string; branch?: string; @@ -345,11 +317,6 @@ export interface Language { export type Languages = Dict; -export interface LightComponent { - key: string; - qualifier: string; -} - export interface LinearIssueLocation { from: number; index?: number;