]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-22168 Align BranchLike and isPullRequest
authorViktor Vorona <viktor.vorona@sonarsource.com>
Thu, 2 May 2024 10:29:13 +0000 (12:29 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 2 May 2024 20:02:38 +0000 (20:02 +0000)
51 files changed:
server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx
server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx
server/sonar-web/src/main/js/app/components/nav/component/branch-like/PRLink.tsx
server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx
server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx
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/ComponentMeasure.tsx
server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx
server/sonar-web/src/main/js/apps/code/components/Search.tsx
server/sonar-web/src/main/js/apps/code/utils.ts
server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx
server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx
server/sonar-web/src/main/js/apps/component-measures/utils.ts
server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx
server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx
server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx
server/sonar-web/src/main/js/apps/overview/branches/Analysis.tsx
server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx
server/sonar-web/src/main/js/apps/overview/branches/QualityGateStatusHeader.tsx
server/sonar-web/src/main/js/apps/overview/branches/__tests__/QualityGatePanelSection-test.tsx
server/sonar-web/src/main/js/apps/overview/components/AnalysisErrorMessage.tsx
server/sonar-web/src/main/js/apps/overview/components/App.tsx
server/sonar-web/src/main/js/apps/overview/pullRequests/BranchQualityGate.tsx
server/sonar-web/src/main/js/apps/overview/pullRequests/SonarLintAd.tsx
server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFilters.tsx
server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx
server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx
server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx
server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx
server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx
server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx
server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx
server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx
server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx
server/sonar-web/src/main/js/components/icon-mappers/BranchLikeIcon.tsx
server/sonar-web/src/main/js/components/measure/Measure.tsx
server/sonar-web/src/main/js/helpers/branch-like.ts
server/sonar-web/src/main/js/helpers/urls.ts
server/sonar-web/src/main/js/queries/branch.tsx
server/sonar-web/src/main/js/sonar-aligned/helpers/branch-like.ts
server/sonar-web/src/main/js/sonar-aligned/helpers/urls.ts
server/sonar-web/src/main/js/sonar-aligned/types/branch-like.ts
server/sonar-web/src/main/js/sonar-aligned/types/common.ts [new file with mode: 0644]
server/sonar-web/src/main/js/types/branch-like.ts
server/sonar-web/src/main/js/types/component.ts
server/sonar-web/src/main/js/types/project-activity.ts
server/sonar-web/src/main/js/types/quality-gates.ts
server/sonar-web/src/main/js/types/types.ts

index 228a263d93bace17f8f8a39d5c29b916b2d38847..0c19a7436ee410767754bde1f7323d400c7972f3 100644 (file)
@@ -24,6 +24,7 @@ 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 { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { validateProjectAlmBinding } from '../../api/alm-settings';
 import { getTasksForComponent } from '../../api/ce';
@@ -33,7 +34,6 @@ import { translateWithParameters } from '../../helpers/l10n';
 import { HttpStatus } from '../../helpers/request';
 import { getPortfolioUrl, getProjectUrl, getPullRequestUrl } from '../../helpers/urls';
 import { useBranchesQuery } from '../../queries/branch';
-import { isPortfolioLike } from '../../sonar-aligned/helpers/component';
 import { ProjectAlmBindingConfigurationErrors } from '../../types/alm-settings';
 import { Branch } from '../../types/branch-like';
 import { isFile } from '../../types/component';
index 46d1e5da73128ee550e7df184a3b24907163f218..2d5863072fb0269ff9d5ff2e8c639704376023cd 100644 (file)
@@ -27,15 +27,14 @@ import {
 } 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 { getBranchLikeQuery, isPullRequest } from '~sonar-aligned/helpers/branch-like';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { BranchParameters } from '~sonar-aligned/types/branch-like';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { DEFAULT_ISSUES_QUERY } from '../../../../components/shared/utils';
-import { isPullRequest } from '../../../../helpers/branch-like';
 import { hasMessage, translate, translateWithParameters } from '../../../../helpers/l10n';
 import { getPortfolioUrl, getProjectQueryUrl } from '../../../../helpers/urls';
 import { useBranchesQuery } from '../../../../queries/branch';
-import { isPortfolioLike } from '../../../../sonar-aligned/helpers/component';
 import { isApplication, isProject } from '../../../../types/component';
 import { Feature } from '../../../../types/features';
 import { Component, Dict, Extension } from '../../../../types/types';
index 79a59e0bf3498594a5830737b5df45a4ea2b43da..9dca663b31c1b22b60df7db3ff1e69fbadc0623c 100644 (file)
 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 { isBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import { queryToSearchString } from '~sonar-aligned/helpers/urls';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { Router } from '~sonar-aligned/types/router';
-import {
-  getBrancheLikesAsTree,
-  isPullRequest,
-  isSameBranchLike,
-} from '../../../../../helpers/branch-like';
+import { getBrancheLikesAsTree, isSameBranchLike } from '../../../../../helpers/branch-like';
 import { KeyboardKeys } from '../../../../../helpers/keycodes';
 import { translate } from '../../../../../helpers/l10n';
 import { getBranchLikeUrl } from '../../../../../helpers/urls';
index c94295f147ba8400eb45c565c87382d5c91c7eac..c2bb7f92ba62c8ae5550ce682dbd95cbabd5d953 100644 (file)
@@ -20,8 +20,8 @@
 
 import { LinkStandalone } from '@sonarsource/echoes-react';
 import React from 'react';
+import { isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import { Image } from '../../../../../components/common/Image';
-import { isPullRequest } from '../../../../../helpers/branch-like';
 import { translate, translateWithParameters } from '../../../../../helpers/l10n';
 import { isDefined } from '../../../../../helpers/types';
 import { AlmKeys } from '../../../../../types/alm-settings';
index b655713b167e4f439841e17a46c0c08827fe7150..a2279d8b63260f330eac01683fc6715f49a34acb 100644 (file)
@@ -28,6 +28,7 @@ import {
 } from 'design-system';
 import * as React from 'react';
 import { formatMeasure } from '~sonar-aligned/helpers/measures';
+import { Status } from '~sonar-aligned/types/common';
 import { MetricType } from '~sonar-aligned/types/metrics';
 import MetaLink from '../../../components/common/MetaLink';
 import Tooltip from '../../../components/controls/Tooltip';
@@ -35,7 +36,7 @@ import DateFromNow from '../../../components/intl/DateFromNow';
 import { translate, translateWithParameters } from '../../../helpers/l10n';
 import { orderLinks } from '../../../helpers/projectLinks';
 import { getProjectUrl } from '../../../helpers/urls';
-import { MyProject, ProjectLink, Status } from '../../../types/types';
+import { MyProject, ProjectLink } from '../../../types/types';
 
 interface Props {
   project: MyProject;
index 00a3ee090e88333b0f1ee49da8f266bd80424743..80aa8bb1ace257d144e30219252895bcbcc3928c 100644 (file)
@@ -27,6 +27,7 @@ import {
   StandoutLink,
 } from 'design-system';
 import * as React from 'react';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { translate } from '../../../helpers/l10n';
 import {
   getBranchUrl,
@@ -34,7 +35,6 @@ import {
   getProjectUrl,
   getPullRequestUrl,
 } from '../../../helpers/urls';
-import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import { Task } from '../../../types/tasks';
 
 interface Props {
index 60a76bd2db957e9e537f3c10817961ad94b38fb8..a13db26792f90858bcc4c2d320df9150fdb6c521 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 { 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 { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import { Breadcrumb, Component, ComponentMeasure, Dict, Metric } from '../../../types/types';
 import { addComponent, addComponentBreadcrumbs, clearBucket } from '../bucket';
 import { loadMoreChildren, retrieveComponent, retrieveComponentChildren } from '../utils';
index 71f21866ede9bba76ccba5f8e3db9367710162cb..2724ae69aca8f27230818efcb9640d6c8ee24efe 100644 (file)
@@ -31,6 +31,7 @@ import * as React from 'react';
 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 { Location } from '~sonar-aligned/types/router';
 import ListFooter from '../../../components/controls/ListFooter';
 import Suggestions from '../../../components/embed-docs-modal/Suggestions';
@@ -39,7 +40,6 @@ import { CCT_SOFTWARE_QUALITY_METRICS, OLD_TAXONOMY_METRICS } from '../../../hel
 import { KeyboardKeys } from '../../../helpers/keycodes';
 import { translate } from '../../../helpers/l10n';
 import { areCCTMeasuresComputed } from '../../../helpers/measures';
-import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import { BranchLike } from '../../../types/branch-like';
 import { isApplication } from '../../../types/component';
 import { Breadcrumb, Component, ComponentMeasure, Dict, Metric } from '../../../types/types';
index 98f076fbee3091f3c132003a10e06e8d9b059001..800af9d358f53c69a709637a20b01761a77e33d2 100644 (file)
@@ -27,6 +27,7 @@ import {
 } from 'design-system';
 import * as React from 'react';
 import { formatMeasure } from '~sonar-aligned/helpers/measures';
+import { Status } from '~sonar-aligned/types/common';
 import { MetricKey, MetricType } from '~sonar-aligned/types/metrics';
 import Measure from '../../../components/measure/Measure';
 import { getLeakValue } from '../../../components/measure/utils';
@@ -40,7 +41,7 @@ import {
   isDiffMetric,
 } from '../../../helpers/measures';
 import { isApplication, isProject } from '../../../types/component';
-import { Metric, Status, ComponentMeasure as TypeComponentMeasure } from '../../../types/types';
+import { Metric, ComponentMeasure as TypeComponentMeasure } from '../../../types/types';
 
 interface Props {
   component: TypeComponentMeasure;
index 5b9e92c2c8b911d2dd3999357f95ff2a86773e65..18ad9680db76119029b48ccb173b6966ec0e9689 100644 (file)
@@ -21,12 +21,12 @@ 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 { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { queryToSearchString } from '~sonar-aligned/helpers/urls';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { translate } from '../../../helpers/l10n';
 import { isDefined } from '../../../helpers/types';
 import { CodeScope, getComponentOverviewUrl } from '../../../helpers/urls';
-import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import { BranchLike } from '../../../types/branch-like';
 import { isApplication, isProject } from '../../../types/component';
 import { ComponentMeasure } from '../../../types/types';
index 17db6ae55250498d7ffeb639feeb2455fa2903c5..f1be0f903e6bc1c67966b1d10da778557b177c39 100644 (file)
@@ -23,12 +23,12 @@ 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 { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { Location, Router } from '~sonar-aligned/types/router';
 import { getTree } from '../../../api/components';
 import { KeyboardKeys } from '../../../helpers/keycodes';
 import { translate } from '../../../helpers/l10n';
-import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import { BranchLike } from '../../../types/branch-like';
 import { isView } from '../../../types/component';
 import { ComponentMeasure } from '../../../types/types';
index fc0d3d09c22d79d61f07a26d7676ca13395eb863..31c828370357578efc371472f46d557d37c0a3dc 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 { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like';
+import { getBranchLikeQuery, isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { MetricKey } from '~sonar-aligned/types/metrics';
 import { getBreadcrumbs, getChildren, getComponent, getComponentData } from '../../api/components';
-import { isPullRequest } from '../../helpers/branch-like';
 import { CCT_SOFTWARE_QUALITY_METRICS, OLD_TAXONOMY_METRICS } from '../../helpers/constants';
 import { BranchLike } from '../../types/branch-like';
 import { Breadcrumb, ComponentMeasure } from '../../types/types';
index 035e0a6cac958ee0cc6b7e4bce2cd9a62fb163b5..fce45c211b2960db5574fa4e7efeae8b4f5b0bd1 100644 (file)
@@ -30,6 +30,7 @@ import {
   Modal,
 } from 'design-system';
 import * as React from 'react';
+import { Status } from '~sonar-aligned/types/common';
 import FormattingTips from '../../../components/common/FormattingTips';
 import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation';
 import { RULE_STATUSES } from '../../../helpers/constants';
@@ -43,7 +44,7 @@ import {
   CleanCodeAttributeCategory,
   SoftwareImpact,
 } from '../../../types/clean-code-taxonomy';
-import { Dict, RuleDetails, RuleParameter, Status } from '../../../types/types';
+import { Dict, RuleDetails, RuleParameter } from '../../../types/types';
 import {
   CleanCodeAttributeField,
   CleanCodeCategoryField,
index b04b06bcb44148c55eaa0b7740f45586d333d8d8..9eccd8c6154fff0888cca667210e750d93b9b811 100644 (file)
@@ -33,7 +33,8 @@ 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 { getBranchLikeQuery, isPullRequest } from '~sonar-aligned/helpers/branch-like';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { MetricKey } from '~sonar-aligned/types/metrics';
 import { Location, Router } from '~sonar-aligned/types/router';
@@ -44,11 +45,10 @@ import Suggestions from '../../../components/embed-docs-modal/Suggestions';
 import { enhanceMeasure } from '../../../components/measure/utils';
 import '../../../components/search-navigator.css';
 import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage';
-import { isPullRequest, isSameBranchLike } from '../../../helpers/branch-like';
+import { isSameBranchLike } from '../../../helpers/branch-like';
 import { translate } from '../../../helpers/l10n';
 import { areLeakAndOverallCCTMeasuresComputed } from '../../../helpers/measures';
 import { WithBranchLikesProps, useBranchesQuery } from '../../../queries/branch';
-import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import { MeasurePageView } from '../../../types/measures';
 import { ComponentMeasure, Dict, MeasureEnhanced, Metric, Period } from '../../../types/types';
 import Sidebar from '../sidebar/Sidebar';
index 13c90589ca9c757ef543bf6af4cee505f0ea3a7f..273697319028e451af58a30cd812b21f552bf760 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { groupBy, memoize, sortBy, toPairs } from 'lodash';
-import { isBranch } from '~sonar-aligned/helpers/branch-like';
+import { isBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { MetricKey, MetricType } from '~sonar-aligned/types/metrics';
 import { RawQuery } from '~sonar-aligned/types/router';
 import { enhanceMeasure } from '../../components/measure/utils';
-import { isPullRequest } from '../../helpers/branch-like';
 import {
   CCT_SOFTWARE_QUALITY_METRICS,
   HIDDEN_METRICS,
index a6ef20e483b9c4fd819897f95158385dd7a7cedf..f4925ec2e623cf389bd7ee3a84f2181ea3e638c6 100644 (file)
@@ -36,7 +36,8 @@ import { Helmet } from 'react-helmet-async';
 import { FormattedMessage } from 'react-intl';
 import A11ySkipTarget from '~sonar-aligned/components/a11y/A11ySkipTarget';
 import { withRouter } from '~sonar-aligned/components/hoc/withRouter';
-import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like';
+import { getBranchLikeQuery, isPullRequest } from '~sonar-aligned/helpers/branch-like';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { Location, RawQuery, Router } from '~sonar-aligned/types/router';
 import { listIssues, searchIssues } from '../../../api/issues';
@@ -54,7 +55,7 @@ import withIndexationGuard from '../../../components/hoc/withIndexationGuard';
 import IssueTabViewer from '../../../components/rules/IssueTabViewer';
 import '../../../components/search-navigator.css';
 import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils';
-import { fillBranchLike, isPullRequest, isSameBranchLike } from '../../../helpers/branch-like';
+import { fillBranchLike, isSameBranchLike } from '../../../helpers/branch-like';
 import handleRequiredAuthentication from '../../../helpers/handleRequiredAuthentication';
 import { parseIssueFromResponse } from '../../../helpers/issues';
 import { isInput, isShortcut } from '../../../helpers/keyboardEventHelpers';
@@ -62,7 +63,6 @@ import { KeyboardKeys } from '../../../helpers/keycodes';
 import { translate, translateWithParameters } from '../../../helpers/l10n';
 import { serializeDate } from '../../../helpers/query';
 import { withBranchLikes } from '../../../queries/branch';
-import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import { BranchLike } from '../../../types/branch-like';
 import { isProject } from '../../../types/component';
 import {
index 6d36e808194dc111f3dbb6b45bcac9c5648acfd6..4bc135d62bb7c5ac5373eca1d82b60fbd0a745f9 100644 (file)
@@ -32,13 +32,12 @@ import {
   themeColor,
 } from 'design-system';
 import * as React from 'react';
-import { getBranchLikeQuery, isBranch } from '~sonar-aligned/helpers/branch-like';
+import { getBranchLikeQuery, isBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import { getComponentIssuesUrl } from '~sonar-aligned/helpers/urls';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { ComponentContext } from '../../../app/components/componentContext/ComponentContext';
 import { useCurrentUser } from '../../../app/components/current-user/CurrentUserContext';
 import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils';
-import { isPullRequest } from '../../../helpers/branch-like';
 import { translate } from '../../../helpers/l10n';
 import { collapsedDirFromPath, fileFromPath } from '../../../helpers/path';
 import { getBranchLikeUrl } from '../../../helpers/urls';
index a54aeb4fb1585d3cf004c8c7d34c73edea25046b..cafa99d1d90e59893ef8a4dfdce91d04820a585c 100644 (file)
 import { BasicSeparator, FlagMessage, Link } from 'design-system';
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
-import { isBranch } from '~sonar-aligned/helpers/branch-like';
+import { isBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import withAppStateContext from '../../../app/components/app-state/withAppStateContext';
-import { isPullRequest } from '../../../helpers/branch-like';
 import { translate } from '../../../helpers/l10n';
-import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import { AppState } from '../../../types/appstate';
 import { BranchLike } from '../../../types/branch-like';
 import { isApplication, isProject, isView } from '../../../types/component';
index 8e296865e2171d118bddd1a712bfd1c2feab0459..4c920a2e017baac0358553c0443cbf3a75288e4c 100644 (file)
@@ -21,6 +21,7 @@ import { QualityGateIndicator } from 'design-system';
 import { sortBy } from 'lodash';
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
+import { Status } from '~sonar-aligned/types/common';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import DateTimeFormatter from '../../../components/intl/DateTimeFormatter';
 import {
@@ -28,7 +29,6 @@ import {
   ProjectAnalysisEventCategory,
   Analysis as TypeAnalysis,
 } from '../../../types/project-activity';
-import { Status } from '../../../types/types';
 import { AnalysisVariations } from './AnalysisVariations';
 import Event from './Event';
 
index 2cc345e1ba6ab991f53907399a1caa1fd63e1dd1..e1194406c2e68a759206e21f1917480b60c45c7a 100644 (file)
@@ -27,12 +27,12 @@ import {
 import * as React from 'react';
 import A11ySkipTarget from '~sonar-aligned/components/a11y/A11ySkipTarget';
 import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage';
 import { parseDate } from '../../../helpers/dates';
 import { areCCTMeasuresComputed, isDiffMetric } from '../../../helpers/measures';
 import { CodeScope } from '../../../helpers/urls';
-import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import { ApplicationPeriod } from '../../../types/application';
 import { Branch } from '../../../types/branch-like';
 import { Analysis, GraphType, MeasureHistory } from '../../../types/project-activity';
index c4eee2fd3ae55334989bae5adc298759b9f1160c..2188c540a8e7545c13d6acf7ebbf69122a77c93d 100644 (file)
@@ -20,8 +20,8 @@
 import { QualityGateIndicator, TextError } from 'design-system';
 import React from 'react';
 import { useIntl } from 'react-intl';
+import { Status } from '~sonar-aligned/types/common';
 import { translate } from '../../../helpers/l10n';
-import { Status } from '../../../types/types';
 
 interface Props {
   status: Status;
index 3bfb3a9d3de98d48c014db5e931d1e12f7f9a98f..7363d813328df5a92c68cafa7614d92f237f8a81 100644 (file)
  */
 import { screen } from '@testing-library/react';
 import * as React from 'react';
+import { Status } from '~sonar-aligned/types/common';
 import { MetricKey } from '~sonar-aligned/types/metrics';
 import CurrentUserContextProvider from '../../../../app/components/current-user/CurrentUserContextProvider';
 import { mockQualityGate, mockQualityGateStatus } from '../../../../helpers/mocks/quality-gates';
 import { mockLoggedInUser } from '../../../../helpers/testMocks';
 import { renderComponent } from '../../../../helpers/testReactTestingUtils';
 import { byRole } from '../../../../helpers/testSelector';
-import { CaycStatus, Status } from '../../../../types/types';
+import { CaycStatus } from '../../../../types/types';
 import { CurrentUser, NoticeType } from '../../../../types/users';
 import QualityGatePanelSection, { QualityGatePanelSectionProps } from '../QualityGatePanelSection';
 
index a7e43540abefb9e9eaa5b94e771db4e62ab0648f..212cb7725c1a51e3c7e020a9791752402cd07bac 100644 (file)
@@ -21,8 +21,7 @@ import { Link } from 'design-system';
 import React from 'react';
 import { FormattedMessage } from 'react-intl';
 import { useLocation } from 'react-router-dom';
-import { isBranch, isMainBranch } from '~sonar-aligned/helpers/branch-like';
-import { isPullRequest } from '../../../helpers/branch-like';
+import { isBranch, isMainBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import { hasMessage, translate } from '../../../helpers/l10n';
 import { getComponentBackgroundTaskUrl } from '../../../helpers/urls';
 import { useBranchesQuery } from '../../../queries/branch';
index 4c7a33f930eee6be1a228df3fd91b4bbad38c3ee..a4920fc60c867aee722d0748ddf64abf20935419 100644 (file)
  */
 import * as React from 'react';
 import { Helmet } from 'react-helmet-async';
+import { isPullRequest } from '~sonar-aligned/helpers/branch-like';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import withAvailableFeatures, {
   WithAvailableFeaturesProps,
 } from '../../../app/components/available-features/withAvailableFeatures';
 import withComponentContext from '../../../app/components/componentContext/withComponentContext';
 import Suggestions from '../../../components/embed-docs-modal/Suggestions';
-import { isPullRequest } from '../../../helpers/branch-like';
 import { translate } from '../../../helpers/l10n';
 import { useBranchesQuery } from '../../../queries/branch';
-import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import { Feature } from '../../../types/features';
 import { Component } from '../../../types/types';
 import BranchOverview from '../branches/BranchOverview';
index f2de2bdbcc36a441fca62f150f7aa4af37cf8693..e5cfc9ffa0fb65bc8c330ca9cc75adc43d8a33f0 100644 (file)
@@ -21,9 +21,10 @@ import { HelperHintIcon, LightPrimary, QualityGateIndicator, TextMuted } from 'd
 import React from 'react';
 import { useIntl } from 'react-intl';
 import HelpTooltip from '~sonar-aligned/components/controls/HelpTooltip';
+import { Status } from '~sonar-aligned/types/common';
 import { BranchLike } from '../../../types/branch-like';
 import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates';
-import { Component, Status } from '../../../types/types';
+import { Component } from '../../../types/types';
 import BranchQualityGateConditions from './BranchQualityGateConditions';
 
 interface Props {
index 64997c927548d3d6c2d64db98e903b146fca51d5..b787eac55b34825c3448e21e8b5dcf4fefb906f7 100644 (file)
@@ -31,9 +31,9 @@ import {
 } from 'design-system';
 import React from 'react';
 import { useIntl } from 'react-intl';
+import { Status } from '~sonar-aligned/types/common';
 import { useCurrentUser } from '../../../app/components/current-user/CurrentUserContext';
 import useLocalStorage from '../../../hooks/useLocalStorage';
-import { Status } from '../../../types/types';
 import { isLoggedIn } from '../../../types/users';
 import { Status as QGStatus } from '../utils';
 
index f72eae8e24bae0da309562759be777213c2a7ece..693ad08b889aca075f591b007b20f9d7c671d6e8 100644 (file)
 
 import { ButtonPrimary, FlagMessage, Title } from 'design-system';
 import * as React from 'react';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import GitHubSynchronisationWarning from '../../../../app/components/GitHubSynchronisationWarning';
 import { Image } from '../../../../components/common/Image';
 import { translate } from '../../../../helpers/l10n';
 import { isDefined } from '../../../../helpers/types';
 import { useGithubProvisioningEnabledQuery } from '../../../../queries/identity-provider/github';
-import { isPortfolioLike } from '../../../../sonar-aligned/helpers/component';
 import { isApplication, isProject } from '../../../../types/component';
 import { Component } from '../../../../types/types';
 import ApplyTemplate from './ApplyTemplate';
index b1251e4eddd82606c087937f57443ad9850991b0..578135e7c6ecc766876261d20d99ae4b756fcbf7 100644 (file)
@@ -19,9 +19,9 @@
  */
 import { InputSelect, LabelValueSelectOption } from 'design-system';
 import * as React from 'react';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { translate } from '../../../helpers/l10n';
-import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
 import {
   ApplicationAnalysisEventCategory,
   ProjectAnalysisEventCategory,
index 68c26e48d05f782039b177362d8b7930b00e8503..255e2c288fe54c553d9c72951f5ed8ae7097c867 100644 (file)
@@ -27,11 +27,11 @@ import {
   TableRowInteractive,
 } from 'design-system';
 import * as React from 'react';
-import { isBranch, isMainBranch } from '~sonar-aligned/helpers/branch-like';
+import { isBranch, isMainBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import QualityGateStatus from '../../../app/components/nav/component/branch-like/QualityGateStatus';
 import BranchLikeIcon from '../../../components/icon-mappers/BranchLikeIcon';
 import DateFromNow from '../../../components/intl/DateFromNow';
-import { getBranchLikeDisplayName, isPullRequest } from '../../../helpers/branch-like';
+import { getBranchLikeDisplayName } from '../../../helpers/branch-like';
 import { translate, translateWithParameters } from '../../../helpers/l10n';
 import { BranchLike } from '../../../types/branch-like';
 import { Component } from '../../../types/types';
index 603fb4ab9e277ec6d50e68245f1397a6ded247f1..d7d49d8fad11579e6d68e58b76589180991cc34e 100644 (file)
@@ -22,8 +22,8 @@ import { IconGitBranch, IconPullrequest } from '@sonarsource/echoes-react';
 import { ToggleButton, getTabId, getTabPanelId } from 'design-system';
 import * as React from 'react';
 import { useState } from 'react';
-import { isBranch, isMainBranch } from '~sonar-aligned/helpers/branch-like';
-import { isPullRequest, sortBranches, sortPullRequests } from '../../../helpers/branch-like';
+import { isBranch, isMainBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like';
+import { sortBranches, sortPullRequests } from '../../../helpers/branch-like';
 import { translate } from '../../../helpers/l10n';
 import { useBranchesQuery } from '../../../queries/branch';
 import { Branch, BranchLike, PullRequest } from '../../../types/branch-like';
index 9fe48ecf412e452df90d67e722554a572f215d67..613af3a933446027f82d06c53e9dcdb509cfd0fb 100644 (file)
@@ -20,7 +20,8 @@
 import { DangerButtonPrimary, Modal } from 'design-system';
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
-import { getBranchLikeDisplayName, isPullRequest } from '../../../helpers/branch-like';
+import { isPullRequest } from '~sonar-aligned/helpers/branch-like';
+import { getBranchLikeDisplayName } from '../../../helpers/branch-like';
 import { useDeletBranchMutation } from '../../../queries/branch';
 import { BranchLike } from '../../../types/branch-like';
 import { Component } from '../../../types/types';
index 4ca0bbcb80b6ffac9a4b457cd9ffa085f1e603bd..b4c09bf43c1294b21d1ed4f532c988dde5736cea 100644 (file)
 import { DangerButtonPrimary, addGlobalSuccessMessage } from 'design-system';
 import * as React from 'react';
 import { withRouter } from '~sonar-aligned/components/hoc/withRouter';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 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 { translate, translateWithParameters } from '../../helpers/l10n';
-import { isPortfolioLike } from '../../sonar-aligned/helpers/component';
 import { isApplication } from '../../types/component';
 import { Component } from '../../types/types';
 
index 44cef2bea20d4d8c770528303a3b50e6c05275c4..6fad30895d7ce4e69cbf022cc4a7f4437ab76e32 100644 (file)
@@ -19,8 +19,8 @@
  */
 import { Title } from 'design-system';
 import * as React from 'react';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { translate } from '../../helpers/l10n';
-import { isPortfolioLike } from '../../sonar-aligned/helpers/component';
 import { isApplication } from '../../types/component';
 import { Component } from '../../types/types';
 
index 5039b6ad228bb23fdad57a6235056e2c20d54224..86f41cbe60298029985f73bcee862e01942f1b0c 100644 (file)
@@ -38,6 +38,7 @@ import { isEmpty } from 'lodash';
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
 import { formatMeasure } from '~sonar-aligned/helpers/measures';
+import { Status } from '~sonar-aligned/types/common';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { MetricKey, MetricType } from '~sonar-aligned/types/metrics';
 import Favorite from '../../../../components/controls/Favorite';
@@ -48,7 +49,6 @@ import Measure from '../../../../components/measure/Measure';
 import { translate, translateWithParameters } from '../../../../helpers/l10n';
 import { isDefined } from '../../../../helpers/types';
 import { getProjectUrl } from '../../../../helpers/urls';
-import { Status } from '../../../../types/types';
 import { CurrentUser, isLoggedIn } from '../../../../types/users';
 import { Project } from '../../types';
 import ProjectCardLanguages from './ProjectCardLanguages';
index 0d7bf5234bdb3ca0f54e44423b65a85e45c3e61f..548b70907ec2e985ed867d3c0a7073ac33ff31e1 100644 (file)
@@ -21,10 +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 { Status } from '~sonar-aligned/types/common';
 import { RawQuery } from '~sonar-aligned/types/router';
 import { translate } from '../../../helpers/l10n';
 import { isDefined } from '../../../helpers/types';
-import { Status } from '../../../types/types';
 import { FacetItemsList } from '../../issues/sidebar/FacetItemsList';
 import { formatFacetStat } from '../../issues/utils';
 import { Facet } from '../types';
index 34c7fd9c73688cf186c96dcc827d0f5e46213829..fb4ba64d883a66856af4ac0606b8070b5885c92b 100644 (file)
@@ -21,7 +21,7 @@
 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 { getBranchLikeQuery, isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { MetricKey } from '~sonar-aligned/types/metrics';
 import { Location, Router } from '~sonar-aligned/types/router';
@@ -31,7 +31,7 @@ import withComponentContext from '../../app/components/componentContext/withComp
 import withCurrentUserContext from '../../app/components/current-user/withCurrentUserContext';
 import withIndexationGuard from '../../components/hoc/withIndexationGuard';
 import { getLeakValue } from '../../components/measure/utils';
-import { isPullRequest, isSameBranchLike } from '../../helpers/branch-like';
+import { isSameBranchLike } from '../../helpers/branch-like';
 import { isInput } from '../../helpers/keyboardEventHelpers';
 import { KeyboardKeys } from '../../helpers/keycodes';
 import { getStandards } from '../../helpers/security-standard';
index 12bfd4b176c0d11c52d35d23fc5180ef0fe046ac..0258c42c04a41fdaf3ef50e98a09687034b51e0c 100644 (file)
@@ -26,8 +26,8 @@ import {
 } from 'design-system';
 import { groupBy, sortBy } from 'lodash';
 import React, { Fragment, PureComponent } from 'react';
+import { isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
-import { isPullRequest } from '../../../helpers/branch-like';
 import { translate } from '../../../helpers/l10n';
 import { collapsedDirFromPath, fileFromPath } from '../../../helpers/path';
 import { getProjectUrl } from '../../../helpers/urls';
index c76172bc27669cc7cd8a7d200dfad9bafeffd764..79c0684213de3fd7505cc7607950b6161a940cc9 100644 (file)
@@ -21,8 +21,7 @@
 import { IconBranch, IconGitBranch, IconProps, IconPullrequest } from '@sonarsource/echoes-react';
 import { StyledMutedText } from 'design-system';
 import * as React from 'react';
-import { isMainBranch } from '~sonar-aligned/helpers/branch-like';
-import { isPullRequest } from '../../helpers/branch-like';
+import { isMainBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import { BranchLike } from '../../types/branch-like';
 
 export interface BranchLikeIconProps extends IconProps {
index 4c7c6c4388b70a8b7f486dfe97abe74ae089edb0..c76051540ff515a192ece8aa482226384a9eafb8 100644 (file)
 import { MetricsRatingBadge, QualityGateIndicator, RatingLabel } from 'design-system';
 import * as React from 'react';
 import { formatMeasure } from '~sonar-aligned/helpers/measures';
+import { Status } from '~sonar-aligned/types/common';
 import { MetricType } from '~sonar-aligned/types/metrics';
 import Tooltip from '../../components/controls/Tooltip';
 import { translate, translateWithParameters } from '../../helpers/l10n';
-import { Status } from '../../types/types';
 import RatingTooltipContent from './RatingTooltipContent';
 
 interface Props {
index 4f9492068bd2555087c59ae8349695ebbe35483b..e0676d7e3538331e32c251bba338cf7a06bb93d5 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { orderBy } from 'lodash';
-import { isBranch, isMainBranch } from '~sonar-aligned/helpers/branch-like';
+import { isBranch, isMainBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like';
 import { Branch, BranchLike, BranchLikeTree, PullRequest } from '../types/branch-like';
 
 export function sortBranches(branches: Branch[]) {
   return orderBy(branches, [(b) => b.isMain, (b) => b.name], ['desc', 'asc']);
 }
 
-export function isPullRequest(branchLike?: BranchLike): branchLike is PullRequest {
-  return branchLike !== undefined && (branchLike as PullRequest).key !== undefined;
-}
-
 export function sortPullRequests(pullRequests: PullRequest[]) {
   return orderBy(pullRequests, (pr) => getPullRequestDisplayName(pr));
 }
index 4b1bbd02d3bc3afc38f59f989c389681219a8749..07e8c76ff0d6cdb5faaf84f1178de361ace53fde 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { Path, To } from 'react-router-dom';
-import { getBranchLikeQuery, isBranch, isMainBranch } from '~sonar-aligned/helpers/branch-like';
+import {
+  getBranchLikeQuery,
+  isBranch,
+  isMainBranch,
+  isPullRequest,
+} from '~sonar-aligned/helpers/branch-like';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { queryToSearchString } from '~sonar-aligned/helpers/urls';
 import { BranchParameters } from '~sonar-aligned/types/branch-like';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
 import { getProfilePath } from '../apps/quality-profiles/utils';
 import { DEFAULT_ISSUES_QUERY } from '../components/shared/utils';
-import { isPortfolioLike } from '../sonar-aligned/helpers/component';
 import { BranchLike } from '../types/branch-like';
 import { isApplication } from '../types/component';
 import { MeasurePageView } from '../types/measures';
 import { GraphType } from '../types/project-activity';
 import { Dict } from '../types/types';
 import { HomePage } from '../types/users';
-import { isPullRequest } from './branch-like';
 import { serializeOptionalBoolean } from './query';
 import { getBaseUrl } from './system';
 
index 4e0644d48c57cb37bb7a62315e58e07c04e75e46..d2c6195cb2400876ef64c80a42fc536283cd5acf 100644 (file)
@@ -23,7 +23,8 @@ 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 { isBranch, isPullRequest } from '~sonar-aligned/helpers/branch-like';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { searchParamsToQuery } from '~sonar-aligned/helpers/router';
 import {
   deleteBranch,
@@ -37,9 +38,7 @@ import {
 import { dismissAnalysisWarning, getAnalysisStatus } from '../api/ce';
 import { getQualityGateProjectStatus } from '../api/quality-gates';
 import { AvailableFeaturesContext } from '../app/components/available-features/AvailableFeaturesContext';
-import { isPullRequest } from '../helpers/branch-like';
 import { extractStatusConditionsFromProjectStatus } from '../helpers/qualityGates';
-import { isPortfolioLike } from '../sonar-aligned/helpers/component';
 import { Branch, BranchLike } from '../types/branch-like';
 import { isApplication, isProject } from '../types/component';
 import { Feature } from '../types/features';
index f881115be97cc00b66497d3c6fe28990cf85af40..71a8a535321741a781662b6be2f2a60ca6cbaf69 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 { isPullRequest } from '../../helpers/branch-like';
+import {
+  BranchBase,
+  BranchLikeBase,
+  BranchParameters,
+  PullRequestBase,
+} from '~sonar-aligned/types/branch-like';
 
-import { BranchParameters } from '~sonar-aligned/types/branch-like';
-import { Branch, BranchLike, MainBranch } from '../../types/branch-like';
-
-export function getBranchLikeQuery(
-  branchLike?: BranchLike,
-  includeMainBranch = false,
+export function getBranchLikeQuery<T extends BranchLikeBase>(
+  branchLike?: T,
+  withMainBranch = false,
 ): BranchParameters {
-  if (isBranch(branchLike) && (includeMainBranch || !isMainBranch(branchLike))) {
+  if (isBranch(branchLike) && (withMainBranch || !isMainBranch(branchLike))) {
     return { branch: branchLike.name };
   } else if (isPullRequest(branchLike)) {
     return { pullRequest: branchLike.key };
   }
   return {};
 }
-export function isBranch(branchLike?: BranchLike): branchLike is Branch {
-  return branchLike !== undefined && (branchLike as Branch).isMain !== undefined;
+
+export function isBranch<T extends BranchBase>(branchLike?: T | PullRequestBase): branchLike is T {
+  return branchLike !== undefined && (branchLike as T).isMain !== undefined;
 }
-export function isMainBranch(branchLike?: BranchLike): branchLike is MainBranch {
+
+export function isMainBranch<T extends BranchBase>(
+  branchLike?: T | PullRequestBase,
+): branchLike is T & { isMain: true } {
   return isBranch(branchLike) && branchLike.isMain;
 }
+
+export function isPullRequest<T extends PullRequestBase>(
+  branchLike?: T | BranchBase,
+): branchLike is T {
+  return branchLike !== undefined && (branchLike as T).key !== undefined;
+}
index 406a6975c33681975f57979f687564bfbfe53e58..f7cf3ec13f88dc883766620f60b0d77e3d0a25da 100644 (file)
@@ -21,9 +21,9 @@ import { mapValues, omitBy, pick } from 'lodash';
 import { Path, URLSearchParamsInit, createSearchParams } from 'react-router-dom';
 import { cleanQuery } from '../../helpers/query';
 import { Query } from '../../helpers/urls';
-import { BranchLike } from '../../types/branch-like';
 import { SecurityStandard } from '../../types/security';
 import { getBranchLikeQuery } from '../helpers/branch-like';
+import { BranchLikeBase } from '../types/branch-like';
 import { RawQuery } from '../types/router';
 
 export function queryToSearchString(query: RawQuery | URLSearchParamsInit = {}) {
@@ -56,7 +56,7 @@ export function getComponentIssuesUrl(componentKey: string, query?: Query): Part
  */
 export function getComponentSecurityHotspotsUrl(
   componentKey: string,
-  branchLike?: BranchLike,
+  branchLike?: BranchLikeBase,
   query: Query = {},
 ): Partial<Path> {
   const { inNewCodePeriod, hotspots, assignedToMe, files } = query;
index 319cf58bba7833cf415be7ee9d426574b675b615..3b9405f23f95721aa5e8d7847067230c90bd3f2b 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 { Status } from './common';
+
 export type BranchParameters = { branch?: string } | { pullRequest?: string };
+
+export type BranchLikeBase = BranchBase | PullRequestBase;
+
+export interface BranchBase {
+  analysisDate?: string;
+  isMain: boolean;
+  name: string;
+  status?: { qualityGateStatus: Status };
+}
+
+export interface PullRequestBase {
+  analysisDate?: string;
+  base: string;
+  branch: string;
+  key: string;
+  isOrphan?: true;
+  status?: { qualityGateStatus: Status };
+  target: string;
+  title: string;
+  url?: string;
+}
diff --git a/server/sonar-web/src/main/js/sonar-aligned/types/common.ts b/server/sonar-web/src/main/js/sonar-aligned/types/common.ts
new file mode 100644 (file)
index 0000000..24d21cd
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+export type Status = 'ERROR' | 'OK' | 'NONE';
index fa2c02c5e80e6b7ad6806171cfe1798e625897d1..653490301d0b96cd5e93ab5a60d3caa24faf338b 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 { BranchBase, PullRequestBase } from '~sonar-aligned/types/branch-like';
+import { Status } from '~sonar-aligned/types/common';
 import { NewCodeDefinition } from './new-code-definition';
 import { QualityGateStatusCondition } from './quality-gates';
-import { Status } from './types';
 
-export interface Branch {
-  analysisDate?: string;
+export interface Branch extends BranchBase {
   excludedFromPurge: boolean;
-  isMain: boolean;
-  name: string;
-  status?: { qualityGateStatus: Status };
 }
 
 export interface MainBranch extends Branch {
   isMain: true;
 }
 
-export interface PullRequest {
-  analysisDate?: string;
-  base: string;
-  branch: string;
-  key: string;
-  isOrphan?: true;
-  status?: { qualityGateStatus: Status };
-  target: string;
-  title: string;
-  url?: string;
-}
+export interface PullRequest extends PullRequestBase {}
 
 export type BranchLike = Branch | PullRequest;
 
index 11f63dd2f8c4392067358b56abf20e05ee11cbf5..48a85909af1c62aced4a04250195924367ecebe9 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 { isPortfolioLike } from '~sonar-aligned/helpers/component';
 import { ComponentQualifier } from '~sonar-aligned/types/component';
-import { isPortfolioLike } from '../sonar-aligned/helpers/component';
 import { Task } from './tasks';
 import { Component, LightComponent } from './types';
 
index 76e29b5be915deee6a44ea7b1477240255c9d3e2..986484e57129e43e42911c6ecf1f9d01e86ba3f9 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 { Status } from '~sonar-aligned/types/common';
 import { MetricKey } from '~sonar-aligned/types/metrics';
-import { Status } from './types';
 
 interface BaseAnalysis {
   buildString?: string;
index 34412f89c9f88fcef661d4a2e98e1108a0b483c2..308147bad967058ee6a2a35971364b1d1b772a53 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 { Status } from '~sonar-aligned/types/common';
 import { MetricKey } from '~sonar-aligned/types/metrics';
 import { BranchLike } from './branch-like';
-import { CaycStatus, MeasureEnhanced, Metric, Status } from './types';
+import { CaycStatus, MeasureEnhanced, Metric } from './types';
 import { UserBase } from './users';
 
 export interface QualityGateProjectStatus {
index cfb310e230c8fa728e890baee01d6bda00afbe5b..16daeeb7c756006dd3050d86cf00abf22721aa1b 100644 (file)
@@ -712,8 +712,6 @@ export interface SourceViewerFile {
 
 export type StandardSecurityCategories = Dict<{ title: string; description?: string }>;
 
-export type Status = 'ERROR' | 'OK';
-
 export interface SubscriptionPlan {
   maxNcloc: number;
   price: number;