]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-22168 Align Component and mockComponent
authorViktor Vorona <viktor.vorona@sonarsource.com>
Thu, 2 May 2024 13:19:58 +0000 (15:19 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 3 May 2024 20:02:50 +0000 (20:02 +0000)
45 files changed:
server/sonar-web/build.gradle
server/sonar-web/src/main/js/api/application.ts
server/sonar-web/src/main/js/api/components.ts
server/sonar-web/src/main/js/api/mocks/AlmIntegrationsServiceMock.ts
server/sonar-web/src/main/js/api/mocks/ApplicationServiceMock.ts
server/sonar-web/src/main/js/api/mocks/CodingRulesServiceMock.ts
server/sonar-web/src/main/js/api/mocks/ComponentsServiceMock.ts
server/sonar-web/src/main/js/api/mocks/PermissionsServiceMock.ts
server/sonar-web/src/main/js/api/mocks/ProjectsManagementServiceMock.ts
server/sonar-web/src/main/js/api/mocks/data/projects.ts
server/sonar-web/src/main/js/api/permissions.ts
server/sonar-web/src/main/js/api/project-management.ts
server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx
server/sonar-web/src/main/js/app/components/extensions/CreateApplicationForm.tsx
server/sonar-web/src/main/js/apps/code/bucket.ts
server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx
server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx
server/sonar-web/src/main/js/apps/code/components/CodeBreadcrumbs.tsx
server/sonar-web/src/main/js/apps/code/utils.ts
server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx
server/sonar-web/src/main/js/apps/permissions/project/components/PermissionsProjectApp.tsx
server/sonar-web/src/main/js/apps/permissions/project/components/__tests__/PermissionsProject-it.tsx
server/sonar-web/src/main/js/apps/permissions/test-utils.ts
server/sonar-web/src/main/js/apps/projectInformation/__tests__/ProjectInformationApp-it.tsx
server/sonar-web/src/main/js/apps/projectInformation/about/AboutProject.tsx
server/sonar-web/src/main/js/apps/projectInformation/about/components/MetaQualityProfiles.tsx
server/sonar-web/src/main/js/apps/projectInformation/about/components/MetaVisibility.tsx
server/sonar-web/src/main/js/apps/projects/components/__tests__/CreateApplication-test.tsx
server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx
server/sonar-web/src/main/js/apps/projects/types.ts
server/sonar-web/src/main/js/apps/projectsManagement/ChangeDefaultVisibilityForm.tsx
server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx
server/sonar-web/src/main/js/apps/projectsManagement/ProjectManagementApp.tsx
server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx
server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx
server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx
server/sonar-web/src/main/js/helpers/mocks/component.ts
server/sonar-web/src/main/js/helpers/mocks/projects.ts
server/sonar-web/src/main/js/queries/branch.tsx
server/sonar-web/src/main/js/sonar-aligned/helpers/mocks/component.ts [new file with mode: 0644]
server/sonar-web/src/main/js/sonar-aligned/types/branch-like.ts
server/sonar-web/src/main/js/sonar-aligned/types/component.ts
server/sonar-web/src/main/js/types/application.ts
server/sonar-web/src/main/js/types/component.ts
server/sonar-web/src/main/js/types/types.ts

index fa2fc83e02453c9342ffbbc4461ae25b61e52c97..cbb2a5b1b10dd44d25b7371d59e563f0a7496f09 100644 (file)
@@ -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/**"
index 679961cfda19fa5b08e67ce362a58e23c18283f3..aa60a842041e144c4fd2e5bce52982f9347d5f92 100644 (file)
@@ -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,
index a69392e7e9e1fe079f3afbd9a77eb86696b7b387..7c8ae1e2dc181673947b258db895b0c2a6ac1463 100644 (file)
@@ -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,
index 6ba0e4034845f532a68d2ed76c4656595052b2d7..33849598d1f94bfca6e167c76074269d31c31938 100644 (file)
@@ -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,
index bf84949827d143fa92caa3f659cdde084bd408a5..66203fbf8977c6f42c43fba13b2cbbb45f2a5a28 100644 (file)
@@ -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');
index 5806e296367ace482f1b36a4ba10bea6ae55885d..71cc1cbfe2261e639e10aedff4023256fec4cc5d 100644 (file)
@@ -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';
index 2ca70ceb9965f41b42cc113032ee695eb2dee2b7..787556a810e331a82855ad546a2a6a32b65cf230 100644 (file)
  */
 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,
index 7c53a4da0f298754472ff6c0c62095ee967eb695..4236df00b27b7fa079cf0b36063d3d46f05abe5e 100644 (file)
@@ -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';
index b6048242d6a605142a56a40b73829f25829bed55..57c6ed0de05a5d4081529a95c08ab63405926869 100644 (file)
@@ -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,
index 966e6bae94df1cd5b5d94bd22d8209994485a658..fbffae152334e9843d22538a6187bcbdd590e724 100644 (file)
@@ -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[] {
index e13899e8a1fcbdf8fd33b1b99f0688d3f4edd097..0dc048add92a55c94a56a97782ebea465d554dbf 100644 (file)
@@ -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,
index 2cd0b6136bc61cb548f9c88ba7b6340422ff25a1..b86443c4729a56522ba94858ae2cd5d3b4260bfd 100644 (file)
@@ -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 {
index 309d128a9f0edb186a7075e3522c35bdf32313a2..afd433e03e1aeeb903ad5a599a730e654f8face1 100644 (file)
@@ -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';
index 74f8f67cafe286f54835b6305dd41bc7e69f27b2..412f325edd51354fc6f36773bb7714f093d30d17 100644 (file)
@@ -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;
index 75c7c87f4f947fc76f8b0e9e8bdfef9916df1521..9a3827b70a7ff71d131dd164d42afdbb41af2117 100644 (file)
@@ -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<ComponentMeasure> = {};
 let childrenBucket: Dict<{
index a13db26792f90858bcc4c2d320df9150fdb6c521..72e81423955fa9474a565ec7dbd4a683b39c552a 100644 (file)
 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';
index 2724ae69aca8f27230818efcb9640d6c8ee24efe..3f514a8e07617d6d7b0f0d94f9df8697d13be010 100644 (file)
@@ -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';
index a72965b31b08628128eba5fc1cc5aca633e2e6b4..91e44b3a0a71961c077a071c6c4a83fed1be45c4 100644 (file)
@@ -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 {
index 31c828370357578efc371472f46d557d37c0a3dc..69ca61edc07ee37f723e26fb6fd983a33d7351ed 100644 (file)
  */
 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,
index 4bc135d62bb7c5ac5373eca1d82b60fbd0a745f9..2f1bf24ba55d53a2f540aa6c5b532c687728b794 100644 (file)
@@ -77,6 +77,7 @@ export function IssueSourceViewerHeader(props: Readonly<Props>) {
   const { data: branchData, isLoading: isLoadingBranches } = useBranchesQuery(
     component ?? {
       key: project,
+      name: projectName,
       qualifier: ComponentQualifier.Project,
     },
   );
index 7cc89368bb66f9f8c3e58d4aecf16a527ba2e358..b5b89e9db02aee916aa74a8e849a08434ccad734 100644 (file)
@@ -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';
index 5e4461aac928b8c523c60f93265e2ce7c8bfd4e6..6c048379bc71287c7e585875f87e87da5986b2a2 100644 (file)
@@ -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';
index 9bec30dc8bd95bd3c5d0fc89017411af9efc7576..d382ec9e14d6879c7db1c3b97bfebb6e6052af97 100644 (file)
@@ -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) {
index dabdddeda8ffbdd8f6ad996610643e5d23c7136c..7349466c79a745c513026bd564748e9eae9c9756 100644 (file)
@@ -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';
index 642955b8ca5bf917b48f097ec4478d1dcc4a67a6..382bf84c832c95287ccb8af630e786093a40e2e9 100644 (file)
 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';
index 8153c194e7e6b847dac6c4ea7dd1ce93935652b4..dc94c4d0417bf746aa84c015025a011dea0be411 100644 (file)
  */
 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[];
index 8237ef6ce20375460efdef101411abd9c1ad699a..a6e5e2646a1c09dbb9b43c0f19a56ae88f44fe5a 100644 (file)
@@ -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;
index 832d7f41d6c583bc55ce221103e967ad8d55f846..a55e30a8593196a0f1d5a3af2e6ee1e35ee9e3c9 100644 (file)
 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';
index 1f5cfda2ca2422be65d98b77df84c05132ddcffe..44fe864f3b72b153b8ae18e92e15e028867a68a1 100644 (file)
  */
 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';
index 437faeb5870088974b284a1f9eb1fcafd73acf11..4abea9916c0aa93cb04adf141fdd30b0ef1a57fa 100644 (file)
@@ -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 {
index 6f2eca87f864d60837cb89faf2d5b8bea515b0f0..5a37ed41b9474a2624f62816e590bf4a746ab877 100644 (file)
@@ -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;
index 18673aae3f6ae3b98082a10c6b1ce46f7c6a8a93..c9c57fc28ca96517d21d4b5a80d38450ec43a1d7 100644 (file)
@@ -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 {
index ae10d3abb8c83ed6f67c76a21e946556e890c021..aa3412d0a134dcd6bea7fb106ec41de072a66e14 100644 (file)
@@ -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';
index 4d4b1a230eb5ed6a155b38c154a27cf9c0e8c6e1..8fe725ef81630df24972d6b253c3e3ab52e75704 100644 (file)
@@ -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';
 
index a6a129f10037948d2b76842c2e547e950a5396d0..cc9ebd48d7b3223f91c657b8dd3939f54b9db35f 100644 (file)
@@ -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;
index e3cfc540ab7642857757d7b44082264949836a80..71c9b0e7242501229271796a3c6c351d27d72bfb 100644 (file)
@@ -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;
index 13b07c99188ba33ae8b0b844df19fd643386304f..b5f40a10449b3b514e380bb3ffc87f1707dc786b 100644 (file)
@@ -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';
 
index a781055695f993f4da9d3bafc3eed26a02475f3f..2648066b96ee57e93478eebc556dfa4acda3ca44 100644 (file)
@@ -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> = {}): Project {
   return {
index d2c6195cb2400876ef64c80a42fc536283cd5acf..5bca3426de31c97df53c1f59eb03b4a803cd24d1 100644 (file)
@@ -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 (file)
index 0000000..85d3136
--- /dev/null
@@ -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> = {}): 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,
+  };
+}
index 3b9405f23f95721aa5e8d7847067230c90bd3f2b..3f075d402e74efa07cfcf8f07029f9103af0be08 100644 (file)
@@ -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;
index 347769b5b9f096c42f3cb6e86e3d39556d773fed..b7d178728e8a640a68c215fbf23ab43eccb5f0a1 100644 (file)
@@ -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;
+}
index 99f31af3843618bee275e937ee573b454c208981..1684dab86f23b1805f437470268b2934ec2e2fa8 100644 (file)
@@ -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;
index 48a85909af1c62aced4a04250195924367ecebe9..0855d59b3de2f6621182bea3931331bf369ca5ae 100644 (file)
  * 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;
index 16daeeb7c756006dd3050d86cf00abf22721aa1b..4737531b46270a090b28764b33cb071457d8bc20 100644 (file)
  * 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<Language>;
 
-export interface LightComponent {
-  key: string;
-  qualifier: string;
-}
-
 export interface LinearIssueLocation {
   from: number;
   index?: number;