aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViktor Vorona <viktor.vorona@sonarsource.com>2024-04-26 16:53:27 +0200
committerMatteo Mara <matteo.mara@sonarsource.com>2024-04-30 10:59:04 +0200
commit0dd09e52aaa4ab4615fba52c481b1d755a40d8a1 (patch)
tree69099c3d4c86e0a34b39172ab5c8f262e2d6ef05
parentaa5fce137e98bb210719474cd5e6095bb60bc1da (diff)
downloadsonarqube-0dd09e52aaa4ab4615fba52c481b1d755a40d8a1.tar.gz
sonarqube-0dd09e52aaa4ab4615fba52c481b1d755a40d8a1.zip
SONAR-22049 Align isPortfolioLike
-rw-r--r--server/sonar-web/src/main/js/app/components/ComponentContainer.tsx3
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/Search.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/code/utils.ts2
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/App.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFilters.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx3
-rw-r--r--server/sonar-web/src/main/js/helpers/urls.ts3
-rw-r--r--server/sonar-web/src/main/js/queries/branch.tsx3
-rw-r--r--server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/__snapshots__/component-test.ts.snap15
-rw-r--r--server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/component-test.ts32
-rw-r--r--server/sonar-web/src/main/js/sonar-aligned/helpers/component.ts30
-rw-r--r--server/sonar-web/src/main/js/types/__tests__/__snapshots__/component-test.ts.snap14
-rw-r--r--server/sonar-web/src/main/js/types/__tests__/component-test.ts4
-rw-r--r--server/sonar-web/src/main/js/types/component.ts10
27 files changed, 114 insertions, 46 deletions
diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
index e05163099ab..228a263d93b 100644
--- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
+++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
@@ -33,9 +33,10 @@ 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, isPortfolioLike } from '../../types/component';
+import { isFile } from '../../types/component';
import { Feature } from '../../types/features';
import { Task, TaskStatuses, TaskTypes } from '../../types/tasks';
import { Component } from '../../types/types';
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx
index c36789459d4..46d1e5da731 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx
@@ -35,7 +35,8 @@ 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 { isApplication, isPortfolioLike, isProject } from '../../../../types/component';
+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';
import withAvailableFeatures, {
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx
index bff801dbc15..00a3ee090e8 100644
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx
+++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx
@@ -34,7 +34,7 @@ import {
getProjectUrl,
getPullRequestUrl,
} from '../../../helpers/urls';
-import { isPortfolioLike } from '../../../types/component';
+import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
import { Task } from '../../../types/tasks';
interface Props {
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 a598b092069..60a76bd2db9 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
@@ -25,7 +25,7 @@ import withComponentContext from '../../../app/components/componentContext/withC
import withMetricsContext from '../../../app/components/metrics/withMetricsContext';
import { CodeScope, getCodeUrl, getProjectUrl } from '../../../helpers/urls';
import { WithBranchLikesProps, useBranchesQuery } from '../../../queries/branch';
-import { isPortfolioLike } from '../../../types/component';
+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';
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 7b50ee8b8fb..71f21866ede 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
@@ -39,8 +39,9 @@ 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, isPortfolioLike } from '../../../types/component';
+import { isApplication } from '../../../types/component';
import { Breadcrumb, Component, ComponentMeasure, Dict, Metric } from '../../../types/types';
import { getCodeMetrics } from '../utils';
import CodeBreadcrumbs from './CodeBreadcrumbs';
diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx
index f06edd9d8d9..be00b55a9f1 100644
--- a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx
@@ -26,8 +26,9 @@ 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, isPortfolioLike, isProject } from '../../../types/component';
+import { isApplication, isProject } from '../../../types/component';
import { ComponentMeasure } from '../../../types/types';
import { mostCommonPrefix } from '../utils';
diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx
index 7c5f749e512..e50a6a6e898 100644
--- a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx
@@ -19,13 +19,13 @@
*/
import { ContentCell, NumericalCell, RatingCell } from 'design-system';
import * as React from 'react';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
import { MetricKey } from '~sonar-aligned/types/metrics';
import {
CCT_SOFTWARE_QUALITY_METRICS,
OLD_TO_NEW_TAXONOMY_METRICS_MAP,
} from '../../../helpers/constants';
import { translate } from '../../../helpers/l10n';
-import { isPortfolioLike } from '../../../types/component';
import { ComponentMeasure } from '../../../types/types';
interface ComponentsHeaderProps {
diff --git a/server/sonar-web/src/main/js/apps/code/components/Search.tsx b/server/sonar-web/src/main/js/apps/code/components/Search.tsx
index ce7cb76897d..17db6ae5525 100644
--- a/server/sonar-web/src/main/js/apps/code/components/Search.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/Search.tsx
@@ -28,8 +28,9 @@ 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 { isPortfolioLike, isView } from '../../../types/component';
+import { isView } from '../../../types/component';
import { ComponentMeasure } from '../../../types/types';
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 60a43d3cd4b..fc0d3d09c22 100644
--- a/server/sonar-web/src/main/js/apps/code/utils.ts
+++ b/server/sonar-web/src/main/js/apps/code/utils.ts
@@ -18,13 +18,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getBranchLikeQuery } 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 { isPortfolioLike } from '../../types/component';
import { Breadcrumb, ComponentMeasure } from '../../types/types';
import {
addComponent,
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx
index a699e6a12cb..b04b06bcb44 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx
@@ -48,7 +48,7 @@ import { isPullRequest, isSameBranchLike } from '../../../helpers/branch-like';
import { translate } from '../../../helpers/l10n';
import { areLeakAndOverallCCTMeasuresComputed } from '../../../helpers/measures';
import { WithBranchLikesProps, useBranchesQuery } from '../../../queries/branch';
-import { isPortfolioLike } from '../../../types/component';
+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';
diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx
index bce2730448a..a6ef20e483b 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx
@@ -62,8 +62,9 @@ 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 { isPortfolioLike, isProject } from '../../../types/component';
+import { isProject } from '../../../types/component';
import {
ASSIGNEE_ME,
Facet,
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx
index 182d77c96c2..a54aeb4fb15 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx
@@ -25,9 +25,10 @@ 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, isPortfolioLike, isProject, isView } from '../../../types/component';
+import { isApplication, isProject, isView } from '../../../types/component';
import {
Facet,
ReferencedComponent,
diff --git a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx
index 41c4648b96d..2cc345e1ba6 100644
--- a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx
@@ -32,9 +32,9 @@ import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissi
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 { isPortfolioLike } from '../../../types/component';
import { Analysis, GraphType, MeasureHistory } from '../../../types/project-activity';
import { QualityGateStatus } from '../../../types/quality-gates';
import { Component, MeasureEnhanced, Metric, Period, QualityGate } from '../../../types/types';
diff --git a/server/sonar-web/src/main/js/apps/overview/components/App.tsx b/server/sonar-web/src/main/js/apps/overview/components/App.tsx
index 661321fea7a..4c7a33f930e 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/App.tsx
@@ -27,7 +27,7 @@ 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 '../../../types/component';
+import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
import { Feature } from '../../../types/features';
import { Component } from '../../../types/types';
import BranchOverview from '../branches/BranchOverview';
diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx
index 08a16d37679..f72eae8e24b 100644
--- a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx
+++ b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx
@@ -25,7 +25,8 @@ import { Image } from '../../../../components/common/Image';
import { translate } from '../../../../helpers/l10n';
import { isDefined } from '../../../../helpers/types';
import { useGithubProvisioningEnabledQuery } from '../../../../queries/identity-provider/github';
-import { isApplication, isPortfolioLike, isProject } from '../../../../types/component';
+import { isPortfolioLike } from '../../../../sonar-aligned/helpers/component';
+import { isApplication, isProject } from '../../../../types/component';
import { Component } from '../../../../types/types';
import ApplyTemplate from './ApplyTemplate';
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx
index 54097f3488c..dca1b0e056c 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx
@@ -20,6 +20,7 @@
import React from 'react';
import { useLocation, useRouter } from '~sonar-aligned/components/hoc/withRouter';
import { getBranchLikeQuery } from '~sonar-aligned/helpers/branch-like';
+import { isPortfolioLike } from '~sonar-aligned/helpers/component';
import { MetricKey } from '~sonar-aligned/types/metrics';
import {
useComponent,
@@ -37,7 +38,7 @@ import useApplicationLeakQuery from '../../../queries/applications';
import { useBranchesQuery } from '../../../queries/branch';
import { useAllMeasuresHistoryQuery } from '../../../queries/measures';
import { useAllProjectAnalysesQuery } from '../../../queries/project-analyses';
-import { isApplication, isPortfolioLike, isProject } from '../../../types/component';
+import { isApplication, isProject } from '../../../types/component';
import { MeasureHistory, ParsedAnalysis } from '../../../types/project-activity';
import { Query, parseQuery, serializeUrlQuery } from '../utils';
import ProjectActivityAppRenderer from './ProjectActivityAppRenderer';
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFilters.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFilters.tsx
index eb2348a7dab..b1251e4eddd 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFilters.tsx
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFilters.tsx
@@ -21,7 +21,7 @@ import { InputSelect, LabelValueSelectOption } from 'design-system';
import * as React from 'react';
import { ComponentQualifier } from '~sonar-aligned/types/component';
import { translate } from '../../../helpers/l10n';
-import { isPortfolioLike } from '../../../types/component';
+import { isPortfolioLike } from '../../../sonar-aligned/helpers/component';
import {
ApplicationAnalysisEventCategory,
ProjectAnalysisEventCategory,
diff --git a/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx b/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx
index 8da90b6c0dd..4ca0bbcb80b 100644
--- a/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx
+++ b/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx
@@ -26,7 +26,8 @@ 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 { isApplication, isPortfolioLike } from '../../types/component';
+import { isPortfolioLike } from '../../sonar-aligned/helpers/component';
+import { isApplication } from '../../types/component';
import { Component } from '../../types/types';
interface Props {
diff --git a/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx b/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx
index af08d4c38f3..44cef2bea20 100644
--- a/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx
+++ b/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx
@@ -20,7 +20,8 @@
import { Title } from 'design-system';
import * as React from 'react';
import { translate } from '../../helpers/l10n';
-import { isApplication, isPortfolioLike } from '../../types/component';
+import { isPortfolioLike } from '../../sonar-aligned/helpers/component';
+import { isApplication } from '../../types/component';
import { Component } from '../../types/types';
interface Props {
diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts
index c4fa26967fe..f8855c86d6b 100644
--- a/server/sonar-web/src/main/js/helpers/urls.ts
+++ b/server/sonar-web/src/main/js/helpers/urls.ts
@@ -24,8 +24,9 @@ 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, isPortfolioLike } from '../types/component';
+import { isApplication } from '../types/component';
import { MeasurePageView } from '../types/measures';
import { GraphType } from '../types/project-activity';
import { Dict } from '../types/types';
diff --git a/server/sonar-web/src/main/js/queries/branch.tsx b/server/sonar-web/src/main/js/queries/branch.tsx
index 642f58db08f..4e0644d48c5 100644
--- a/server/sonar-web/src/main/js/queries/branch.tsx
+++ b/server/sonar-web/src/main/js/queries/branch.tsx
@@ -39,8 +39,9 @@ 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, isPortfolioLike, isProject } from '../types/component';
+import { isApplication, isProject } from '../types/component';
import { Feature } from '../types/features';
import { Component, LightComponent } from '../types/types';
diff --git a/server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/__snapshots__/component-test.ts.snap b/server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/__snapshots__/component-test.ts.snap
new file mode 100644
index 00000000000..8c0c1bfd06d
--- /dev/null
+++ b/server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/__snapshots__/component-test.ts.snap
@@ -0,0 +1,15 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`[Function isPortfolioLike] should work properly 1`] = `
+{
+ "APP": false,
+ "BRC": false,
+ "DEV": false,
+ "DIR": false,
+ "FIL": false,
+ "SVW": true,
+ "TRK": false,
+ "UTS": false,
+ "VW": true,
+}
+`;
diff --git a/server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/component-test.ts b/server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/component-test.ts
new file mode 100644
index 00000000000..cbc68999f94
--- /dev/null
+++ b/server/sonar-web/src/main/js/sonar-aligned/helpers/__tests__/component-test.ts
@@ -0,0 +1,32 @@
+/*
+ * 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 { ComponentQualifier } from '~sonar-aligned/types/component';
+import { isPortfolioLike } from '../component';
+
+it.each([[isPortfolioLike]])(
+ '%p should work properly',
+ (utilityMethod: (componentQualifier: ComponentQualifier) => void) => {
+ const results = Object.values(ComponentQualifier).reduce(
+ (prev, qualifier) => ({ ...prev, [qualifier]: utilityMethod(qualifier) }),
+ {},
+ );
+ expect(results).toMatchSnapshot();
+ },
+);
diff --git a/server/sonar-web/src/main/js/sonar-aligned/helpers/component.ts b/server/sonar-web/src/main/js/sonar-aligned/helpers/component.ts
new file mode 100644
index 00000000000..0be481e4617
--- /dev/null
+++ b/server/sonar-web/src/main/js/sonar-aligned/helpers/component.ts
@@ -0,0 +1,30 @@
+/*
+ * 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 { ComponentQualifier } from '~sonar-aligned/types/component';
+
+export function isPortfolioLike(
+ componentQualifier?: string | ComponentQualifier,
+): componentQualifier is ComponentQualifier.Portfolio | ComponentQualifier.SubPortfolio {
+ return (
+ componentQualifier === ComponentQualifier.Portfolio ||
+ componentQualifier === ComponentQualifier.SubPortfolio
+ );
+}
diff --git a/server/sonar-web/src/main/js/types/__tests__/__snapshots__/component-test.ts.snap b/server/sonar-web/src/main/js/types/__tests__/__snapshots__/component-test.ts.snap
index 519f2d6f978..705b12fb87f 100644
--- a/server/sonar-web/src/main/js/types/__tests__/__snapshots__/component-test.ts.snap
+++ b/server/sonar-web/src/main/js/types/__tests__/__snapshots__/component-test.ts.snap
@@ -28,20 +28,6 @@ exports[`[Function isFile] should work properly 1`] = `
}
`;
-exports[`[Function isPortfolioLike] should work properly 1`] = `
-{
- "APP": false,
- "BRC": false,
- "DEV": false,
- "DIR": false,
- "FIL": false,
- "SVW": true,
- "TRK": false,
- "UTS": false,
- "VW": true,
-}
-`;
-
exports[`[Function isProject] should work properly 1`] = `
{
"APP": false,
diff --git a/server/sonar-web/src/main/js/types/__tests__/component-test.ts b/server/sonar-web/src/main/js/types/__tests__/component-test.ts
index f024bff9c14..1a2d237f6de 100644
--- a/server/sonar-web/src/main/js/types/__tests__/component-test.ts
+++ b/server/sonar-web/src/main/js/types/__tests__/component-test.ts
@@ -18,9 +18,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { ComponentQualifier } from '~sonar-aligned/types/component';
-import { isApplication, isFile, isPortfolioLike, isProject, isView } from '../component';
+import { isApplication, isFile, isProject, isView } from '../component';
-it.each([[isFile], [isView], [isProject], [isApplication], [isPortfolioLike]])(
+it.each([[isFile], [isView], [isProject], [isApplication]])(
'%p should work properly',
(utilityMethod: (componentQualifier: ComponentQualifier) => void) => {
const results = Object.values(ComponentQualifier).reduce(
diff --git a/server/sonar-web/src/main/js/types/component.ts b/server/sonar-web/src/main/js/types/component.ts
index b70eaca84f1..11f63dd2f8c 100644
--- a/server/sonar-web/src/main/js/types/component.ts
+++ b/server/sonar-web/src/main/js/types/component.ts
@@ -18,6 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { ComponentQualifier } from '~sonar-aligned/types/component';
+import { isPortfolioLike } from '../sonar-aligned/helpers/component';
import { Task } from './tasks';
import { Component, LightComponent } from './types';
@@ -48,15 +49,6 @@ export interface TreeComponentWithPath extends TreeComponent {
path: string;
}
-export function isPortfolioLike(
- componentQualifier?: string | ComponentQualifier,
-): componentQualifier is ComponentQualifier.Portfolio | ComponentQualifier.SubPortfolio {
- return (
- componentQualifier === ComponentQualifier.Portfolio ||
- componentQualifier === ComponentQualifier.SubPortfolio
- );
-}
-
export function isApplication(
componentQualifier?: string | ComponentQualifier,
): componentQualifier is ComponentQualifier.Application {