aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorPhilippe Perrin <philippe.perrin@sonarsource.com>2019-11-27 22:16:40 +0100
committerSonarTech <sonartech@sonarsource.com>2019-12-09 20:46:17 +0100
commit064e1d872f584f4568a12fa0f31e6a4f975a7437 (patch)
tree2dba1212e3aff2309b4d016c75ae5d9809bf423c /server
parent7197bceddc7c51d51cd46e22b68cdc71d277aa65 (diff)
downloadsonarqube-064e1d872f584f4568a12fa0f31e6a4f975a7437.tar.gz
sonarqube-064e1d872f584f4568a12fa0f31e6a4f975a7437.zip
SONAR-12679 Drop short & long living branch concept
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/api/branches.ts5
-rw-r--r--server/sonar-web/src/main/js/api/components.ts21
-rw-r--r--server/sonar-web/src/main/js/api/measures.ts3
-rw-r--r--server/sonar-web/src/main/js/api/nav.ts3
-rw-r--r--server/sonar-web/src/main/js/api/projectActivity.ts3
-rw-r--r--server/sonar-web/src/main/js/api/quality-gates.ts3
-rw-r--r--server/sonar-web/src/main/js/api/settings.ts7
-rw-r--r--server/sonar-web/src/main/js/api/time-machine.ts5
-rw-r--r--server/sonar-web/src/main/js/app/components/ComponentContainer.tsx36
-rw-r--r--server/sonar-web/src/main/js/app/components/ComponentContext.tsx3
-rw-r--r--server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx5
-rw-r--r--server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx52
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/ProjectPageExtension.tsx3
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/__tests__/ProjectPageExtension-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/ProjectPageExtension-test.tsx.snap1
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts10
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/ComponentBreadcrumb.tsx5
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx5
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx5
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.tsx14
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx24
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentBreadcrumb-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavHeader-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx39
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx28
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavHeader-test.tsx.snap29
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMenu-test.tsx.snap379
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMeta-test.tsx.snap33
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx5
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLike.tsx5
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLikeMergeInformation.tsx5
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx21
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx7
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItemList.tsx11
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/BranchLikeNavigation-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/CurrentBranchLike-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/CurrentBranchLikeMergeInformation-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/Menu-test.tsx9
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/MenuItem-test.tsx7
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/MenuItemList-test.tsx9
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/BranchLikeNavigation-test.tsx.snap29
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/Menu-test.tsx.snap38
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/MenuItemList-test.tsx.snap31
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx21
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap4
-rw-r--r--server/sonar-web/src/main/js/apps/code/__tests__/utils-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/App.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/Component.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/ComponentPin.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/Components.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/Search.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/__tests__/App-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentName-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/__tests__/Components-test.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentName-test.tsx.snap4
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Components-test.tsx.snap38
-rw-r--r--server/sonar-web/src/main/js/apps/code/utils.ts19
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/App.tsx16
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx10
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx25
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/MeasureHeader-test.tsx.snap45
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx7
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/utils.ts16
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/App.tsx14
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesSourceViewer-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetViewer-test.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/SnippetViewer-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/overview/badges/ProjectBadges.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/overview/badges/__tests__/ProjectBadges-test.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/App.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx12
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/__tests__/OverviewApp-test.tsx13
-rw-r--r--server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/overview/events/__tests__/AnalysesList-test.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/overview/main/Bugs.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/overview/main/__tests__/Bugs-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/overview/main/__tests__/CodeSmells-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/overview/main/__tests__/Coverage-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/overview/main/__tests__/Duplications-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/overview/main/__tests__/VulnerabilitiesAndHotspots-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/overview/main/enhance.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/meta/MetaSize.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/IssueLabel.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/IssueRating.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/MeasurementLabel.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/ReviewApp.tsx7
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/IssueLabel-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/IssueRating-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/MeasurementLabel-test.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/ReviewApp-test.tsx7
-rw-r--r--server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/__snapshots__/MeasurementLabel-test.tsx.snap16
-rw-r--r--server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx7
-rw-r--r--server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGateCondition-test.tsx.snap1
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/DefinitionChangeEventInner-test.tsx.snap10
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchBaselineSettingModal-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchList-test.tsx15
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BranchList-test.tsx.snap9
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/components/BranchBaselineSettingModal.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/components/BranchList.tsx13
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx19
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx18
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTabs-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx12
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap17
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap109
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap54
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTabs-test.tsx.snap21
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx17
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/SourceViewerContext.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeader-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeaderSlim-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx7
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/Line-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineOptionsPopup-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx9
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineCode-test.tsx.snap4
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/helpers/__tests__/loadIssues-test.ts2
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts7
-rw-r--r--server/sonar-web/src/main/js/components/common/BranchStatus.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx6
-rw-r--r--server/sonar-web/src/main/js/components/icons/BranchLikeIcon.tsx9
-rw-r--r--server/sonar-web/src/main/js/components/icons/__tests__/BranchLikeIcon-test.tsx15
-rw-r--r--server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/BranchLikeIcon-test.tsx.snap6
-rw-r--r--server/sonar-web/src/main/js/components/issue/Issue.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/issue/IssueView.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/IssueChangelogDiff.tsx7
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelogDiff-test.tsx41
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.tsx9
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueChangelogDiff-test.tsx.snap34
-rw-r--r--server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/workspace/WorkspaceComponentViewer.tsx9
-rw-r--r--server/sonar-web/src/main/js/components/workspace/__tests__/WorkspaceComponentViewer-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/workspace/context.ts3
-rw-r--r--server/sonar-web/src/main/js/helpers/__tests__/branches-test.ts101
-rw-r--r--server/sonar-web/src/main/js/helpers/branch-like.ts (renamed from server/sonar-web/src/main/js/helpers/branches.ts)75
-rw-r--r--server/sonar-web/src/main/js/helpers/mocks/branch-like.ts (renamed from server/sonar-web/src/main/js/helpers/mocks/branch-pull-request.tsx)49
-rw-r--r--server/sonar-web/src/main/js/helpers/testMocks.ts49
-rw-r--r--server/sonar-web/src/main/js/helpers/urls.ts25
-rw-r--r--server/sonar-web/src/main/js/store/__tests__/branches-test.ts19
-rw-r--r--server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx5
-rw-r--r--server/sonar-web/src/main/js/store/__tests__/rootReducers-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/store/branches.ts7
-rw-r--r--server/sonar-web/src/main/js/store/rootActions.ts11
-rw-r--r--server/sonar-web/src/main/js/store/rootReducer.ts3
-rw-r--r--server/sonar-web/src/main/js/types/branch-like.d.ts79
-rw-r--r--server/sonar-web/src/main/js/types/branch-like.ts63
-rw-r--r--server/sonar-web/src/main/js/types/types.d.ts1
200 files changed, 1094 insertions, 1512 deletions
diff --git a/server/sonar-web/src/main/js/api/branches.ts b/server/sonar-web/src/main/js/api/branches.ts
index 0bf62d734b6..d2c152405f0 100644
--- a/server/sonar-web/src/main/js/api/branches.ts
+++ b/server/sonar-web/src/main/js/api/branches.ts
@@ -19,12 +19,13 @@
*/
import { getJSON, post } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
+import { Branch, PullRequest } from '../types/branch-like';
-export function getBranches(project: string): Promise<T.Branch[]> {
+export function getBranches(project: string): Promise<Branch[]> {
return getJSON('/api/project_branches/list', { project }).then(r => r.branches, throwGlobalError);
}
-export function getPullRequests(project: string): Promise<T.PullRequest[]> {
+export function getPullRequests(project: string): Promise<PullRequest[]> {
return getJSON('/api/project_pull_requests/list', { project }).then(
r => r.pullRequests,
throwGlobalError
diff --git a/server/sonar-web/src/main/js/api/components.ts b/server/sonar-web/src/main/js/api/components.ts
index 8b26dacc1bb..32b7933674e 100644
--- a/server/sonar-web/src/main/js/api/components.ts
+++ b/server/sonar-web/src/main/js/api/components.ts
@@ -19,6 +19,7 @@
*/
import { getJSON, post, postJSON, RequestData } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
+import { BranchParameters } from '../types/branch-like';
export interface BaseSearchProjectsParameters {
analyzedBefore?: string;
@@ -121,7 +122,7 @@ export function getComponentLeaves(
}
export function getComponent(
- data: { component: string; metricKeys: string } & T.BranchParameters
+ data: { component: string; metricKeys: string } & BranchParameters
): Promise<{ component: T.ComponentMeasure }> {
return getJSON('/api/measures/component', data);
}
@@ -148,7 +149,7 @@ type GetTreeParams = {
q?: string;
s?: string;
strategy?: 'all' | 'leaves' | 'children';
-} & T.BranchParameters;
+} & BranchParameters;
export function getTree<T = TreeComponent>(
data: GetTreeParams & { qualifiers?: string }
@@ -164,17 +165,17 @@ export function getDirectories(data: GetTreeParams) {
return getTree<TreeComponentWithPath>({ ...data, qualifiers: 'DIR' });
}
-export function getComponentData(data: { component: string } & T.BranchParameters): Promise<any> {
+export function getComponentData(data: { component: string } & BranchParameters): Promise<any> {
return getJSON('/api/components/show', data);
}
export function doesComponentExists(
- data: { component: string } & T.BranchParameters
+ data: { component: string } & BranchParameters
): Promise<boolean> {
return getComponentData(data).then(({ component }) => component !== undefined, () => false);
}
-export function getComponentShow(data: { component: string } & T.BranchParameters): Promise<any> {
+export function getComponentShow(data: { component: string } & BranchParameters): Promise<any> {
return getComponentData(data).catch(throwGlobalError);
}
@@ -182,7 +183,7 @@ export function getParents(component: string): Promise<any> {
return getComponentShow({ component }).then(r => r.ancestors);
}
-export function getBreadcrumbs(data: { component: string } & T.BranchParameters): Promise<any> {
+export function getBreadcrumbs(data: { component: string } & BranchParameters): Promise<any> {
return getComponentShow(data).then(r => {
const reversedAncestors = [...r.ancestors].reverse();
return [...reversedAncestors, r.component];
@@ -275,25 +276,25 @@ export function getSuggestions(
}
export function getComponentForSourceViewer(
- data: { component: string } & T.BranchParameters
+ data: { component: string } & BranchParameters
): Promise<T.SourceViewerFile> {
return getJSON('/api/components/app', data);
}
export function getSources(
- data: { key: string; from?: number; to?: number } & T.BranchParameters
+ data: { key: string; from?: number; to?: number } & BranchParameters
): Promise<T.SourceLine[]> {
return getJSON('/api/sources/lines', data).then(r => r.sources);
}
export function getDuplications(
- data: { key: string } & T.BranchParameters
+ data: { key: string } & BranchParameters
): Promise<{ duplications: T.Duplication[]; files: T.Dict<T.DuplicatedFile> }> {
return getJSON('/api/duplications/show', data).catch(throwGlobalError);
}
export function getTests(
- data: { sourceFileKey: string; sourceFileLineNumber: number | string } & T.BranchParameters
+ data: { sourceFileKey: string; sourceFileLineNumber: number | string } & BranchParameters
): Promise<any> {
return getJSON('/api/tests/list', data).then(r => r.tests);
}
diff --git a/server/sonar-web/src/main/js/api/measures.ts b/server/sonar-web/src/main/js/api/measures.ts
index 455fa131a8e..6f62cab0561 100644
--- a/server/sonar-web/src/main/js/api/measures.ts
+++ b/server/sonar-web/src/main/js/api/measures.ts
@@ -19,9 +19,10 @@
*/
import { getJSON, post, postJSON, RequestData } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
+import { BranchParameters } from '../types/branch-like';
export function getMeasures(
- data: { component: string; metricKeys: string } & T.BranchParameters
+ data: { component: string; metricKeys: string } & BranchParameters
): Promise<T.Measure[]> {
return getJSON('/api/measures/component', data).then(r => r.component.measures, throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/nav.ts b/server/sonar-web/src/main/js/api/nav.ts
index 9d1fdcec5e6..c09a42be697 100644
--- a/server/sonar-web/src/main/js/api/nav.ts
+++ b/server/sonar-web/src/main/js/api/nav.ts
@@ -19,6 +19,7 @@
*/
import { getJSON } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
+import { BranchParameters } from '../types/branch-like';
export function getGlobalNavigation(): Promise<T.AppState> {
return getJSON('/api/navigation/global');
@@ -27,7 +28,7 @@ export function getGlobalNavigation(): Promise<T.AppState> {
type NavComponent = T.Omit<T.Component, 'alm' | 'qualifier' | 'leakPeriodDate' | 'path' | 'tags'>;
export function getComponentNavigation(
- data: { component: string } & T.BranchParameters
+ data: { component: string } & BranchParameters
): Promise<NavComponent> {
return getJSON('/api/navigation/component', data).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/projectActivity.ts b/server/sonar-web/src/main/js/api/projectActivity.ts
index 20aa8e8e89b..7b639df7931 100644
--- a/server/sonar-web/src/main/js/api/projectActivity.ts
+++ b/server/sonar-web/src/main/js/api/projectActivity.ts
@@ -19,6 +19,7 @@
*/
import { getJSON, post, postJSON, RequestData } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
+import { BranchParameters } from '../types/branch-like';
export function getProjectActivity(
data: {
@@ -27,7 +28,7 @@ export function getProjectActivity(
from?: string;
p?: number;
ps?: number;
- } & T.BranchParameters
+ } & BranchParameters
): Promise<{ analyses: T.Analysis[]; paging: T.Paging }> {
return getJSON('/api/project_analyses/search', data).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/quality-gates.ts b/server/sonar-web/src/main/js/api/quality-gates.ts
index b881adfefd6..fa63e0d1b20 100644
--- a/server/sonar-web/src/main/js/api/quality-gates.ts
+++ b/server/sonar-web/src/main/js/api/quality-gates.ts
@@ -19,6 +19,7 @@
*/
import { getJSON, post, postJSON } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
+import { BranchParameters } from '../types/branch-like';
export function fetchQualityGates(data: {
organization?: string;
@@ -174,7 +175,7 @@ export function getQualityGateProjectStatus(
data: {
projectKey?: string;
projectId?: string;
- } & T.BranchParameters
+ } & BranchParameters
): Promise<T.QualityGateProjectStatus> {
return getJSON('/api/qualitygates/project_status', data)
.then(r => r.projectStatus)
diff --git a/server/sonar-web/src/main/js/api/settings.ts b/server/sonar-web/src/main/js/api/settings.ts
index f6426a81593..5b9798f52c2 100644
--- a/server/sonar-web/src/main/js/api/settings.ts
+++ b/server/sonar-web/src/main/js/api/settings.ts
@@ -21,6 +21,7 @@ import { omitBy } from 'lodash';
import { getJSON, post, postJSON, RequestData } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
import { isCategoryDefinition } from '../apps/settings/utils';
+import { BranchParameters } from '../types/branch-like';
export function getDefinitions(component?: string): Promise<T.SettingCategoryDefinition[]> {
return getJSON('/api/settings/list_definitions', { component }).then(
@@ -30,7 +31,7 @@ export function getDefinitions(component?: string): Promise<T.SettingCategoryDef
}
export function getValues(
- data: { keys: string; component?: string } & T.BranchParameters
+ data: { keys: string; component?: string } & BranchParameters
): Promise<T.SettingValue[]> {
return getJSON('/api/settings/values', data).then(r => r.settings);
}
@@ -57,13 +58,13 @@ export function setSettingValue(
}
export function setSimpleSettingValue(
- data: { component?: string; value: string; key: string } & T.BranchParameters
+ data: { component?: string; value: string; key: string } & BranchParameters
): Promise<void | Response> {
return post('/api/settings/set', data).catch(throwGlobalError);
}
export function resetSettingValue(
- data: { keys: string; component?: string } & T.BranchParameters
+ data: { keys: string; component?: string } & BranchParameters
): Promise<void> {
return post('/api/settings/reset', data);
}
diff --git a/server/sonar-web/src/main/js/api/time-machine.ts b/server/sonar-web/src/main/js/api/time-machine.ts
index af307b524bc..43018b3b595 100644
--- a/server/sonar-web/src/main/js/api/time-machine.ts
+++ b/server/sonar-web/src/main/js/api/time-machine.ts
@@ -19,6 +19,7 @@
*/
import { getJSON } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
+import { BranchParameters } from '../types/branch-like';
interface TimeMachineResponse {
measures: {
@@ -36,7 +37,7 @@ export function getTimeMachineData(
p?: number;
ps?: number;
to?: string;
- } & T.BranchParameters
+ } & BranchParameters
): Promise<TimeMachineResponse> {
return getJSON('/api/measures/search_history', data).catch(throwGlobalError);
}
@@ -48,7 +49,7 @@ export function getAllTimeMachineData(
from?: string;
p?: number;
to?: string;
- } & T.BranchParameters,
+ } & BranchParameters,
prev?: TimeMachineResponse
): Promise<TimeMachineResponse> {
return getTimeMachineData({ ...data, ps: 1000 }).then(r => {
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 0b9ba73cd8b..7e645c6d434 100644
--- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
+++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
@@ -29,17 +29,16 @@ import { Location, Router, withRouter } from '../../components/hoc/withRouter';
import {
getBranchLikeQuery,
isBranch,
- isLongLivingBranch,
isMainBranch,
- isPullRequest,
- isShortLivingBranch
-} from '../../helpers/branches';
+ isPullRequest
+} from '../../helpers/branch-like';
import { isSonarCloud } from '../../helpers/system';
import {
fetchOrganization,
registerBranchStatus,
requireAuthorization
} from '../../store/rootActions';
+import { BranchLike } from '../../types/branch-like';
import ComponentContainerNotFound from './ComponentContainerNotFound';
import { ComponentContext } from './ComponentContext';
import ComponentNav from './nav/component/ComponentNav';
@@ -48,14 +47,14 @@ interface Props {
children: React.ReactElement;
fetchOrganization: (organization: string) => void;
location: Pick<Location, 'query'>;
- registerBranchStatus: (branchLike: T.BranchLike, component: string, status: T.Status) => void;
+ registerBranchStatus: (branchLike: BranchLike, component: string, status: T.Status) => void;
requireAuthorization: (router: Pick<Router, 'replace'>) => void;
router: Pick<Router, 'replace'>;
}
interface State {
- branchLike?: T.BranchLike;
- branchLikes: T.BranchLike[];
+ branchLike?: BranchLike;
+ branchLikes: BranchLike[];
component?: T.Component;
currentTask?: T.Task;
isPending: boolean;
@@ -143,8 +142,8 @@ export class ComponentContainer extends React.PureComponent<Props, State> {
fetchBranches = (
component: T.Component
): Promise<{
- branchLike?: T.BranchLike;
- branchLikes: T.BranchLike[];
+ branchLike?: BranchLike;
+ branchLikes: BranchLike[];
component: T.Component;
}> => {
const breadcrumb = component.breadcrumbs.find(({ qualifier }) => {
@@ -222,7 +221,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> {
);
};
- fetchWarnings = (component: T.Component, branchLike?: T.BranchLike) => {
+ fetchWarnings = (component: T.Component, branchLike?: BranchLike) => {
if (component.qualifier === 'TRK') {
getAnalysisStatus({
component: component.key,
@@ -236,14 +235,14 @@ export class ComponentContainer extends React.PureComponent<Props, State> {
}
};
- getCurrentBranchLike = (branchLikes: T.BranchLike[]) => {
+ getCurrentBranchLike = (branchLikes: BranchLike[]) => {
const { query } = this.props.location;
return query.pullRequest
? branchLikes.find(b => isPullRequest(b) && b.key === query.pullRequest)
: branchLikes.find(b => isBranch(b) && (query.branch ? b.name === query.branch : b.isMain));
};
- getCurrentTask = (current: T.Task, branchLike?: T.BranchLike) => {
+ getCurrentTask = (current: T.Task, branchLike?: BranchLike) => {
if (!current) {
return undefined;
}
@@ -253,26 +252,23 @@ export class ComponentContainer extends React.PureComponent<Props, State> {
: undefined;
};
- getPendingTasks = (pendingTasks: T.Task[], branchLike?: T.BranchLike) => {
+ getPendingTasks = (pendingTasks: T.Task[], branchLike?: BranchLike) => {
return pendingTasks.filter(task => this.isSameBranch(task, branchLike));
};
- isSameBranch = (
- task: Pick<T.Task, 'branch' | 'branchType' | 'pullRequest'>,
- branchLike?: T.BranchLike
- ) => {
+ isSameBranch = (task: Pick<T.Task, 'branch' | 'pullRequest'>, branchLike?: BranchLike) => {
if (branchLike && !isMainBranch(branchLike)) {
if (isPullRequest(branchLike)) {
return branchLike.key === task.pullRequest;
}
- if (isShortLivingBranch(branchLike) || isLongLivingBranch(branchLike)) {
- return branchLike.type === task.branchType && branchLike.name === task.branch;
+ if (isBranch(branchLike)) {
+ return branchLike.name === task.branch;
}
}
return !task.branch && !task.pullRequest;
};
- registerBranchStatuses = (branchLikes: T.BranchLike[], component: T.Component) => {
+ registerBranchStatuses = (branchLikes: BranchLike[], component: T.Component) => {
branchLikes.forEach(branchLike => {
if (branchLike.status) {
this.props.registerBranchStatus(
diff --git a/server/sonar-web/src/main/js/app/components/ComponentContext.tsx b/server/sonar-web/src/main/js/app/components/ComponentContext.tsx
index 87322aab565..6976c8aa8e3 100644
--- a/server/sonar-web/src/main/js/app/components/ComponentContext.tsx
+++ b/server/sonar-web/src/main/js/app/components/ComponentContext.tsx
@@ -18,9 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { BranchLike } from '../../types/branch-like';
interface ComponentContextType {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
component: T.Component | undefined;
}
diff --git a/server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx b/server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx
index 57c6f32d6bb..d5bce534b87 100644
--- a/server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx
+++ b/server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx
@@ -18,13 +18,14 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { BranchLike } from '../../types/branch-like';
import handleRequiredAuthorization from '../utils/handleRequiredAuthorization';
import A11ySkipTarget from './a11y/A11ySkipTarget';
interface Props {
children: JSX.Element;
- branchLike?: T.BranchLike;
- branchLikes: T.BranchLike[];
+ branchLike?: BranchLike;
+ branchLikes: BranchLike[];
component: T.Component;
isInProgress?: boolean;
isPending?: boolean;
diff --git a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx
index 20a412bbee3..72956b0a254 100644
--- a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx
@@ -25,20 +25,15 @@ import { getTasksForComponent } from '../../../api/ce';
import { getComponentData } from '../../../api/components';
import { getComponentNavigation } from '../../../api/nav';
import { STATUSES } from '../../../apps/background-tasks/constants';
+import { mockBranch, mockMainBranch, mockPullRequest } from '../../../helpers/mocks/branch-like';
import { isSonarCloud } from '../../../helpers/system';
-import {
- mockComponent,
- mockLocation,
- mockLongLivingBranch,
- mockMainBranch,
- mockPullRequest,
- mockRouter,
- mockShortLivingBranch
-} from '../../../helpers/testMocks';
+import { mockComponent, mockLocation, mockRouter } from '../../../helpers/testMocks';
import { ComponentContainer } from '../ComponentContainer';
jest.mock('../../../api/branches', () => {
- const { mockMainBranch, mockPullRequest } = require.requireActual('../../../helpers/testMocks');
+ const { mockMainBranch, mockPullRequest } = require.requireActual(
+ '../../../helpers/mocks/branch-like'
+ );
return {
getBranches: jest
.fn()
@@ -79,7 +74,7 @@ jest.mock('../nav/component/ComponentNav', () => ({
const Inner = () => <div />;
-const mainBranch: T.MainBranch = mockMainBranch();
+const mainBranch = mockMainBranch();
beforeEach(() => {
jest.clearAllMocks();
@@ -154,40 +149,23 @@ it('filters correctly the pending tasks for a main branch', () => {
const wrapper = shallowRender();
const component = wrapper.instance();
const mainBranch = mockMainBranch();
- const shortBranch = mockShortLivingBranch();
- const longBranch = mockLongLivingBranch();
+ const branch3 = mockBranch({ name: 'branch-3' });
+ const branch2 = mockBranch({ name: 'branch-2' });
const pullRequest = mockPullRequest();
expect(component.isSameBranch({}, undefined)).toBeTruthy();
expect(component.isSameBranch({}, mainBranch)).toBeTruthy();
- expect(component.isSameBranch({}, shortBranch)).toBeFalsy();
- expect(
- component.isSameBranch({ branch: shortBranch.name, branchType: 'SHORT' }, shortBranch)
- ).toBeTruthy();
- expect(
- component.isSameBranch({ branch: 'feature', branchType: 'SHORT' }, longBranch)
- ).toBeFalsy();
- expect(
- component.isSameBranch({ branch: 'feature', branchType: 'SHORT' }, longBranch)
- ).toBeFalsy();
- expect(
- component.isSameBranch({ branch: 'branch-6.6', branchType: 'LONG' }, longBranch)
- ).toBeFalsy();
- expect(
- component.isSameBranch({ branch: longBranch.name, branchType: 'LONG' }, longBranch)
- ).toBeTruthy();
- expect(
- component.isSameBranch({ branch: 'branch-6.7', branchType: 'LONG' }, pullRequest)
- ).toBeFalsy();
+ expect(component.isSameBranch({}, branch3)).toBeFalsy();
+ expect(component.isSameBranch({ branch: branch3.name }, branch3)).toBeTruthy();
+ expect(component.isSameBranch({ branch: 'feature' }, branch2)).toBeFalsy();
+ expect(component.isSameBranch({ branch: 'branch-6.6' }, branch2)).toBeFalsy();
+ expect(component.isSameBranch({ branch: branch2.name }, branch2)).toBeTruthy();
+ expect(component.isSameBranch({ branch: 'branch-6.7' }, pullRequest)).toBeFalsy();
expect(component.isSameBranch({ pullRequest: pullRequest.key }, pullRequest)).toBeTruthy();
const currentTask = { pullRequest: pullRequest.key, status: STATUSES.IN_PROGRESS } as T.Task;
const failedTask = { ...currentTask, status: STATUSES.FAILED };
- const pendingTasks = [
- currentTask,
- { branch: shortBranch.name, branchType: 'SHORT' } as T.Task,
- {} as T.Task
- ];
+ const pendingTasks = [currentTask, { branch: branch3.name } as T.Task, {} as T.Task];
expect(component.getCurrentTask(currentTask, undefined)).toBe(undefined);
expect(component.getCurrentTask(failedTask, mainBranch)).toBe(failedTask);
expect(component.getCurrentTask(currentTask, mainBranch)).toBe(undefined);
diff --git a/server/sonar-web/src/main/js/app/components/extensions/ProjectPageExtension.tsx b/server/sonar-web/src/main/js/app/components/extensions/ProjectPageExtension.tsx
index 636c1ba6f04..0f0efb0dcfd 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/ProjectPageExtension.tsx
+++ b/server/sonar-web/src/main/js/app/components/extensions/ProjectPageExtension.tsx
@@ -18,11 +18,12 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { BranchLike } from '../../../types/branch-like';
import NotFound from '../NotFound';
import Extension from './Extension';
export interface ProjectPageExtensionProps {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.Component;
location: { query: { id: string } };
params: {
diff --git a/server/sonar-web/src/main/js/app/components/extensions/__tests__/ProjectPageExtension-test.tsx b/server/sonar-web/src/main/js/app/components/extensions/__tests__/ProjectPageExtension-test.tsx
index c71191ef13a..bce7f972516 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/__tests__/ProjectPageExtension-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/extensions/__tests__/ProjectPageExtension-test.tsx
@@ -20,7 +20,8 @@
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockComponent, mockLocation, mockMainBranch } from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockLocation } from '../../../../helpers/testMocks';
import ProjectPageExtension, { ProjectPageExtensionProps } from '../ProjectPageExtension';
it('should render correctly', () => {
diff --git a/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/ProjectPageExtension-test.tsx.snap b/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/ProjectPageExtension-test.tsx.snap
index 3f3e9501e38..ec2613d5c56 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/ProjectPageExtension-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/ProjectPageExtension-test.tsx.snap
@@ -12,6 +12,7 @@ exports[`should render correctly 1`] = `
Object {
"branchLike": Object {
"analysisDate": "2018-01-01",
+ "excludedFromPurge": true,
"isMain": true,
"name": "master",
},
diff --git a/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts b/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts
index c0231f17d4c..c34c94e5b4b 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts
+++ b/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts
@@ -46,13 +46,13 @@ import Tooltip from 'sonar-ui-common/components/controls/Tooltip';
import AlertErrorIcon from 'sonar-ui-common/components/icons/AlertErrorIcon';
import AlertSuccessIcon from 'sonar-ui-common/components/icons/AlertSuccessIcon';
import AlertWarnIcon from 'sonar-ui-common/components/icons/AlertWarnIcon';
+import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon';
import CheckIcon from 'sonar-ui-common/components/icons/CheckIcon';
import ClearIcon from 'sonar-ui-common/components/icons/ClearIcon';
import DetachIcon from 'sonar-ui-common/components/icons/DetachIcon';
import DropdownIcon from 'sonar-ui-common/components/icons/DropdownIcon';
import HelpIcon from 'sonar-ui-common/components/icons/HelpIcon';
import LockIcon from 'sonar-ui-common/components/icons/LockIcon';
-import LongLivingBranchIcon from 'sonar-ui-common/components/icons/LongLivingBranchIcon';
import PlusCircleIcon from 'sonar-ui-common/components/icons/PlusCircleIcon';
import PullRequestIcon from 'sonar-ui-common/components/icons/PullRequestIcon';
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon';
@@ -75,9 +75,9 @@ import CoverageRating from '../../../components/ui/CoverageRating';
import {
getBranchLikeQuery,
isBranch,
- isLongLivingBranch,
+ isMainBranch,
isPullRequest
-} from '../../../helpers/branches';
+} from '../../../helpers/branch-like';
import * as measures from '../../../helpers/measures';
import {
getStandards,
@@ -101,7 +101,7 @@ const exposeLibraries = () => {
global.SonarHelpers = {
getBranchLikeQuery,
isBranch,
- isLongLivingBranch,
+ isMainBranch,
isPullRequest,
getStandards,
renderCWECategory,
@@ -149,7 +149,7 @@ const exposeLibraries = () => {
Level,
ListFooter,
LockIcon,
- LongLivingBranchIcon,
+ LongLivingBranchIcon: BranchIcon,
Modal,
NotFound,
PlusCircleIcon,
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentBreadcrumb.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentBreadcrumb.tsx
index 5e646b5cdb6..ddbdcce5806 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentBreadcrumb.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentBreadcrumb.tsx
@@ -22,12 +22,13 @@ import { last } from 'lodash';
import * as React from 'react';
import { Link } from 'react-router';
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon';
-import { isMainBranch } from '../../../../helpers/branches';
+import { isMainBranch } from '../../../../helpers/branch-like';
import { getProjectUrl } from '../../../../helpers/urls';
+import { BranchLike } from '../../../../types/branch-like';
interface Props {
component: T.Component;
- currentBranchLike: T.BranchLike | undefined;
+ currentBranchLike: BranchLike | undefined;
}
export function ComponentBreadcrumb(props: Props) {
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx
index 6605535550a..ed874867e0a 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx
@@ -20,6 +20,7 @@
import * as React from 'react';
import ContextNavBar from 'sonar-ui-common/components/ui/ContextNavBar';
import { STATUSES } from '../../../../apps/background-tasks/constants';
+import { BranchLike } from '../../../../types/branch-like';
import { rawSizes } from '../../../theme';
import RecentHistory from '../../RecentHistory';
import './ComponentNav.css';
@@ -29,8 +30,8 @@ import ComponentNavMenu from './ComponentNavMenu';
import ComponentNavMeta from './ComponentNavMeta';
interface Props {
- branchLikes: T.BranchLike[];
- currentBranchLike: T.BranchLike | undefined;
+ branchLikes: BranchLike[];
+ currentBranchLike: BranchLike | undefined;
component: T.Component;
currentTask?: T.Task;
currentTaskOnSameBranch?: boolean;
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx
index 93d15ab572e..b1ab9f14a8a 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx
@@ -19,14 +19,15 @@
*/
import * as React from 'react';
import Helmet from 'react-helmet';
+import { BranchLike } from '../../../../types/branch-like';
import BranchLikeNavigation from './branch-like/BranchLikeNavigation';
import CurrentBranchLikeMergeInformation from './branch-like/CurrentBranchLikeMergeInformation';
import { ComponentBreadcrumb } from './ComponentBreadcrumb';
export interface ComponentNavHeaderProps {
- branchLikes: T.BranchLike[];
+ branchLikes: BranchLike[];
component: T.Component;
- currentBranchLike: T.BranchLike | undefined;
+ currentBranchLike: BranchLike | undefined;
}
export function ComponentNavHeader(props: ComponentNavHeaderProps) {
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.tsx
index 4aa7ba37407..6e76570fcf6 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.tsx
@@ -25,13 +25,9 @@ import DropdownIcon from 'sonar-ui-common/components/icons/DropdownIcon';
import NavBarTabs from 'sonar-ui-common/components/ui/NavBarTabs';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { withAppState } from '../../../../components/hoc/withAppState';
-import {
- getBranchLikeQuery,
- isMainBranch,
- isPullRequest,
- isShortLivingBranch
-} from '../../../../helpers/branches';
+import { getBranchLikeQuery, isMainBranch, isPullRequest } from '../../../../helpers/branch-like';
import { isSonarCloud } from '../../../../helpers/system';
+import { BranchLike } from '../../../../types/branch-like';
const SETTINGS_URLS = [
'/project/admin',
@@ -52,7 +48,7 @@ const SETTINGS_URLS = [
interface Props {
appState: Pick<T.AppState, 'branchesEnabled'>;
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
component: T.Component;
location?: any;
}
@@ -113,7 +109,7 @@ export class ComponentNavMenu extends React.PureComponent<Props> {
renderActivityLink() {
const { branchLike } = this.props;
- if (isShortLivingBranch(branchLike) || isPullRequest(branchLike)) {
+ if (isPullRequest(branchLike)) {
return null;
}
@@ -159,7 +155,7 @@ export class ComponentNavMenu extends React.PureComponent<Props> {
const { branchLike, component } = this.props;
const { extensions = [] } = component;
- if (isShortLivingBranch(branchLike) || isPullRequest(branchLike)) {
+ if (isPullRequest(branchLike)) {
return null;
}
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx
index 47b574cb50f..6c9025982ea 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx
@@ -26,18 +26,14 @@ import BranchStatus from '../../../../components/common/BranchStatus';
import Favorite from '../../../../components/controls/Favorite';
import HomePageSelect from '../../../../components/controls/HomePageSelect';
import DateTimeFormatter from '../../../../components/intl/DateTimeFormatter';
-import {
- isLongLivingBranch,
- isMainBranch,
- isPullRequest,
- isShortLivingBranch
-} from '../../../../helpers/branches';
+import { isBranch, isMainBranch, isPullRequest } from '../../../../helpers/branch-like';
import { isLoggedIn } from '../../../../helpers/users';
import { getCurrentUser, Store } from '../../../../store/rootReducer';
+import { BranchLike } from '../../../../types/branch-like';
import ComponentNavWarnings from './ComponentNavWarnings';
export interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
currentUser: T.CurrentUser;
component: T.Component;
warnings: string[];
@@ -45,9 +41,9 @@ export interface Props {
export function ComponentNavMeta({ branchLike, component, currentUser, warnings }: Props) {
const mainBranch = !branchLike || isMainBranch(branchLike);
- const longBranch = isLongLivingBranch(branchLike);
+ const isABranch = isBranch(branchLike);
const currentPage = getCurrentPage(component, branchLike);
- const displayVersion = component.version !== undefined && (mainBranch || longBranch);
+ const displayVersion = component.version !== undefined && isABranch;
return (
<div className="navbar-context-meta flex-0">
@@ -73,12 +69,12 @@ export function ComponentNavMeta({ branchLike, component, currentUser, warnings
qualifier={component.qualifier}
/>
)}
- {(mainBranch || longBranch) && currentPage !== undefined && (
+ {isABranch && currentPage !== undefined && (
<HomePageSelect className="spacer-left" currentPage={currentPage} />
)}
</div>
)}
- {(isShortLivingBranch(branchLike) || isPullRequest(branchLike)) && (
+ {isPullRequest(branchLike) && (
<div className="navbar-context-meta-secondary display-inline-flex-center">
{isPullRequest(branchLike) && branchLike.url !== undefined && (
<a
@@ -97,16 +93,16 @@ export function ComponentNavMeta({ branchLike, component, currentUser, warnings
);
}
-export function getCurrentPage(component: T.Component, branchLike: T.BranchLike | undefined) {
+export function getCurrentPage(component: T.Component, branchLike: BranchLike | undefined) {
let currentPage: T.HomePage | undefined;
if (component.qualifier === 'VW' || component.qualifier === 'SVW') {
currentPage = { type: 'PORTFOLIO', component: component.key };
} else if (component.qualifier === 'APP') {
- const branch = isLongLivingBranch(branchLike) ? branchLike.name : undefined;
+ const branch = isBranch(branchLike) ? branchLike.name : undefined;
currentPage = { type: 'APPLICATION', component: component.key, branch };
} else if (component.qualifier === 'TRK') {
// when home page is set to the default branch of a project, its name is returned as `undefined`
- const branch = isLongLivingBranch(branchLike) ? branchLike.name : undefined;
+ const branch = isBranch(branchLike) ? branchLike.name : undefined;
currentPage = { type: 'PROJECT', component: component.key, branch };
}
return currentPage;
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentBreadcrumb-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentBreadcrumb-test.tsx
index 3dde40f6f04..92c481e70dd 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentBreadcrumb-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentBreadcrumb-test.tsx
@@ -20,7 +20,8 @@
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockComponent, mockMainBranch } from '../../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../../helpers/mocks/branch-like';
+import { mockComponent } from '../../../../../helpers/testMocks';
import { ComponentQualifier } from '../../../../../types/component';
import { ComponentBreadcrumb } from '../ComponentBreadcrumb';
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavHeader-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavHeader-test.tsx
index 285598465d5..4fd53015b6b 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavHeader-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavHeader-test.tsx
@@ -20,7 +20,7 @@
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockSetOfBranchAndPullRequest } from '../../../../../helpers/mocks/branch-pull-request';
+import { mockSetOfBranchAndPullRequest } from '../../../../../helpers/mocks/branch-like';
import { mockComponent } from '../../../../../helpers/testMocks';
import { ComponentNavHeader, ComponentNavHeaderProps } from '../ComponentNavHeader';
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx
index 466d0c9c0e6..b328a4543a1 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx
@@ -19,10 +19,10 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockMainBranch } from '../../../../../helpers/testMocks';
+import { mockBranch, mockMainBranch } from '../../../../../helpers/mocks/branch-like';
import { ComponentNavMenu } from '../ComponentNavMenu';
-const mainBranch: T.MainBranch = mockMainBranch();
+const mainBranch = mockMainBranch();
const baseComponent = {
breadcrumbs: [],
@@ -95,37 +95,10 @@ it('should render correctly for security extensions', () => {
expect(wrapper.find('Dropdown[data-test="security"]')).toMatchSnapshot();
});
-it('should work for short-living branches', () => {
- const branch: T.ShortLivingBranch = {
- isMain: false,
- excludedFromPurge: true,
- mergeBranch: 'master',
- name: 'feature',
- type: 'SHORT'
- };
- const component = {
- ...baseComponent,
- configuration: { showSettings: true },
- extensions: [{ key: 'component-foo', name: 'ComponentFoo' }]
- };
- expect(
- shallow(
- <ComponentNavMenu
- appState={{ branchesEnabled: true }}
- branchLike={branch}
- component={component}
- />
- )
- ).toMatchSnapshot();
-});
-
-it('should work for long-living branches', () => {
- const branch: T.LongLivingBranch = {
- excludedFromPurge: true,
- isMain: false,
- name: 'release',
- type: 'LONG'
- };
+it('should work for a branch', () => {
+ const branch = mockBranch({
+ name: 'release'
+ });
[true, false].forEach(showSettings =>
expect(
shallow(
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx
index 858d8ea1134..e1bb4487d24 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx
@@ -19,24 +19,14 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import {
- mockComponent,
- mockCurrentUser,
- mockLoggedInUser,
- mockLongLivingBranch,
- mockPullRequest,
- mockShortLivingBranch
-} from '../../../../../helpers/testMocks';
+import { mockBranch, mockPullRequest } from '../../../../../helpers/mocks/branch-like';
+import { mockComponent, mockCurrentUser, mockLoggedInUser } from '../../../../../helpers/testMocks';
import { ComponentNavMeta, getCurrentPage, Props } from '../ComponentNavMeta';
describe('#ComponentNavMeta', () => {
- it('renders status of short-living branch', () => {
- expect(shallowRender()).toMatchSnapshot();
- });
-
- it('renders meta for long-living branch', () => {
+ it('renders meta for a branch', () => {
expect(
- shallowRender({ branchLike: mockLongLivingBranch(), currentUser: mockLoggedInUser() })
+ shallowRender({ branchLike: mockBranch(), currentUser: mockLoggedInUser() })
).toMatchSnapshot();
});
@@ -63,16 +53,16 @@ describe('#getCurrentPage', () => {
expect(
getCurrentPage(
mockComponent({ key: 'foo', qualifier: 'APP' }),
- mockLongLivingBranch({ name: 'develop' })
+ mockBranch({ name: 'develop' })
)
).toEqual({ type: 'APPLICATION', component: 'foo', branch: 'develop' });
});
- it('should return a portfolio page', () => {
- expect(getCurrentPage(mockComponent(), mockShortLivingBranch())).toEqual({
+ it('should return a project page', () => {
+ expect(getCurrentPage(mockComponent(), mockBranch({ name: 'feature/foo' }))).toEqual({
type: 'PROJECT',
component: 'my-project',
- branch: undefined
+ branch: 'feature/foo'
});
});
});
@@ -80,7 +70,7 @@ describe('#getCurrentPage', () => {
function shallowRender(props: Partial<Props> = {}) {
return shallow(
<ComponentNavMeta
- branchLike={mockShortLivingBranch()}
+ branchLike={mockBranch()}
component={mockComponent({ analysisDate: '2017-01-02T00:00:00.000Z', version: '0.0.1' })}
currentUser={mockCurrentUser()}
warnings={[]}
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavHeader-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavHeader-test.tsx.snap
index eb495bb4149..81197bd8cc8 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavHeader-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavHeader-test.tsx.snap
@@ -39,9 +39,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
}
}
/>
@@ -52,16 +50,13 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
},
Object {
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-1",
- "type": "LONG",
+ "name": "branch-1",
},
Object {
"analysisDate": "2018-01-01",
@@ -81,9 +76,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "llb-1",
- "name": "slb-2",
- "type": "SHORT",
+ "name": "branch-12",
},
Object {
"analysisDate": "2018-01-01",
@@ -97,15 +90,13 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-3",
- "type": "LONG",
+ "name": "branch-3",
},
Object {
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-2",
- "type": "LONG",
+ "name": "branch-2",
},
Object {
"analysisDate": "2018-01-01",
@@ -146,9 +137,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
}
}
/>
@@ -158,9 +147,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
}
}
/>
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMenu-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMenu-test.tsx.snap
index 83cb4576530..696bb7739f1 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMenu-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMenu-test.tsx.snap
@@ -35,7 +35,7 @@ exports[`should render correctly for security extensions 1`] = `
exports[`should render correctly for security extensions 2`] = `null`;
-exports[`should work for all qualifiers 1`] = `
+exports[`should work for a branch 1`] = `
<NavBarTabs>
<li>
<Link
@@ -46,6 +46,7 @@ exports[`should work for all qualifiers 1`] = `
Object {
"pathname": "/dashboard",
"query": Object {
+ "branch": "release",
"id": "foo",
},
}
@@ -64,6 +65,7 @@ exports[`should work for all qualifiers 1`] = `
Object {
"pathname": "/project/issues",
"query": Object {
+ "branch": "release",
"id": "foo",
"resolved": "false",
},
@@ -82,6 +84,7 @@ exports[`should work for all qualifiers 1`] = `
Object {
"pathname": "/component_measures",
"query": Object {
+ "branch": "release",
"id": "foo",
},
}
@@ -99,6 +102,7 @@ exports[`should work for all qualifiers 1`] = `
Object {
"pathname": "/code",
"query": Object {
+ "branch": "release",
"id": "foo",
},
}
@@ -116,6 +120,7 @@ exports[`should work for all qualifiers 1`] = `
Object {
"pathname": "/project/activity",
"query": Object {
+ "branch": "release",
"id": "foo",
},
}
@@ -124,107 +129,10 @@ exports[`should work for all qualifiers 1`] = `
project_activity.page
</Link>
</li>
- <Dropdown
- data-test="administration"
- overlay={
- <ul
- className="menu"
- >
- <li>
- <Link
- activeClassName="active"
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/project/settings",
- "query": Object {
- "id": "foo",
- },
- }
- }
- >
- project_settings.page
- </Link>
- </li>
- <li>
- <Link
- activeClassName="active"
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/project/branches",
- "query": Object {
- "id": "foo",
- },
- }
- }
- >
- project_branch_pull_request.page
- </Link>
- </li>
- <li>
- <Link
- activeClassName="active"
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/project/baseline",
- "query": Object {
- "id": "foo",
- },
- }
- }
- >
- project_baseline.page
- </Link>
- </li>
- <li>
- <Link
- activeClassName="active"
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/project/webhooks",
- "query": Object {
- "id": "foo",
- },
- }
- }
- >
- webhooks.page
- </Link>
- </li>
- <li>
- <Link
- activeClassName="active"
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/project/deletion",
- "query": Object {
- "id": "foo",
- },
- }
- }
- >
- deletion.page
- </Link>
- </li>
- </ul>
- }
- tagName="li"
- >
- <Component />
- </Dropdown>
</NavBarTabs>
`;
-exports[`should work for all qualifiers 2`] = `
+exports[`should work for a branch 2`] = `
<NavBarTabs>
<li>
<Link
@@ -233,8 +141,9 @@ exports[`should work for all qualifiers 2`] = `
style={Object {}}
to={
Object {
- "pathname": "/portfolio",
+ "pathname": "/dashboard",
"query": Object {
+ "branch": "release",
"id": "foo",
},
}
@@ -253,6 +162,7 @@ exports[`should work for all qualifiers 2`] = `
Object {
"pathname": "/project/issues",
"query": Object {
+ "branch": "release",
"id": "foo",
"resolved": "false",
},
@@ -271,6 +181,7 @@ exports[`should work for all qualifiers 2`] = `
Object {
"pathname": "/component_measures",
"query": Object {
+ "branch": "release",
"id": "foo",
},
}
@@ -288,12 +199,13 @@ exports[`should work for all qualifiers 2`] = `
Object {
"pathname": "/code",
"query": Object {
+ "branch": "release",
"id": "foo",
},
}
}
>
- view_projects.page
+ code.page
</Link>
</li>
<li>
@@ -305,6 +217,7 @@ exports[`should work for all qualifiers 2`] = `
Object {
"pathname": "/project/activity",
"query": Object {
+ "branch": "release",
"id": "foo",
},
}
@@ -313,39 +226,10 @@ exports[`should work for all qualifiers 2`] = `
project_activity.page
</Link>
</li>
- <Dropdown
- data-test="administration"
- overlay={
- <ul
- className="menu"
- >
- <li>
- <Link
- activeClassName="active"
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/project/deletion",
- "query": Object {
- "id": "foo",
- },
- }
- }
- >
- deletion.page
- </Link>
- </li>
- </ul>
- }
- tagName="li"
- >
- <Component />
- </Dropdown>
</NavBarTabs>
`;
-exports[`should work for all qualifiers 3`] = `
+exports[`should work for all qualifiers 1`] = `
<NavBarTabs>
<li>
<Link
@@ -354,7 +238,7 @@ exports[`should work for all qualifiers 3`] = `
style={Object {}}
to={
Object {
- "pathname": "/portfolio",
+ "pathname": "/dashboard",
"query": Object {
"id": "foo",
},
@@ -414,7 +298,7 @@ exports[`should work for all qualifiers 3`] = `
}
}
>
- view_projects.page
+ code.page
</Link>
</li>
<li>
@@ -434,10 +318,107 @@ exports[`should work for all qualifiers 3`] = `
project_activity.page
</Link>
</li>
+ <Dropdown
+ data-test="administration"
+ overlay={
+ <ul
+ className="menu"
+ >
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/project/settings",
+ "query": Object {
+ "id": "foo",
+ },
+ }
+ }
+ >
+ project_settings.page
+ </Link>
+ </li>
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/project/branches",
+ "query": Object {
+ "id": "foo",
+ },
+ }
+ }
+ >
+ project_branch_pull_request.page
+ </Link>
+ </li>
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/project/baseline",
+ "query": Object {
+ "id": "foo",
+ },
+ }
+ }
+ >
+ project_baseline.page
+ </Link>
+ </li>
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/project/webhooks",
+ "query": Object {
+ "id": "foo",
+ },
+ }
+ }
+ >
+ webhooks.page
+ </Link>
+ </li>
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/project/deletion",
+ "query": Object {
+ "id": "foo",
+ },
+ }
+ }
+ >
+ deletion.page
+ </Link>
+ </li>
+ </ul>
+ }
+ tagName="li"
+ >
+ <Component />
+ </Dropdown>
</NavBarTabs>
`;
-exports[`should work for all qualifiers 4`] = `
+exports[`should work for all qualifiers 2`] = `
<NavBarTabs>
<li>
<Link
@@ -446,7 +427,7 @@ exports[`should work for all qualifiers 4`] = `
style={Object {}}
to={
Object {
- "pathname": "/dashboard",
+ "pathname": "/portfolio",
"query": Object {
"id": "foo",
},
@@ -558,7 +539,7 @@ exports[`should work for all qualifiers 4`] = `
</NavBarTabs>
`;
-exports[`should work for long-living branches 1`] = `
+exports[`should work for all qualifiers 3`] = `
<NavBarTabs>
<li>
<Link
@@ -567,9 +548,8 @@ exports[`should work for long-living branches 1`] = `
style={Object {}}
to={
Object {
- "pathname": "/dashboard",
+ "pathname": "/portfolio",
"query": Object {
- "branch": "release",
"id": "foo",
},
}
@@ -588,7 +568,6 @@ exports[`should work for long-living branches 1`] = `
Object {
"pathname": "/project/issues",
"query": Object {
- "branch": "release",
"id": "foo",
"resolved": "false",
},
@@ -607,7 +586,6 @@ exports[`should work for long-living branches 1`] = `
Object {
"pathname": "/component_measures",
"query": Object {
- "branch": "release",
"id": "foo",
},
}
@@ -625,13 +603,12 @@ exports[`should work for long-living branches 1`] = `
Object {
"pathname": "/code",
"query": Object {
- "branch": "release",
"id": "foo",
},
}
}
>
- code.page
+ view_projects.page
</Link>
</li>
<li>
@@ -643,7 +620,6 @@ exports[`should work for long-living branches 1`] = `
Object {
"pathname": "/project/activity",
"query": Object {
- "branch": "release",
"id": "foo",
},
}
@@ -655,7 +631,7 @@ exports[`should work for long-living branches 1`] = `
</NavBarTabs>
`;
-exports[`should work for long-living branches 2`] = `
+exports[`should work for all qualifiers 4`] = `
<NavBarTabs>
<li>
<Link
@@ -666,7 +642,6 @@ exports[`should work for long-living branches 2`] = `
Object {
"pathname": "/dashboard",
"query": Object {
- "branch": "release",
"id": "foo",
},
}
@@ -685,7 +660,6 @@ exports[`should work for long-living branches 2`] = `
Object {
"pathname": "/project/issues",
"query": Object {
- "branch": "release",
"id": "foo",
"resolved": "false",
},
@@ -704,7 +678,6 @@ exports[`should work for long-living branches 2`] = `
Object {
"pathname": "/component_measures",
"query": Object {
- "branch": "release",
"id": "foo",
},
}
@@ -722,13 +695,12 @@ exports[`should work for long-living branches 2`] = `
Object {
"pathname": "/code",
"query": Object {
- "branch": "release",
"id": "foo",
},
}
}
>
- code.page
+ view_projects.page
</Link>
</li>
<li>
@@ -740,7 +712,6 @@ exports[`should work for long-living branches 2`] = `
Object {
"pathname": "/project/activity",
"query": Object {
- "branch": "release",
"id": "foo",
},
}
@@ -749,85 +720,35 @@ exports[`should work for long-living branches 2`] = `
project_activity.page
</Link>
</li>
-</NavBarTabs>
-`;
-
-exports[`should work for short-living branches 1`] = `
-<NavBarTabs>
- <li>
- <Link
- activeClassName="active"
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/dashboard",
- "query": Object {
- "branch": "feature",
- "id": "foo",
- },
- }
- }
- >
- overview.page
- </Link>
- </li>
- <li>
- <Link
- activeClassName="active"
- className=""
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/project/issues",
- "query": Object {
- "branch": "feature",
- "id": "foo",
- "resolved": "false",
- },
- }
- }
- >
- issues.page
- </Link>
- </li>
- <li>
- <Link
- activeClassName="active"
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/component_measures",
- "query": Object {
- "branch": "feature",
- "id": "foo",
- },
- }
- }
- >
- layout.measures
- </Link>
- </li>
- <li>
- <Link
- activeClassName="active"
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/code",
- "query": Object {
- "branch": "feature",
- "id": "foo",
- },
- }
- }
- >
- code.page
- </Link>
- </li>
+ <Dropdown
+ data-test="administration"
+ overlay={
+ <ul
+ className="menu"
+ >
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/project/deletion",
+ "query": Object {
+ "id": "foo",
+ },
+ }
+ }
+ >
+ deletion.page
+ </Link>
+ </li>
+ </ul>
+ }
+ tagName="li"
+ >
+ <Component />
+ </Dropdown>
</NavBarTabs>
`;
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMeta-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMeta-test.tsx.snap
index 190780d385d..26ba74edacf 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMeta-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMeta-test.tsx.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`#ComponentNavMeta renders meta for long-living branch 1`] = `
+exports[`#ComponentNavMeta renders meta for a branch 1`] = `
<div
className="navbar-context-meta flex-0"
>
@@ -83,34 +83,3 @@ exports[`#ComponentNavMeta renders meta for pull request 1`] = `
</div>
</div>
`;
-
-exports[`#ComponentNavMeta renders status of short-living branch 1`] = `
-<div
- className="navbar-context-meta flex-0"
->
- <div
- className="spacer-left text-ellipsis"
- >
- <DateTimeFormatter
- date="2017-01-02T00:00:00.000Z"
- />
- </div>
- <div
- className="navbar-context-meta-secondary display-inline-flex-center"
- >
- <Connect(BranchStatus)
- branchLike={
- Object {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "mergeBranch": "master",
- "name": "feature/foo",
- "type": "SHORT",
- }
- }
- component="my-project"
- />
- </div>
-</div>
-`;
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx
index 8b92aa6dbb4..15a7bfcb053 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx
@@ -22,15 +22,16 @@ import * as classNames from 'classnames';
import * as React from 'react';
import Toggler from 'sonar-ui-common/components/controls/Toggler';
import { withAppState } from '../../../../../components/hoc/withAppState';
+import { BranchLike } from '../../../../../types/branch-like';
import './BranchLikeNavigation.css';
import CurrentBranchLike from './CurrentBranchLike';
import Menu from './Menu';
export interface BranchLikeNavigationProps {
appState: Pick<T.AppState, 'branchesEnabled'>;
- branchLikes: T.BranchLike[];
+ branchLikes: BranchLike[];
component: T.Component;
- currentBranchLike: T.BranchLike;
+ currentBranchLike: BranchLike;
}
export function BranchLikeNavigation(props: BranchLikeNavigationProps) {
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLike.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLike.tsx
index acb2f334efe..133f3442c61 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLike.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLike.tsx
@@ -26,15 +26,16 @@ import PlusCircleIcon from 'sonar-ui-common/components/icons/PlusCircleIcon';
import { translate } from 'sonar-ui-common/helpers/l10n';
import DocTooltip from '../../../../../components/docs/DocTooltip';
import BranchLikeIcon from '../../../../../components/icons/BranchLikeIcon';
-import { getBranchLikeDisplayName } from '../../../../../helpers/branches';
+import { getBranchLikeDisplayName } from '../../../../../helpers/branch-like';
import { getPortfolioAdminUrl } from '../../../../../helpers/urls';
+import { BranchLike } from '../../../../../types/branch-like';
import { ComponentQualifier } from '../../../../../types/component';
import { colors } from '../../../../theme';
export interface CurrentBranchLikeProps {
branchesEnabled: boolean;
component: T.Component;
- currentBranchLike: T.BranchLike;
+ currentBranchLike: BranchLike;
hasManyBranches: boolean;
}
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLikeMergeInformation.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLikeMergeInformation.tsx
index 7e5e3560f40..10caa6de7c7 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLikeMergeInformation.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLikeMergeInformation.tsx
@@ -21,10 +21,11 @@
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { translate } from 'sonar-ui-common/helpers/l10n';
-import { isPullRequest } from '../../../../../helpers/branches';
+import { isPullRequest } from '../../../../../helpers/branch-like';
+import { BranchLike } from '../../../../../types/branch-like';
export interface CurrentBranchLikeMergeInformationProps {
- currentBranchLike: T.BranchLike;
+ currentBranchLike: BranchLike;
}
export function CurrentBranchLikeMergeInformation(props: CurrentBranchLikeMergeInformationProps) {
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx
index abc88308d7e..1827a04386a 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx
@@ -30,25 +30,26 @@ import {
isBranch,
isPullRequest,
isSameBranchLike
-} from '../../../../../helpers/branches';
+} from '../../../../../helpers/branch-like';
import { getBranchLikeUrl } from '../../../../../helpers/urls';
+import { BranchLike, BranchLikeTree } from '../../../../../types/branch-like';
import { ComponentQualifier } from '../../../../../types/component';
import MenuItemList from './MenuItemList';
interface Props {
- branchLikes: T.BranchLike[];
+ branchLikes: BranchLike[];
canAdminComponent?: boolean;
component: T.Component;
- currentBranchLike: T.BranchLike;
+ currentBranchLike: BranchLike;
onClose: () => void;
router: Pick<Router, 'push'>;
}
interface State {
- branchLikesToDisplay: T.BranchLike[];
- branchLikesToDisplayTree: T.BranchLikeTree;
+ branchLikesToDisplay: BranchLike[];
+ branchLikesToDisplayTree: BranchLikeTree;
query: string;
- selectedBranchLike: T.BranchLike | undefined;
+ selectedBranchLike: BranchLike | undefined;
}
export class Menu extends React.PureComponent<Props, State> {
@@ -70,7 +71,7 @@ export class Menu extends React.PureComponent<Props, State> {
};
}
- processBranchLikes = (branchLikes: T.BranchLike[]) => {
+ processBranchLikes = (branchLikes: BranchLike[]) => {
const tree = getBrancheLikesAsTree(branchLikes);
return {
branchLikesToDisplay: [
@@ -128,9 +129,9 @@ export class Menu extends React.PureComponent<Props, State> {
handleSearchChange = (query: string) => {
const q = query.toLowerCase();
- const filterBranch = (branch: T.BranchLike) =>
+ const filterBranch = (branch: BranchLike) =>
isBranch(branch) && branch.name.toLowerCase().includes(q);
- const filterPullRequest = (pr: T.BranchLike) =>
+ const filterPullRequest = (pr: BranchLike) =>
isPullRequest(pr) && (pr.title.toLowerCase().includes(q) || pr.key.toLowerCase().includes(q));
const filteredBranchLikes = this.props.branchLikes.filter(
@@ -144,7 +145,7 @@ export class Menu extends React.PureComponent<Props, State> {
});
};
- handleOnSelect = (branchLike: T.BranchLike) => {
+ handleOnSelect = (branchLike: BranchLike) => {
this.setState({ selectedBranchLike: branchLike }, () => {
this.props.onClose();
this.props.router.push(getBranchLikeUrl(this.props.component.key, branchLike));
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx
index c9aa4daddc6..eeeffcc5556 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx
@@ -23,13 +23,14 @@ import * as React from 'react';
import { translate } from 'sonar-ui-common/helpers/l10n';
import BranchStatus from '../../../../../components/common/BranchStatus';
import BranchLikeIcon from '../../../../../components/icons/BranchLikeIcon';
-import { getBranchLikeDisplayName, isMainBranch } from '../../../../../helpers/branches';
+import { getBranchLikeDisplayName, isMainBranch } from '../../../../../helpers/branch-like';
+import { BranchLike } from '../../../../../types/branch-like';
export interface MenuItemProps {
- branchLike: T.BranchLike;
+ branchLike: BranchLike;
component: T.Component;
indent?: boolean;
- onSelect: (branchLike: T.BranchLike) => void;
+ onSelect: (branchLike: BranchLike) => void;
selected: boolean;
setSelectedNode?: (node: HTMLLIElement) => void;
}
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItemList.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItemList.tsx
index 903893912a3..ab06f416c08 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItemList.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItemList.tsx
@@ -23,15 +23,16 @@ import HelpTooltip from 'sonar-ui-common/components/controls/HelpTooltip';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { scrollToElement } from 'sonar-ui-common/helpers/scrolling';
import { isDefined } from 'sonar-ui-common/helpers/types';
-import { getBranchLikeKey, isSameBranchLike } from '../../../../../helpers/branches';
+import { getBranchLikeKey, isSameBranchLike } from '../../../../../helpers/branch-like';
+import { BranchLike, BranchLikeTree } from '../../../../../types/branch-like';
import MenuItem from './MenuItem';
export interface MenuItemListProps {
- branchLikeTree: T.BranchLikeTree;
+ branchLikeTree: BranchLikeTree;
component: T.Component;
hasResults: boolean;
- onSelect: (branchLike: T.BranchLike) => void;
- selectedBranchLike: T.BranchLike | undefined;
+ onSelect: (branchLike: BranchLike) => void;
+ selectedBranchLike: BranchLike | undefined;
}
export function MenuItemList(props: MenuItemListProps) {
@@ -46,7 +47,7 @@ export function MenuItemList(props: MenuItemListProps) {
const { branchLikeTree, component, hasResults, onSelect, selectedBranchLike } = props;
- const renderItem = (branchLike: T.BranchLike, indent?: boolean) => (
+ const renderItem = (branchLike: BranchLike, indent?: boolean) => (
<MenuItem
branchLike={branchLike}
component={component}
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/BranchLikeNavigation-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/BranchLikeNavigation-test.tsx
index 9ffcbf39fee..fdb6c9b274b 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/BranchLikeNavigation-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/BranchLikeNavigation-test.tsx
@@ -22,7 +22,7 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import Toggler from 'sonar-ui-common/components/controls/Toggler';
import { click } from 'sonar-ui-common/helpers/testUtils';
-import { mockSetOfBranchAndPullRequest } from '../../../../../../helpers/mocks/branch-pull-request';
+import { mockSetOfBranchAndPullRequest } from '../../../../../../helpers/mocks/branch-like';
import { mockAppState, mockComponent } from '../../../../../../helpers/testMocks';
import { BranchLikeNavigation, BranchLikeNavigationProps } from '../BranchLikeNavigation';
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/CurrentBranchLike-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/CurrentBranchLike-test.tsx
index 03328f8ff33..b208688a7fa 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/CurrentBranchLike-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/CurrentBranchLike-test.tsx
@@ -20,7 +20,8 @@
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockComponent, mockMainBranch } from '../../../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../../../helpers/mocks/branch-like';
+import { mockComponent } from '../../../../../../helpers/testMocks';
import { ComponentQualifier } from '../../../../../../types/component';
import { CurrentBranchLike, CurrentBranchLikeProps } from '../CurrentBranchLike';
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/CurrentBranchLikeMergeInformation-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/CurrentBranchLikeMergeInformation-test.tsx
index d1c7873aa13..936014ae885 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/CurrentBranchLikeMergeInformation-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/CurrentBranchLikeMergeInformation-test.tsx
@@ -20,7 +20,7 @@
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockMainBranch, mockPullRequest } from '../../../../../../helpers/testMocks';
+import { mockMainBranch, mockPullRequest } from '../../../../../../helpers/mocks/branch-like';
import {
CurrentBranchLikeMergeInformation,
CurrentBranchLikeMergeInformationProps
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/Menu-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/Menu-test.tsx
index 7e80ca84ec4..f2f350768b8 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/Menu-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/Menu-test.tsx
@@ -24,8 +24,11 @@ import { Link } from 'react-router';
import SearchBox from 'sonar-ui-common/components/controls/SearchBox';
import { KeyCodes } from 'sonar-ui-common/helpers/keycodes';
import { click, mockEvent } from 'sonar-ui-common/helpers/testUtils';
-import { mockSetOfBranchAndPullRequest } from '../../../../../../helpers/mocks/branch-pull-request';
-import { mockComponent, mockPullRequest, mockRouter } from '../../../../../../helpers/testMocks';
+import {
+ mockPullRequest,
+ mockSetOfBranchAndPullRequest
+} from '../../../../../../helpers/mocks/branch-like';
+import { mockComponent, mockRouter } from '../../../../../../helpers/testMocks';
import { Menu } from '../Menu';
import { MenuItemList } from '../MenuItemList';
@@ -98,7 +101,7 @@ it('should handle keyboard shortcut correctly', () => {
onKeyDown(mockEvent({ keyCode: KeyCodes.DownArrow }));
onKeyDown(mockEvent({ keyCode: KeyCodes.DownArrow }));
- expect(wrapper.state().selectedBranchLike).toBe(branchLikes[7]);
+ expect(wrapper.state().selectedBranchLike).toBe(branchLikes[0]);
onKeyDown(mockEvent({ keyCode: KeyCodes.Enter }));
expect(push).toHaveBeenCalled();
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/MenuItem-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/MenuItem-test.tsx
index cb701325499..b753f9c0715 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/MenuItem-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/MenuItem-test.tsx
@@ -21,11 +21,8 @@
import { shallow } from 'enzyme';
import * as React from 'react';
import { click } from 'sonar-ui-common/helpers/testUtils';
-import {
- mockComponent,
- mockMainBranch,
- mockPullRequest
-} from '../../../../../../helpers/testMocks';
+import { mockMainBranch, mockPullRequest } from '../../../../../../helpers/mocks/branch-like';
+import { mockComponent } from '../../../../../../helpers/testMocks';
import { MenuItem, MenuItemProps } from '../MenuItem';
it('should render a main branch correctly', () => {
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/MenuItemList-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/MenuItemList-test.tsx
index 1cc6404d4e5..91223e1ad96 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/MenuItemList-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/MenuItemList-test.tsx
@@ -20,9 +20,12 @@
import { shallow } from 'enzyme';
import * as React from 'react';
-import { getBrancheLikesAsTree } from '../../../../../../helpers/branches';
-import { mockSetOfBranchAndPullRequest } from '../../../../../../helpers/mocks/branch-pull-request';
-import { mockComponent, mockPullRequest } from '../../../../../../helpers/testMocks';
+import { getBrancheLikesAsTree } from '../../../../../../helpers/branch-like';
+import {
+ mockPullRequest,
+ mockSetOfBranchAndPullRequest
+} from '../../../../../../helpers/mocks/branch-like';
+import { mockComponent } from '../../../../../../helpers/testMocks';
import { MenuItemList, MenuItemListProps } from '../MenuItemList';
it('should render correctly', () => {
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/BranchLikeNavigation-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/BranchLikeNavigation-test.tsx.snap
index 1bae73bfd18..fd5123a1825 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/BranchLikeNavigation-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/BranchLikeNavigation-test.tsx.snap
@@ -34,9 +34,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
}
}
hasManyBranches={true}
@@ -59,16 +57,13 @@ exports[`should render the menu trigger if branches are enabled 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
},
Object {
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-1",
- "type": "LONG",
+ "name": "branch-1",
},
Object {
"analysisDate": "2018-01-01",
@@ -88,9 +83,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "llb-1",
- "name": "slb-2",
- "type": "SHORT",
+ "name": "branch-12",
},
Object {
"analysisDate": "2018-01-01",
@@ -104,15 +97,13 @@ exports[`should render the menu trigger if branches are enabled 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-3",
- "type": "LONG",
+ "name": "branch-3",
},
Object {
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-2",
- "type": "LONG",
+ "name": "branch-2",
},
Object {
"analysisDate": "2018-01-01",
@@ -153,9 +144,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
}
}
onClose={[Function]}
@@ -197,9 +186,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
}
}
hasManyBranches={true}
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/Menu-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/Menu-test.tsx.snap
index 999f8552e96..35b945c0f97 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/Menu-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/Menu-test.tsx.snap
@@ -28,8 +28,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-1",
- "type": "LONG",
+ "name": "branch-1",
},
"pullRequests": Array [],
},
@@ -38,8 +37,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-2",
- "type": "LONG",
+ "name": "branch-11",
},
"pullRequests": Array [],
},
@@ -48,8 +46,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-3",
- "type": "LONG",
+ "name": "branch-12",
},
"pullRequests": Array [],
},
@@ -58,9 +55,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-2",
},
"pullRequests": Array [],
},
@@ -69,9 +64,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "llb-1",
- "name": "slb-2",
- "type": "SHORT",
+ "name": "branch-3",
},
"pullRequests": Array [],
},
@@ -201,8 +194,7 @@ exports[`should render correctly with no current branch like 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-1",
- "type": "LONG",
+ "name": "branch-1",
},
"pullRequests": Array [],
},
@@ -211,8 +203,7 @@ exports[`should render correctly with no current branch like 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-2",
- "type": "LONG",
+ "name": "branch-11",
},
"pullRequests": Array [],
},
@@ -221,8 +212,7 @@ exports[`should render correctly with no current branch like 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-3",
- "type": "LONG",
+ "name": "branch-12",
},
"pullRequests": Array [],
},
@@ -231,9 +221,7 @@ exports[`should render correctly with no current branch like 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-2",
},
"pullRequests": Array [],
},
@@ -242,9 +230,7 @@ exports[`should render correctly with no current branch like 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "llb-1",
- "name": "slb-2",
- "type": "SHORT",
+ "name": "branch-3",
},
"pullRequests": Array [],
},
@@ -319,9 +305,7 @@ exports[`should render correctly with no current branch like 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
}
}
/>
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/MenuItemList-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/MenuItemList-test.tsx.snap
index 96ce5bea8b6..39102cfadb7 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/MenuItemList-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/MenuItemList-test.tsx.snap
@@ -146,8 +146,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-1",
- "type": "LONG",
+ "name": "branch-1",
}
}
component={
@@ -173,7 +172,7 @@ exports[`should render correctly 1`] = `
"tags": Array [],
}
}
- key="branch-llb-1"
+ key="branch-branch-1"
onSelect={[MockFunction]}
selected={false}
setSelectedNode={[Function]}
@@ -185,8 +184,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-2",
- "type": "LONG",
+ "name": "branch-11",
}
}
component={
@@ -212,9 +210,9 @@ exports[`should render correctly 1`] = `
"tags": Array [],
}
}
- key="branch-llb-2"
+ key="branch-branch-11"
onSelect={[MockFunction]}
- selected={false}
+ selected={true}
setSelectedNode={[Function]}
/>
<hr />
@@ -224,8 +222,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-3",
- "type": "LONG",
+ "name": "branch-12",
}
}
component={
@@ -251,7 +248,7 @@ exports[`should render correctly 1`] = `
"tags": Array [],
}
}
- key="branch-llb-3"
+ key="branch-branch-12"
onSelect={[MockFunction]}
selected={false}
setSelectedNode={[Function]}
@@ -263,9 +260,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-2",
}
}
component={
@@ -291,9 +286,9 @@ exports[`should render correctly 1`] = `
"tags": Array [],
}
}
- key="branch-slb-1"
+ key="branch-branch-2"
onSelect={[MockFunction]}
- selected={true}
+ selected={false}
setSelectedNode={[Function]}
/>
<hr />
@@ -303,9 +298,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "llb-1",
- "name": "slb-2",
- "type": "SHORT",
+ "name": "branch-3",
}
}
component={
@@ -331,7 +324,7 @@ exports[`should render correctly 1`] = `
"tags": Array [],
}
}
- key="branch-slb-2"
+ key="branch-branch-3"
onSelect={[MockFunction]}
selected={false}
setSelectedNode={[Function]}
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 a453b1390e7..bdfc7e8dc1c 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
@@ -19,17 +19,11 @@
*/
import * as React from 'react';
import { Link } from 'react-router';
-import LongLivingBranchIcon from 'sonar-ui-common/components/icons/LongLivingBranchIcon';
+import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon';
import PullRequestIcon from 'sonar-ui-common/components/icons/PullRequestIcon';
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon';
-import ShortLivingBranchIcon from 'sonar-ui-common/components/icons/ShortLivingBranchIcon';
import Organization from '../../../components/shared/Organization';
-import {
- getLongLivingBranchUrl,
- getProjectUrl,
- getPullRequestUrl,
- getShortLivingBranchUrl
-} from '../../../helpers/urls';
+import { getBranchUrl, getProjectUrl, getPullRequestUrl } from '../../../helpers/urls';
import TaskType from './TaskType';
interface Props {
@@ -48,11 +42,10 @@ export default function TaskComponent({ task }: Props) {
return (
<td>
- {task.branchType === 'SHORT' && <ShortLivingBranchIcon className="little-spacer-right" />}
- {task.branchType === 'LONG' && <LongLivingBranchIcon className="little-spacer-right" />}
+ {task.branch !== undefined && <BranchIcon className="little-spacer-right" />}
{task.pullRequest !== undefined && <PullRequestIcon className="little-spacer-right" />}
- {!task.branchType && !task.pullRequest && task.componentQualifier && (
+ {!task.branch && !task.pullRequest && task.componentQualifier && (
<span className="little-spacer-right">
<QualifierIcon qualifier={task.componentQualifier} />
</span>
@@ -87,11 +80,7 @@ export default function TaskComponent({ task }: Props) {
function getTaskComponentUrl(componentKey: string, task: T.Task) {
if (task.branch) {
- if (task.branchType === 'SHORT') {
- return getShortLivingBranchUrl(componentKey, task.branch);
- } else if (task.branchType === 'LONG') {
- return getLongLivingBranchUrl(componentKey, task.branch);
- }
+ return getBranchUrl(componentKey, task.branch);
} else if (task.pullRequest) {
return getPullRequestUrl(componentKey, task.pullRequest);
}
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx
index e1e249a775e..09ef414789b 100644
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx
+++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx
@@ -39,11 +39,7 @@ it('renders correctly', () => {
});
it('renders correctly for branches and pullrequest', () => {
- expect(
- shallow(<TaskComponent task={{ ...TASK, branch: 'feature', branchType: 'SHORT' }} />)
- ).toMatchSnapshot();
- expect(
- shallow(<TaskComponent task={{ ...TASK, branch: 'branch-6.7', branchType: 'LONG' }} />)
- ).toMatchSnapshot();
+ expect(shallow(<TaskComponent task={{ ...TASK, branch: 'feature' }} />)).toMatchSnapshot();
+ expect(shallow(<TaskComponent task={{ ...TASK, branch: 'branch-6.7' }} />)).toMatchSnapshot();
expect(shallow(<TaskComponent task={{ ...TASK, pullRequest: 'pr-89' }} />)).toMatchSnapshot();
});
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap
index 8d5dacc3a4e..653b69c156f 100644
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap
@@ -49,7 +49,7 @@ exports[`renders correctly 2`] = `
exports[`renders correctly for branches and pullrequest 1`] = `
<td>
- <ShortLivingBranchIcon
+ <BranchIcon
className="little-spacer-right"
/>
<Connect(Organization)
@@ -95,7 +95,7 @@ exports[`renders correctly for branches and pullrequest 1`] = `
exports[`renders correctly for branches and pullrequest 2`] = `
<td>
- <LongLivingBranchIcon
+ <BranchIcon
className="little-spacer-right"
/>
<Connect(Organization)
diff --git a/server/sonar-web/src/main/js/apps/code/__tests__/utils-test.tsx b/server/sonar-web/src/main/js/apps/code/__tests__/utils-test.tsx
index 84a22b4f01b..496981acb74 100644
--- a/server/sonar-web/src/main/js/apps/code/__tests__/utils-test.tsx
+++ b/server/sonar-web/src/main/js/apps/code/__tests__/utils-test.tsx
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getChildren } from '../../../api/components';
-import { mockMainBranch, mockPullRequest } from '../../../helpers/testMocks';
+import { mockMainBranch, mockPullRequest } from '../../../helpers/mocks/branch-like';
import { addComponent, addComponentChildren, getComponentBreadcrumbs } from '../bucket';
import { getCodeMetrics, loadMoreChildren, retrieveComponentChildren } from '../utils';
diff --git a/server/sonar-web/src/main/js/apps/code/components/App.tsx b/server/sonar-web/src/main/js/apps/code/components/App.tsx
index 7135d3fe6a0..436ed42fb3b 100644
--- a/server/sonar-web/src/main/js/apps/code/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/App.tsx
@@ -28,10 +28,11 @@ import ListFooter from 'sonar-ui-common/components/controls/ListFooter';
import { translate } from 'sonar-ui-common/helpers/l10n';
import A11ySkipTarget from '../../../app/components/a11y/A11ySkipTarget';
import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
-import { isPullRequest, isSameBranchLike, isShortLivingBranch } from '../../../helpers/branches';
+import { isPullRequest, isSameBranchLike } from '../../../helpers/branch-like';
import { getCodeUrl, getProjectUrl } from '../../../helpers/urls';
import { fetchBranchStatus, fetchMetrics } from '../../../store/rootActions';
import { getMetrics } from '../../../store/rootReducer';
+import { BranchLike } from '../../../types/branch-like';
import { addComponent, addComponentBreadcrumbs, clearBucket } from '../bucket';
import '../code.css';
import { loadMoreChildren, retrieveComponent, retrieveComponentChildren } from '../utils';
@@ -45,12 +46,12 @@ interface StateToProps {
}
interface DispatchToProps {
- fetchBranchStatus: (branchLike: T.BranchLike, projectKey: string) => Promise<void>;
+ fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>;
fetchMetrics: () => void;
}
interface OwnProps {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.Component;
location: Pick<Location, 'query'>;
router: Pick<InjectedRouter, 'push'>;
@@ -231,7 +232,7 @@ export class App extends React.PureComponent<Props, State> {
refreshBranchStatus = () => {
const { branchLike, component } = this.props;
- if (branchLike && component && (isPullRequest(branchLike) || isShortLivingBranch(branchLike))) {
+ if (branchLike && component && isPullRequest(branchLike)) {
this.props.fetchBranchStatus(branchLike, component.key);
}
};
diff --git a/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.tsx b/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.tsx
index 4ca21c7fd11..586a7adb80a 100644
--- a/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.tsx
@@ -18,10 +18,11 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { BranchLike } from '../../../types/branch-like';
import ComponentName from './ComponentName';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
breadcrumbs: T.Breadcrumb[];
rootComponent: T.ComponentMeasure;
}
diff --git a/server/sonar-web/src/main/js/apps/code/components/Component.tsx b/server/sonar-web/src/main/js/apps/code/components/Component.tsx
index 5b001ac62a1..dec3d7896ec 100644
--- a/server/sonar-web/src/main/js/apps/code/components/Component.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/Component.tsx
@@ -21,12 +21,13 @@ import * as classNames from 'classnames';
import * as React from 'react';
import { withScrollTo } from '../../../components/hoc/withScrollTo';
import { WorkspaceContext } from '../../../components/workspace/context';
+import { BranchLike } from '../../../types/branch-like';
import ComponentMeasure from './ComponentMeasure';
import ComponentName from './ComponentName';
import ComponentPin from './ComponentPin';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
canBePinned?: boolean;
canBrowse?: boolean;
component: T.ComponentMeasure;
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 7b1777b019f..d59bf558e99 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
@@ -19,11 +19,12 @@
*/
import * as React from 'react';
import { Link } from 'react-router';
-import LongLivingBranchIcon from 'sonar-ui-common/components/icons/LongLivingBranchIcon';
+import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon';
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { colors } from '../../../app/theme';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
export function getTooltip(component: T.ComponentMeasure) {
const isFile = component.qualifier === 'FIL' || component.qualifier === 'UTS';
@@ -50,7 +51,7 @@ export function mostCommonPrefix(strings: string[]) {
}
export interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
canBrowse?: boolean;
component: T.ComponentMeasure;
previous?: T.ComponentMeasure;
@@ -115,7 +116,7 @@ export default function ComponentName({
</span>
{component.branch ? (
<span className="text-ellipsis spacer-left">
- <LongLivingBranchIcon className="little-spacer-right" />
+ <BranchIcon className="little-spacer-right" />
<span className="note">{component.branch}</span>
</span>
) : (
diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentPin.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentPin.tsx
index 5db17fbcdac..1192a7bf378 100644
--- a/server/sonar-web/src/main/js/apps/code/components/ComponentPin.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/ComponentPin.tsx
@@ -21,9 +21,10 @@ import * as React from 'react';
import PinIcon from 'sonar-ui-common/components/icons/PinIcon';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { WorkspaceContextShape } from '../../../components/workspace/context';
+import { BranchLike } from '../../../types/branch-like';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.ComponentMeasure;
openComponent: WorkspaceContextShape['openComponent'];
}
diff --git a/server/sonar-web/src/main/js/apps/code/components/Components.tsx b/server/sonar-web/src/main/js/apps/code/components/Components.tsx
index c00591859b8..c2becafee67 100644
--- a/server/sonar-web/src/main/js/apps/code/components/Components.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/Components.tsx
@@ -20,6 +20,7 @@
import { intersection } from 'lodash';
import * as React from 'react';
import withKeyboardNavigation from '../../../components/hoc/withKeyboardNavigation';
+import { BranchLike } from '../../../types/branch-like';
import { getCodeMetrics } from '../utils';
import Component from './Component';
import ComponentsEmpty from './ComponentsEmpty';
@@ -27,7 +28,7 @@ import ComponentsHeader from './ComponentsHeader';
interface Props {
baseComponent?: T.ComponentMeasure;
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
components: T.ComponentMeasure[];
metrics: T.Dict<T.Metric>;
rootComponent: T.ComponentMeasure;
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 60f79e0c11b..f96354586e1 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
@@ -23,10 +23,11 @@ import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { getTree } from '../../../api/components';
import { Location, Router, withRouter } from '../../../components/hoc/withRouter';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.ComponentMeasure;
location: Location;
onSearchClear: () => void;
diff --git a/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx b/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx
index f9882605bbc..54eb83691a0 100644
--- a/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx
@@ -22,9 +22,10 @@ import * as React from 'react';
import { scrollToElement } from 'sonar-ui-common/helpers/scrolling';
import withKeyboardNavigation from '../../../components/hoc/withKeyboardNavigation';
import SourceViewer from '../../../components/SourceViewer/SourceViewer';
+import { BranchLike } from '../../../types/branch-like';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: string;
componentMeasures: T.Measure[] | undefined;
location: Pick<Location, 'query'>;
diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/code/components/__tests__/App-test.tsx
index f00cf796cc7..1562febba7b 100644
--- a/server/sonar-web/src/main/js/apps/code/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/App-test.tsx
@@ -20,7 +20,8 @@
import { shallow } from 'enzyme';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
-import { mockIssue, mockPullRequest, mockRouter } from '../../../../helpers/testMocks';
+import { mockPullRequest } from '../../../../helpers/mocks/branch-like';
+import { mockIssue, mockRouter } from '../../../../helpers/testMocks';
import { retrieveComponent } from '../../utils';
import { App } from '../App';
diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentName-test.tsx b/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentName-test.tsx
index daac35be17a..9a88d78a3b3 100644
--- a/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentName-test.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentName-test.tsx
@@ -19,7 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockComponentMeasure, mockMainBranch } from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponentMeasure } from '../../../../helpers/testMocks';
import ComponentName, { getTooltip, mostCommonPrefix, Props } from '../ComponentName';
describe('#getTooltip', () => {
diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/Components-test.tsx b/server/sonar-web/src/main/js/apps/code/components/__tests__/Components-test.tsx
index 6b3f69fb0ad..fcebb14a93b 100644
--- a/server/sonar-web/src/main/js/apps/code/components/__tests__/Components-test.tsx
+++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/Components-test.tsx
@@ -19,18 +19,13 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
+import { mockBranch } from '../../../../helpers/mocks/branch-like';
import { Components } from '../Components';
const COMPONENT = { key: 'foo', name: 'Foo', qualifier: 'TRK' };
const PORTFOLIO = { key: 'bar', name: 'Bar', qualifier: 'VW' };
const METRICS = { coverage: { id: '1', key: 'coverage', type: 'PERCENT', name: 'Coverage' } };
-const BRANCH: T.ShortLivingBranch = {
- isMain: false,
- excludedFromPurge: true,
- name: 'feature',
- mergeBranch: 'master',
- type: 'SHORT'
-};
+const BRANCH = mockBranch({ name: 'feature' });
it('renders correctly', () => {
expect(
diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentName-test.tsx.snap b/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentName-test.tsx.snap
index df54b7a90a7..4cc11714524 100644
--- a/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentName-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentName-test.tsx.snap
@@ -160,7 +160,7 @@ foo:src/index.tsx"
<span
className="text-ellipsis spacer-left"
>
- <LongLivingBranchIcon
+ <BranchIcon
className="little-spacer-right"
/>
<span
@@ -239,7 +239,7 @@ foo"
<span
className="text-ellipsis spacer-left"
>
- <LongLivingBranchIcon
+ <BranchIcon
className="little-spacer-right"
/>
<span
diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Components-test.tsx.snap b/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Components-test.tsx.snap
index 80bb548aad6..d2382b2ac84 100644
--- a/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Components-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Components-test.tsx.snap
@@ -165,7 +165,11 @@ exports[`renders correctly for leak 1`] = `
}
}
canBePinned={true}
- metrics={Array []}
+ metrics={
+ Array [
+ "coverage",
+ ]
+ }
rootComponent={
Object {
"key": "foo",
@@ -178,11 +182,10 @@ exports[`renders correctly for leak 1`] = `
<withScrollTo(Component)
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
"name": "feature",
- "type": "SHORT",
}
}
canBePinned={true}
@@ -194,7 +197,16 @@ exports[`renders correctly for leak 1`] = `
}
}
key="foo"
- metrics={Array []}
+ metrics={
+ Array [
+ Object {
+ "id": "1",
+ "key": "coverage",
+ "name": "Coverage",
+ "type": "PERCENT",
+ },
+ ]
+ }
rootComponent={
Object {
"key": "foo",
@@ -212,7 +224,7 @@ exports[`renders correctly for leak 1`] = `
 
</td>
<td
- colSpan={4}
+ colSpan={5}
>
 
</td>
@@ -222,11 +234,10 @@ exports[`renders correctly for leak 1`] = `
<withScrollTo(Component)
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
"name": "feature",
- "type": "SHORT",
}
}
canBePinned={true}
@@ -239,7 +250,16 @@ exports[`renders correctly for leak 1`] = `
}
}
key="foo"
- metrics={Array []}
+ metrics={
+ Array [
+ Object {
+ "id": "1",
+ "key": "coverage",
+ "name": "Coverage",
+ "type": "PERCENT",
+ },
+ ]
+ }
rootComponent={
Object {
"key": "foo",
@@ -255,7 +275,7 @@ exports[`renders correctly for leak 1`] = `
colSpan={3}
/>
<td
- colSpan={4}
+ colSpan={5}
/>
</tr>
</tbody>
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 2e05df99a95..6545960953d 100644
--- a/server/sonar-web/src/main/js/apps/code/utils.ts
+++ b/server/sonar-web/src/main/js/apps/code/utils.ts
@@ -18,7 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getBreadcrumbs, getChildren, getComponent } from '../../api/components';
-import { getBranchLikeQuery, isPullRequest, isShortLivingBranch } from '../../helpers/branches';
+import { getBranchLikeQuery, isPullRequest } from '../../helpers/branch-like';
+import { BranchLike } from '../../types/branch-like';
import {
addComponent,
addComponentBreadcrumbs,
@@ -75,8 +76,8 @@ function prepareChildren(r: any): Children {
};
}
-export function showLeakMeasure(branchLike?: T.BranchLike) {
- return isShortLivingBranch(branchLike) || isPullRequest(branchLike);
+export function showLeakMeasure(branchLike?: BranchLike) {
+ return isPullRequest(branchLike);
}
function skipRootDir(breadcrumbs: T.ComponentMeasure[]) {
@@ -101,7 +102,7 @@ function storeChildrenBreadcrumbs(parentComponentKey: string, children: T.Breadc
export function getCodeMetrics(
qualifier: string,
- branchLike?: T.BranchLike,
+ branchLike?: BranchLike,
options: { includeQGStatus?: boolean } = {}
) {
if (['VW', 'SVW'].includes(qualifier)) {
@@ -117,7 +118,7 @@ export function getCodeMetrics(
return [...METRICS];
}
-function retrieveComponentBase(componentKey: string, qualifier: string, branchLike?: T.BranchLike) {
+function retrieveComponentBase(componentKey: string, qualifier: string, branchLike?: BranchLike) {
const existing = getComponentFromBucket(componentKey);
if (existing) {
return Promise.resolve(existing);
@@ -138,7 +139,7 @@ function retrieveComponentBase(componentKey: string, qualifier: string, branchLi
export function retrieveComponentChildren(
componentKey: string,
qualifier: string,
- branchLike?: T.BranchLike
+ branchLike?: BranchLike
): Promise<{ components: T.ComponentMeasure[]; page: number; total: number }> {
const existing = getComponentChildren(componentKey);
if (existing) {
@@ -167,7 +168,7 @@ export function retrieveComponentChildren(
function retrieveComponentBreadcrumbs(
component: string,
- branchLike?: T.BranchLike
+ branchLike?: BranchLike
): Promise<T.Breadcrumb[]> {
const existing = getComponentBreadcrumbs(component);
if (existing) {
@@ -185,7 +186,7 @@ function retrieveComponentBreadcrumbs(
export function retrieveComponent(
componentKey: string,
qualifier: string,
- branchLike?: T.BranchLike
+ branchLike?: BranchLike
): Promise<{
breadcrumbs: T.Breadcrumb[];
component: T.ComponentMeasure;
@@ -212,7 +213,7 @@ export function loadMoreChildren(
componentKey: string,
page: number,
qualifier: string,
- branchLike?: T.BranchLike
+ branchLike?: BranchLike
): Promise<Children> {
const metrics = getCodeMetrics(qualifier, branchLike, { includeQGStatus: true });
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx
index 71e0c6f3c84..6bb6b79c662 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx
@@ -40,14 +40,10 @@ import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
import ScreenPositionHelper from '../../../components/common/ScreenPositionHelper';
import { enhanceMeasure } from '../../../components/measure/utils';
import '../../../components/search-navigator.css';
-import {
- getBranchLikeQuery,
- isPullRequest,
- isSameBranchLike,
- isShortLivingBranch
-} from '../../../helpers/branches';
+import { getBranchLikeQuery, isPullRequest, isSameBranchLike } from '../../../helpers/branch-like';
import { getLeakPeriod } from '../../../helpers/periods';
import { fetchBranchStatus } from '../../../store/rootActions';
+import { BranchLike } from '../../../types/branch-like';
import Sidebar from '../sidebar/Sidebar';
import '../style.css';
import {
@@ -68,9 +64,9 @@ import MeasureOverviewContainer from './MeasureOverviewContainer';
import MeasuresEmpty from './MeasuresEmpty';
interface Props extends WithRouterProps {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.ComponentMeasure;
- fetchBranchStatus: (branchLike: T.BranchLike, projectKey: string) => Promise<void>;
+ fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>;
}
interface State {
@@ -240,7 +236,7 @@ export class App extends React.PureComponent<Props, State> {
refreshBranchStatus = () => {
const { branchLike, component } = this.props;
- if (branchLike && component && (isPullRequest(branchLike) || isShortLivingBranch(branchLike))) {
+ if (branchLike && component && isPullRequest(branchLike)) {
this.props.fetchBranchStatus(branchLike, component.key);
}
};
@@ -270,7 +266,7 @@ export class App extends React.PureComponent<Props, State> {
}
const hideDrilldown =
- (isShortLivingBranch(branchLike) || isPullRequest(branchLike)) &&
+ isPullRequest(branchLike) &&
(metric.key === 'coverage' || metric.key === 'duplicated_lines_density');
if (hideDrilldown) {
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx
index f6878654a74..e9ae667a0df 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx
@@ -20,12 +20,13 @@
import * as key from 'keymaster';
import * as React from 'react';
import { getBreadcrumbs } from '../../../api/components';
-import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches';
+import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
import Breadcrumb from './Breadcrumb';
interface Props {
backToFirst: boolean;
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
className?: string;
component: T.ComponentMeasure;
handleSelect: (component: string) => void;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx
index 6957a37935b..0965640b17d 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx
@@ -26,9 +26,10 @@ import { getComponentTree } from '../../../api/components';
import { getMeasures } from '../../../api/measures';
import A11ySkipTarget from '../../../app/components/a11y/A11ySkipTarget';
import SourceViewer from '../../../components/SourceViewer/SourceViewer';
-import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches';
+import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like';
import { getPeriodValue, isDiffMetric } from '../../../helpers/measures';
import { getProjectUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import { complementary } from '../config/complementary';
import FilesView from '../drilldown/FilesView';
import TreeMapView from '../drilldown/TreeMapView';
@@ -39,7 +40,7 @@ import MeasureHeader from './MeasureHeader';
import MeasureViewSelect from './MeasureViewSelect';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
leakPeriod?: T.Period;
requestedMetric: Pick<T.Metric, 'key' | 'direction'>;
metrics: T.Dict<T.Metric>;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx
index 328e5f7c213..6af4582d976 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx
@@ -27,11 +27,12 @@ import LanguageDistributionContainer from '../../../components/charts/LanguageDi
import Measure from '../../../components/measure/Measure';
import { isDiffMetric } from '../../../helpers/measures';
import { getMeasureHistoryUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import { hasFullMeasures } from '../utils';
import LeakPeriodLegend from './LeakPeriodLegend';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.ComponentMeasure;
leakPeriod?: T.Period;
measureValue?: string;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx
index 6e2d3ff6132..5dc7b04e692 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx
@@ -23,7 +23,8 @@ import PageActions from 'sonar-ui-common/components/ui/PageActions';
import { getComponentLeaves } from '../../../api/components';
import A11ySkipTarget from '../../../app/components/a11y/A11ySkipTarget';
import SourceViewer from '../../../components/SourceViewer/SourceViewer';
-import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches';
+import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
import BubbleChart from '../drilldown/BubbleChart';
import { enhanceComponent, getBubbleMetrics, hasFullMeasures, isFileType } from '../utils';
import Breadcrumbs from './Breadcrumbs';
@@ -31,7 +32,7 @@ import LeakPeriodLegend from './LeakPeriodLegend';
import MeasureContentHeader from './MeasureContentHeader';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
className?: string;
component: T.ComponentMeasure;
domain: string;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx
index 335367d9235..677c09e9868 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx
@@ -20,13 +20,14 @@
import * as React from 'react';
import { InjectedRouter } from 'react-router';
import { getComponentShow } from '../../../api/components';
-import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches';
+import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like';
import { getProjectUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import { isViewType, Query } from '../utils';
import MeasureOverview from './MeasureOverview';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
className?: string;
domain: string;
leakPeriod?: T.Period;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx
index 817f237ff98..fa45839a60d 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/App-test.tsx
@@ -21,14 +21,8 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { getMeasuresAndMeta } from '../../../../api/measures';
-import {
- mockComponent,
- mockIssue,
- mockLocation,
- mockMainBranch,
- mockPullRequest,
- mockRouter
-} from '../../../../helpers/testMocks';
+import { mockMainBranch, mockPullRequest } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockIssue, mockLocation, mockRouter } from '../../../../helpers/testMocks';
import { App } from '../App';
jest.mock('../../../../api/metrics', () => ({
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx
index 2dbe1bb2b19..c13e0511317 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx
@@ -19,6 +19,7 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
+import { mockBranch } from '../../../../helpers/mocks/branch-like';
import MeasureHeader from '../MeasureHeader';
const METRIC = {
@@ -64,31 +65,13 @@ it('should render correctly for leak', () => {
).toMatchSnapshot();
});
-it('should render with long living branch', () => {
- const longBranch: T.LongLivingBranch = {
- isMain: false,
- excludedFromPurge: true,
- name: 'branch-6.7',
- type: 'LONG'
- };
- expect(
- shallow(<MeasureHeader branchLike={longBranch} {...PROPS} />).find('Link')
- ).toMatchSnapshot();
-});
-
-it('should render with short living branch', () => {
- const shortBranch: T.ShortLivingBranch = {
- isMain: false,
- excludedFromPurge: true,
- name: 'feature',
- mergeBranch: 'master',
- type: 'SHORT'
- };
+it('should render with a branch', () => {
+ const branch = mockBranch({ name: 'feature' });
expect(
shallow(
<MeasureHeader
{...PROPS}
- branchLike={shortBranch}
+ branchLike={branch}
measureValue={LEAK_MEASURE}
metric={LEAK_METRIC}
/>
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/MeasureHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/MeasureHeader-test.tsx.snap
index ebd56775016..2e025bedaf5 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/MeasureHeader-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/MeasureHeader-test.tsx.snap
@@ -128,28 +128,7 @@ exports[`should render correctly for leak 1`] = `
</div>
`;
-exports[`should render with long living branch 1`] = `
-<Link
- className="js-show-history spacer-left button button-small"
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/project/activity",
- "query": Object {
- "branch": "branch-6.7",
- "custom_metrics": "reliability_rating",
- "graph": "custom",
- "id": "foo",
- },
- }
- }
->
- <HistoryIcon />
-</Link>
-`;
-
-exports[`should render with short living branch 1`] = `
+exports[`should render with a branch 1`] = `
<div
className="measure-details-header big-spacer-bottom"
>
@@ -169,6 +148,7 @@ exports[`should render with short living branch 1`] = `
>
<strong>
<Measure
+ className="leak-box"
metricKey="new_reliability_rating"
metricType="RATING"
value="3.0"
@@ -178,7 +158,26 @@ exports[`should render with short living branch 1`] = `
</div>
<div
className="measure-details-primary-actions"
- />
+ >
+ <InjectIntl(LeakPeriodLegend)
+ className="spacer-left"
+ component={
+ Object {
+ "key": "foo",
+ "name": "Foo",
+ "qualifier": "TRK",
+ }
+ }
+ period={
+ Object {
+ "date": "2017-05-16T13:50:02+0200",
+ "index": 1,
+ "mode": "previous_version",
+ "parameter": "6,4",
+ }
+ }
+ />
+ </div>
</div>
</div>
`;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx
index 4f8271724dd..0584975b751 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx
@@ -19,8 +19,8 @@
*/
import * as React from 'react';
import { Link } from 'react-router';
+import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon';
import LinkIcon from 'sonar-ui-common/components/icons/LinkIcon';
-import LongLivingBranchIcon from 'sonar-ui-common/components/icons/LongLivingBranchIcon';
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { splitPath } from 'sonar-ui-common/helpers/path';
@@ -30,10 +30,11 @@ import {
getComponentDrilldownUrlWithSelection,
getProjectUrl
} from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import { View } from '../utils';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.ComponentMeasureEnhanced;
onClick: (component: string) => void;
metric: T.Metric;
@@ -76,7 +77,7 @@ export default class ComponentCell extends React.PureComponent<Props> {
<>
{component.branch ? (
<>
- <LongLivingBranchIcon className="spacer-left little-spacer-right" />
+ <BranchIcon className="spacer-left little-spacer-right" />
<span className="note">{component.branch}</span>
</>
) : (
diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx
index cba704176e3..a6a3cfc2834 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx
@@ -19,13 +19,14 @@
*/
import * as React from 'react';
import { getLocalizedMetricName } from 'sonar-ui-common/helpers/l10n';
+import { BranchLike } from '../../../types/branch-like';
import { complementary } from '../config/complementary';
import { View } from '../utils';
import ComponentsListRow from './ComponentsListRow';
import EmptyResult from './EmptyResult';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
components: T.ComponentMeasureEnhanced[];
onClick: (component: string) => void;
metric: T.Metric;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx
index 54ebdbb3864..22a460696e5 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx
@@ -19,12 +19,13 @@
*/
import * as classNames from 'classnames';
import * as React from 'react';
+import { BranchLike } from '../../../types/branch-like';
import { View } from '../utils';
import ComponentCell from './ComponentCell';
import MeasureCell from './MeasureCell';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.ComponentMeasureEnhanced;
isSelected: boolean;
onClick: (component: string) => void;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx
index d04308c887e..40e35ae9061 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx
@@ -27,11 +27,12 @@ import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n
import { formatMeasure } from 'sonar-ui-common/helpers/measures';
import { scrollToElement } from 'sonar-ui-common/helpers/scrolling';
import { isDiffMetric, isPeriodBestValue } from '../../../helpers/measures';
+import { BranchLike } from '../../../types/branch-like';
import { View } from '../utils';
import ComponentsList from './ComponentsList';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
components: T.ComponentMeasureEnhanced[];
defaultShowBestMeasures: boolean;
fetchMore: () => void;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx
index 51e8a668c0e..27c4f291b5c 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx
@@ -33,10 +33,11 @@ import { isDefined } from 'sonar-ui-common/helpers/types';
import { colors } from '../../../app/theme';
import ColorBoxLegend from '../../../components/charts/ColorBoxLegend';
import { isDiffMetric } from '../../../helpers/measures';
+import { BranchLike } from '../../../types/branch-like';
import EmptyResult from './EmptyResult';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
components: T.ComponentMeasureEnhanced[];
handleSelect: (component: string) => void;
metric: T.Metric;
diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.ts b/server/sonar-web/src/main/js/apps/component-measures/utils.ts
index 1195b0a9681..e6263ad863a 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/utils.ts
+++ b/server/sonar-web/src/main/js/apps/component-measures/utils.ts
@@ -21,13 +21,9 @@ import { groupBy, memoize, sortBy, toPairs } from 'lodash';
import { getLocalizedMetricName } from 'sonar-ui-common/helpers/l10n';
import { cleanQuery, parseAsString, serializeString } from 'sonar-ui-common/helpers/query';
import { enhanceMeasure } from '../../components/measure/utils';
-import {
- isLongLivingBranch,
- isMainBranch,
- isPullRequest,
- isShortLivingBranch
-} from '../../helpers/branches';
+import { isBranch, isPullRequest } from '../../helpers/branch-like';
import { getDisplayMetrics, isDiffMetric } from '../../helpers/measures';
+import { BranchLike } from '../../types/branch-like';
import { bubbles } from './config/bubbles';
import { domains } from './config/domains';
@@ -149,14 +145,14 @@ export function hasFacetStat(metric: string): boolean {
return metric !== 'alert_status';
}
-export function hasFullMeasures(branch?: T.BranchLike) {
- return !branch || isLongLivingBranch(branch) || isMainBranch(branch);
+export function hasFullMeasures(branch?: BranchLike) {
+ return !branch || isBranch(branch);
}
-export function getMeasuresPageMetricKeys(metrics: T.Dict<T.Metric>, branch?: T.BranchLike) {
+export function getMeasuresPageMetricKeys(metrics: T.Dict<T.Metric>, branch?: BranchLike) {
const metricKeys = getDisplayMetrics(Object.values(metrics)).map(metric => metric.key);
- if (isPullRequest(branch) || isShortLivingBranch(branch)) {
+ if (isPullRequest(branch)) {
return metricKeys.filter(key => isDiffMetric(key));
} else {
return metricKeys;
diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.tsx b/server/sonar-web/src/main/js/apps/issues/components/App.tsx
index 2827236403d..51a16d0d3c4 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/App.tsx
@@ -47,11 +47,11 @@ import {
fillBranchLike,
getBranchLikeQuery,
isPullRequest,
- isSameBranchLike,
- isShortLivingBranch
-} from '../../../helpers/branches';
+ isSameBranchLike
+} from '../../../helpers/branch-like';
import { isSonarCloud } from '../../../helpers/system';
import { fetchBranchStatus } from '../../../store/rootActions';
+import { BranchLike } from '../../../types/branch-like';
import * as actions from '../actions';
import ConciseIssuesList from '../conciseIssuesList/ConciseIssuesList';
import ConciseIssuesListHeader from '../conciseIssuesList/ConciseIssuesListHeader';
@@ -99,10 +99,10 @@ interface FetchIssuesPromise {
}
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component?: T.Component;
currentUser: T.CurrentUser;
- fetchBranchStatus: (branchLike: T.BranchLike, projectKey: string) => Promise<void>;
+ fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>;
fetchIssues: (query: T.RawQuery, requestOrganizations?: boolean) => Promise<FetchIssuesPromise>;
hideAuthorFacet?: boolean;
location: Pick<Location, 'pathname' | 'query'>;
@@ -827,7 +827,7 @@ export class App extends React.PureComponent<Props, State> {
handleReload = () => {
this.fetchFirstIssues();
this.refreshBranchStatus();
- if (isShortLivingBranch(this.props.branchLike) || isPullRequest(this.props.branchLike)) {
+ if (isPullRequest(this.props.branchLike)) {
this.props.onBranchesChange();
}
};
@@ -880,7 +880,7 @@ export class App extends React.PureComponent<Props, State> {
refreshBranchStatus = () => {
const { branchLike, component } = this.props;
- if (branchLike && component && (isPullRequest(branchLike) || isShortLivingBranch(branchLike))) {
+ if (branchLike && component && isPullRequest(branchLike)) {
this.props.fetchBranchStatus(branchLike, component.key);
}
};
diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx
index ed378927511..ce6222dc4a3 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx
@@ -18,11 +18,12 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { BranchLike } from '../../../types/branch-like';
import { Query, scrollToIssue } from '../utils';
import ListItem from './ListItem';
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
checked: string[];
component: T.Component | undefined;
issues: T.Issue[];
diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx
index 22c337cd48e..efc0a60e9a8 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx
@@ -21,11 +21,12 @@ import { uniq } from 'lodash';
import * as React from 'react';
import { scrollToElement } from 'sonar-ui-common/helpers/scrolling';
import SourceViewer from '../../../components/SourceViewer/SourceViewer';
+import { BranchLike } from '../../../types/branch-like';
import CrossComponentSourceViewer from '../crossComponentSourceViewer/CrossComponentSourceViewer';
import { getLocations, getSelectedLocation } from '../utils';
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
issues: T.Issue[];
loadIssues: (component: string, from: number, to: number) => Promise<T.Issue[]>;
locationsNavigator: boolean;
diff --git a/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx b/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx
index d8aa5380053..915a2560eba 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx
@@ -19,11 +19,12 @@
*/
import * as React from 'react';
import Issue from '../../../components/issue/Issue';
+import { BranchLike } from '../../../types/branch-like';
import { Query } from '../utils';
import ComponentBreadcrumbs from './ComponentBreadcrumbs';
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
checked: boolean;
component: T.Component | undefined;
issue: T.Issue;
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx
index 994700df140..7c30c5eee4e 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx
@@ -21,6 +21,7 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import handleRequiredAuthentication from 'sonar-ui-common/helpers/handleRequiredAuthentication';
import { KEYCODE_MAP, keydown, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
+import { mockPullRequest } from '../../../../helpers/mocks/branch-like';
import {
mockComponent,
mockCurrentUser,
@@ -28,7 +29,6 @@ import {
mockIssue,
mockLocation,
mockLoggedInUser,
- mockPullRequest,
mockRouter
} from '../../../../helpers/testMocks';
import {
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesSourceViewer-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesSourceViewer-test.tsx
index 9e96ee51066..086c9abb913 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesSourceViewer-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesSourceViewer-test.tsx
@@ -19,7 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockIssue, mockMainBranch } from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockIssue } from '../../../../helpers/testMocks';
import IssuesSourceViewer from '../IssuesSourceViewer';
it('should render SourceViewer correctly', () => {
diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx
index 1b2d958ca19..e9bbd64033b 100644
--- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx
@@ -23,7 +23,8 @@ import { getSources } from '../../../api/components';
import getCoverageStatus from '../../../components/SourceViewer/helpers/getCoverageStatus';
import { locationsByLine } from '../../../components/SourceViewer/helpers/indexing';
import SourceViewerHeaderSlim from '../../../components/SourceViewer/SourceViewerHeaderSlim';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
import SnippetViewer from './SnippetViewer';
import {
createSnippets,
@@ -34,7 +35,7 @@ import {
} from './utils';
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
duplications?: T.Duplication[];
duplicationsByLine?: { [line: number]: number[] };
highlightedLocationMessage: { index: number; text: string | undefined } | undefined;
diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx
index b324a014aa3..4c1435391f7 100644
--- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx
@@ -33,12 +33,13 @@ import {
} from '../../../components/SourceViewer/helpers/indexing';
import { SourceViewerContext } from '../../../components/SourceViewer/SourceViewerContext';
import { WorkspaceContext } from '../../../components/workspace/context';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
import ComponentSourceSnippetViewer from './ComponentSourceSnippetViewer';
import { groupLocationsByComponent } from './utils';
interface Props {
- branchLike: T.Branch | T.PullRequest | undefined;
+ branchLike: BranchLike | undefined;
highlightedLocationMessage?: { index: number; text: string | undefined };
issue: T.Issue;
issues: T.Issue[];
diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx
index 621fc9f32f0..6c246054588 100644
--- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx
@@ -30,10 +30,11 @@ import {
optimizeLocationMessage,
optimizeSelectedIssue
} from '../../../components/SourceViewer/helpers/lines';
+import { BranchLike } from '../../../types/branch-like';
import { inSnippet, LINES_BELOW_ISSUE } from './utils';
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
component: T.SourceViewerFile;
duplications?: T.Duplication[];
duplicationsByLine?: { [line: number]: number[] };
diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetViewer-test.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetViewer-test.tsx
index eda23a7515f..666434672dd 100644
--- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetViewer-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetViewer-test.tsx
@@ -22,11 +22,10 @@ import { range, times } from 'lodash';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { getSources } from '../../../../api/components';
+import { mockBranch, mockMainBranch } from '../../../../helpers/mocks/branch-like';
import {
mockFlowLocation,
mockIssue,
- mockMainBranch,
- mockShortLivingBranch,
mockSnippetsByComponent,
mockSourceLine,
mockSourceViewerFile
@@ -144,7 +143,7 @@ it('should get the right branch when expanding', async () => {
};
const wrapper = shallowRender({
- branchLike: mockShortLivingBranch({ name: 'asdf' }),
+ branchLike: mockBranch({ name: 'asdf' }),
snippetGroup
});
diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/SnippetViewer-test.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/SnippetViewer-test.tsx
index a802a998d9e..97e9bd31039 100644
--- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/SnippetViewer-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/SnippetViewer-test.tsx
@@ -21,12 +21,8 @@ import { mount, shallow } from 'enzyme';
import { range } from 'lodash';
import * as React from 'react';
import { scrollHorizontally } from 'sonar-ui-common/helpers/scrolling';
-import {
- mockIssue,
- mockMainBranch,
- mockSourceLine,
- mockSourceViewerFile
-} from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockIssue, mockSourceLine, mockSourceViewerFile } from '../../../../helpers/testMocks';
import SnippetViewer from '../SnippetViewer';
jest.mock('sonar-ui-common/helpers/scrolling', () => ({
diff --git a/server/sonar-web/src/main/js/apps/overview/badges/ProjectBadges.tsx b/server/sonar-web/src/main/js/apps/overview/badges/ProjectBadges.tsx
index 145d2bdcc48..0f3a469fe57 100644
--- a/server/sonar-web/src/main/js/apps/overview/badges/ProjectBadges.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/badges/ProjectBadges.tsx
@@ -22,15 +22,16 @@ import { Button, ResetButtonLink } from 'sonar-ui-common/components/controls/but
import Modal from 'sonar-ui-common/components/controls/Modal';
import { translate } from 'sonar-ui-common/helpers/l10n';
import CodeSnippet from '../../../components/common/CodeSnippet';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
import { isSonarCloud } from '../../../helpers/system';
+import { BranchLike } from '../../../types/branch-like';
import BadgeButton from './BadgeButton';
import BadgeParams from './BadgeParams';
import './styles.css';
import { BadgeOptions, BadgeType, getBadgeSnippet, getBadgeUrl } from './utils';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
metrics: T.Dict<T.Metric>;
project: string;
qualifier: string;
diff --git a/server/sonar-web/src/main/js/apps/overview/badges/__tests__/ProjectBadges-test.tsx b/server/sonar-web/src/main/js/apps/overview/badges/__tests__/ProjectBadges-test.tsx
index d911a9f1fa8..b56fbe8a913 100644
--- a/server/sonar-web/src/main/js/apps/overview/badges/__tests__/ProjectBadges-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/badges/__tests__/ProjectBadges-test.tsx
@@ -21,6 +21,7 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { click } from 'sonar-ui-common/helpers/testUtils';
import { Location } from 'sonar-ui-common/helpers/urls';
+import { mockBranch } from '../../../../helpers/mocks/branch-like';
import { isSonarCloud } from '../../../../helpers/system';
import ProjectBadges from '../ProjectBadges';
@@ -35,13 +36,7 @@ jest.mock('../../../../helpers/urls', () => ({
jest.mock('../../../../helpers/system', () => ({ isSonarCloud: jest.fn() }));
-const shortBranch: T.ShortLivingBranch = {
- excludedFromPurge: true,
- isMain: false,
- mergeBranch: '',
- name: 'branch-6.6',
- type: 'SHORT'
-};
+const shortBranch = mockBranch({ name: 'branch-6.6' });
it('should display the modal after click on sonarcloud', () => {
(isSonarCloud as jest.Mock).mockImplementation(() => true);
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 71fd2c09ed8..caf767f3e59 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
@@ -23,17 +23,18 @@ import { lazyLoad } from 'sonar-ui-common/components/lazyLoad';
import { getBaseUrl, getPathUrlAsString } from 'sonar-ui-common/helpers/urls';
import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
import { Router, withRouter } from '../../../components/hoc/withRouter';
-import { isPullRequest, isShortLivingBranch } from '../../../helpers/branches';
+import { isPullRequest } from '../../../helpers/branch-like';
import { isSonarCloud } from '../../../helpers/system';
import { getProjectUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import OverviewApp from './OverviewApp';
const EmptyOverview = lazyLoad(() => import('./EmptyOverview'));
const ReviewApp = lazyLoad(() => import('../pullRequests/ReviewApp'));
interface Props {
- branchLike?: T.BranchLike;
- branchLikes: T.BranchLike[];
+ branchLike?: BranchLike;
+ branchLikes: BranchLike[];
component: T.Component;
isInProgress?: boolean;
isPending?: boolean;
@@ -75,7 +76,7 @@ export class App extends React.PureComponent<Props> {
</Helmet>
)}
- {isShortLivingBranch(branchLike) || isPullRequest(branchLike) ? (
+ {isPullRequest(branchLike) ? (
<>
<Suggestions suggestions="pull_requests" />
<ReviewApp branchLike={branchLike} component={component} />
diff --git a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx
index f8e88da5743..62d215f7601 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx
@@ -25,9 +25,10 @@ import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n
import { getApplicationLeak } from '../../../api/application';
import DateFromNow from '../../../components/intl/DateFromNow';
import DateTooltipFormatter from '../../../components/intl/DateTooltipFormatter';
+import { Branch } from '../../../types/branch-like';
interface Props {
- branch?: T.LongLivingBranch;
+ branch?: Branch;
component: T.LightComponent;
}
diff --git a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx
index 6035db37576..0c0ae576314 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx
@@ -22,17 +22,18 @@ import { FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import { Alert } from 'sonar-ui-common/components/ui/Alert';
import { translate } from 'sonar-ui-common/helpers/l10n';
-import { isBranch, isLongLivingBranch, isMainBranch } from '../../../helpers/branches';
+import { isBranch, isMainBranch } from '../../../helpers/branch-like';
import { isSonarCloud } from '../../../helpers/system';
import { isLoggedIn } from '../../../helpers/users';
import { getCurrentUser, Store } from '../../../store/rootReducer';
+import { BranchLike } from '../../../types/branch-like';
import AnalyzeTutorial from '../../tutorials/analyzeProject/AnalyzeTutorial';
import AnalyzeTutorialSonarCloud from '../../tutorials/analyzeProject/AnalyzeTutorialSonarCloud';
import MetaContainer from '../meta/MetaContainer';
interface OwnProps {
- branchLike?: T.BranchLike;
- branchLikes: T.BranchLike[];
+ branchLike?: BranchLike;
+ branchLikes: BranchLike[];
component: T.Component;
hasAnalyses?: boolean;
onComponentChange: (changes: {}) => void;
@@ -55,7 +56,8 @@ export function EmptyOverview({
const hasBranches = branchLikes.length > 1;
const hasBadBranchConfig =
branchLikes.length > 2 ||
- (branchLikes.length === 2 && branchLikes.some(branch => isLongLivingBranch(branch)));
+ (branchLikes.length === 2 &&
+ branchLikes.some(branch => isBranch(branch) && !isMainBranch(branchLike)));
return (
<div className="page page-limited">
<div className="overview page-with-sidebar">
@@ -106,7 +108,7 @@ export function WarningMessage({
branchLike,
message
}: {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
message: string;
}) {
if (!isBranch(branchLike)) {
diff --git a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx
index c907475cef5..8f8ea7ac59a 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx
@@ -28,14 +28,15 @@ import A11ySkipTarget from '../../../app/components/a11y/A11ySkipTarget';
import {
getBranchLikeDisplayName,
getBranchLikeQuery,
- isLongLivingBranch,
+ isBranch,
isMainBranch,
isSameBranchLike
-} from '../../../helpers/branches';
+} from '../../../helpers/branch-like';
import { enhanceMeasuresWithMetrics } from '../../../helpers/measures';
import { getLeakPeriod } from '../../../helpers/periods';
import { fetchMetrics } from '../../../store/rootActions';
import { getMetrics, Store } from '../../../store/rootReducer';
+import { BranchLike } from '../../../types/branch-like';
import {
DEFAULT_GRAPH,
getDisplayedHistoryMetrics,
@@ -53,7 +54,7 @@ import '../styles.css';
import { HISTORY_METRICS_LIST, METRICS } from '../utils';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.Component;
fetchMetrics: () => void;
onComponentChange: (changes: {}) => void;
@@ -251,7 +252,7 @@ export class OverviewApp extends React.PureComponent<Props, State> {
<div className="overview-main page-main">
{component.qualifier === 'APP' ? (
<ApplicationQualityGate
- branch={isLongLivingBranch(branchLike) ? branchLike : undefined}
+ branch={isBranch(branchLike) && !isMainBranch(branchLike) ? branchLike : undefined}
component={component}
/>
) : (
diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx
index f442759f929..e5ba82ef9d9 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx
@@ -19,12 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import {
- mockComponent,
- mockLoggedInUser,
- mockMainBranch,
- mockPullRequest
-} from '../../../../helpers/testMocks';
+import { mockMainBranch, mockPullRequest } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockLoggedInUser } from '../../../../helpers/testMocks';
import { EmptyOverview, WarningMessage } from '../EmptyOverview';
const branch = mockMainBranch();
diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/OverviewApp-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/OverviewApp-test.tsx
index f032121332f..d14b6420dd1 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/OverviewApp-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/OverviewApp-test.tsx
@@ -22,13 +22,8 @@ import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { getMeasuresAndMeta } from '../../../../api/measures';
import { getAllTimeMachineData } from '../../../../api/time-machine';
-import {
- mockComponent,
- mockLongLivingBranch,
- mockMainBranch,
- mockMeasure,
- mockMetric
-} from '../../../../helpers/testMocks';
+import { mockBranch, mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockMeasure, mockMetric } from '../../../../helpers/testMocks';
import { OverviewApp } from '../OverviewApp';
jest.mock('../../../../api/measures', () => {
@@ -111,7 +106,7 @@ it('should show the correct message if the project is empty', async () => {
await waitAndUpdate(wrapper);
expect(wrapper.find('h3').text()).toBe('overview.project.main_branch_empty');
- wrapper.setProps({ branchLike: mockLongLivingBranch({ name: 'branch-foo' }) });
+ wrapper.setProps({ branchLike: mockBranch({ name: 'branch-foo' }) });
await waitAndUpdate(wrapper);
expect(wrapper.find('h3').text()).toBe('overview.project.branch_X_empty.branch-foo');
@@ -133,7 +128,7 @@ it('should show the correct message if the project has no lines of code', async
await waitAndUpdate(wrapper);
expect(wrapper.find('h3').text()).toBe('overview.project.main_branch_no_lines_of_code');
- wrapper.setProps({ branchLike: mockLongLivingBranch({ name: 'branch-foo' }) });
+ wrapper.setProps({ branchLike: mockBranch({ name: 'branch-foo' }) });
await waitAndUpdate(wrapper);
expect(wrapper.find('h3').text()).toBe('overview.project.branch_X_no_lines_of_code.branch-foo');
diff --git a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx
index 92043634f54..1dbcda4b30b 100644
--- a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx
@@ -22,12 +22,13 @@ import { Link } from 'react-router';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { getProjectActivity } from '../../../api/projectActivity';
import PreviewGraph from '../../../components/preview-graph/PreviewGraph';
-import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches';
+import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like';
import { getActivityUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import Analysis from './Analysis';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.Component;
history?: {
[metric: string]: Array<{ date: Date; value?: string }>;
diff --git a/server/sonar-web/src/main/js/apps/overview/events/__tests__/AnalysesList-test.tsx b/server/sonar-web/src/main/js/apps/overview/events/__tests__/AnalysesList-test.tsx
index d2ebc93333a..4db84389579 100644
--- a/server/sonar-web/src/main/js/apps/overview/events/__tests__/AnalysesList-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/events/__tests__/AnalysesList-test.tsx
@@ -19,11 +19,11 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockMainBranch } from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
import AnalysesList from '../AnalysesList';
it('should render show more link', () => {
- const branchLike: T.MainBranch = mockMainBranch();
+ const branchLike = mockMainBranch();
const component = {
breadcrumbs: [{ key: 'foo', name: 'foo', qualifier: 'TRK' }],
key: 'foo',
diff --git a/server/sonar-web/src/main/js/apps/overview/main/Bugs.tsx b/server/sonar-web/src/main/js/apps/overview/main/Bugs.tsx
index 06712825131..5b0cd5ccc7e 100644
--- a/server/sonar-web/src/main/js/apps/overview/main/Bugs.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/main/Bugs.tsx
@@ -22,7 +22,7 @@ import BugIcon from 'sonar-ui-common/components/icons/BugIcon';
import { translateWithParameters } from 'sonar-ui-common/helpers/l10n';
import DocTooltip from '../../../components/docs/DocTooltip';
import DateFromNow from '../../../components/intl/DateFromNow';
-import { isLongLivingBranch } from '../../../helpers/branches';
+import { isBranch, isMainBranch } from '../../../helpers/branch-like';
import ApplicationLeakPeriodLegend from '../components/ApplicationLeakPeriodLegend';
import LeakPeriodLegend from '../components/LeakPeriodLegend';
import { getMetricName } from '../utils';
@@ -62,7 +62,7 @@ export class Bugs extends React.PureComponent<ComposedProps> {
<div className="overview-domain-leak">
{component.qualifier === 'APP' ? (
<ApplicationLeakPeriodLegend
- branch={isLongLivingBranch(branchLike) ? branchLike : undefined}
+ branch={isBranch(branchLike) && !isMainBranch(branchLike) ? branchLike : undefined}
component={component}
/>
) : (
diff --git a/server/sonar-web/src/main/js/apps/overview/main/__tests__/Bugs-test.tsx b/server/sonar-web/src/main/js/apps/overview/main/__tests__/Bugs-test.tsx
index e784fa3c9e8..42742bfbf16 100644
--- a/server/sonar-web/src/main/js/apps/overview/main/__tests__/Bugs-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/main/__tests__/Bugs-test.tsx
@@ -19,12 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import {
- mockComponent,
- mockMainBranch,
- mockMeasureEnhanced,
- mockMetric
-} from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockMeasureEnhanced, mockMetric } from '../../../../helpers/testMocks';
import Bugs from '../Bugs';
import { ComposedProps } from '../enhance';
diff --git a/server/sonar-web/src/main/js/apps/overview/main/__tests__/CodeSmells-test.tsx b/server/sonar-web/src/main/js/apps/overview/main/__tests__/CodeSmells-test.tsx
index fedf6e0aed6..b7f041d43bd 100644
--- a/server/sonar-web/src/main/js/apps/overview/main/__tests__/CodeSmells-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/main/__tests__/CodeSmells-test.tsx
@@ -19,12 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import {
- mockComponent,
- mockMainBranch,
- mockMeasureEnhanced,
- mockMetric
-} from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockMeasureEnhanced, mockMetric } from '../../../../helpers/testMocks';
import CodeSmells from '../CodeSmells';
import { ComposedProps } from '../enhance';
diff --git a/server/sonar-web/src/main/js/apps/overview/main/__tests__/Coverage-test.tsx b/server/sonar-web/src/main/js/apps/overview/main/__tests__/Coverage-test.tsx
index bcf72336499..1c5454a4553 100644
--- a/server/sonar-web/src/main/js/apps/overview/main/__tests__/Coverage-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/main/__tests__/Coverage-test.tsx
@@ -19,12 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import {
- mockComponent,
- mockMainBranch,
- mockMeasureEnhanced,
- mockMetric
-} from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockMeasureEnhanced, mockMetric } from '../../../../helpers/testMocks';
import Coverage from '../Coverage';
import { ComposedProps } from '../enhance';
diff --git a/server/sonar-web/src/main/js/apps/overview/main/__tests__/Duplications-test.tsx b/server/sonar-web/src/main/js/apps/overview/main/__tests__/Duplications-test.tsx
index 3d61e5f980a..77afbc283da 100644
--- a/server/sonar-web/src/main/js/apps/overview/main/__tests__/Duplications-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/main/__tests__/Duplications-test.tsx
@@ -19,12 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import {
- mockComponent,
- mockMainBranch,
- mockMeasureEnhanced,
- mockMetric
-} from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockMeasureEnhanced, mockMetric } from '../../../../helpers/testMocks';
import Duplications from '../Duplications';
import { ComposedProps } from '../enhance';
diff --git a/server/sonar-web/src/main/js/apps/overview/main/__tests__/VulnerabilitiesAndHotspots-test.tsx b/server/sonar-web/src/main/js/apps/overview/main/__tests__/VulnerabilitiesAndHotspots-test.tsx
index 13f0d69b10f..9514709d12f 100644
--- a/server/sonar-web/src/main/js/apps/overview/main/__tests__/VulnerabilitiesAndHotspots-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/main/__tests__/VulnerabilitiesAndHotspots-test.tsx
@@ -19,12 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import {
- mockComponent,
- mockMainBranch,
- mockMeasureEnhanced,
- mockMetric
-} from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockMeasureEnhanced, mockMetric } from '../../../../helpers/testMocks';
import { ComposedProps } from '../enhance';
import VulnerabilitiesAndHotspots from '../VulnerabilitiesAndHotspots';
diff --git a/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx b/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx
index 98cf4b50eca..7e9f3ccd525 100644
--- a/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx
@@ -26,7 +26,7 @@ import { getLocalizedMetricName, translate } from 'sonar-ui-common/helpers/l10n'
import { formatMeasure } from 'sonar-ui-common/helpers/measures';
import { getWrappedDisplayName } from '../../../components/hoc/utils';
import DrilldownLink from '../../../components/shared/DrilldownLink';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
import {
getPeriodValue,
getRatingTooltip,
@@ -39,10 +39,11 @@ import {
getComponentIssuesUrl,
getMeasureHistoryUrl
} from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import Timeline from '../components/Timeline';
export interface EnhanceProps {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.Component;
measures: T.MeasureEnhanced[];
leakPeriod?: T.Period;
diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx
index c35ad5bec9a..90f2a829649 100644
--- a/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx
@@ -31,6 +31,7 @@ import {
getOrganizationByKey,
Store
} from '../../../store/rootReducer';
+import { BranchLike } from '../../../types/branch-like';
import AnalysesList from '../events/AnalysesList';
import MetaKey from './MetaKey';
import MetaLinks from './MetaLinks';
@@ -54,7 +55,7 @@ interface StateToProps {
}
interface OwnProps {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.Component;
history?: {
[metric: string]: Array<{ date: Date; value?: string }>;
diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaSize.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaSize.tsx
index 1ef8689626f..b291574823e 100644
--- a/server/sonar-web/src/main/js/apps/overview/meta/MetaSize.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaSize.tsx
@@ -24,10 +24,11 @@ import { translate } from 'sonar-ui-common/helpers/l10n';
import { formatMeasure } from 'sonar-ui-common/helpers/measures';
import LanguageDistributionContainer from '../../../components/charts/LanguageDistributionContainer';
import DrilldownLink from '../../../components/shared/DrilldownLink';
+import { BranchLike } from '../../../types/branch-like';
import { getMetricName } from '../utils';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.LightComponent;
measures: T.MeasureEnhanced[];
}
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueLabel.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueLabel.tsx
index b7fa8f83677..e1f384ff9df 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueLabel.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueLabel.tsx
@@ -23,13 +23,14 @@ import { Link } from 'react-router';
import { formatMeasure } from 'sonar-ui-common/helpers/measures';
import DocTooltip from '../../../components/docs/DocTooltip';
import { getLeakValue } from '../../../components/measure/utils';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
import { findMeasure } from '../../../helpers/measures';
import { getComponentIssuesUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import { getMetricName, IssueType, ISSUETYPE_MAP } from '../utils';
export interface Props {
- branchLike?: T.ShortLivingBranch | T.PullRequest;
+ branchLike?: BranchLike;
className?: string;
component: T.Component;
docTooltip?: Promise<{ default: string }>;
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueRating.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueRating.tsx
index 508fd803f8e..78d18978e96 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueRating.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/IssueRating.tsx
@@ -23,10 +23,11 @@ import Rating from 'sonar-ui-common/components/ui/Rating';
import { getLeakValue, getRatingTooltip } from '../../../components/measure/utils';
import DrilldownLink from '../../../components/shared/DrilldownLink';
import { findMeasure } from '../../../helpers/measures';
+import { BranchLike } from '../../../types/branch-like';
import { getRatingName, IssueType, ISSUETYPE_MAP } from '../utils';
interface Props {
- branchLike?: T.ShortLivingBranch | T.PullRequest;
+ branchLike?: BranchLike;
component: T.Component;
measures: T.Measure[];
type: IssueType;
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/MeasurementLabel.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/MeasurementLabel.tsx
index 45a6e7698fd..70d4670aafe 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/MeasurementLabel.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/MeasurementLabel.tsx
@@ -25,10 +25,11 @@ import { formatMeasure } from 'sonar-ui-common/helpers/measures';
import { getLeakValue } from '../../../components/measure/utils';
import DrilldownLink from '../../../components/shared/DrilldownLink';
import { findMeasure } from '../../../helpers/measures';
+import { BranchLike } from '../../../types/branch-like';
import { MEASUREMENTS_MAP, MeasurementType } from '../utils';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
className?: string;
component: T.Component;
measures: T.Measure[];
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/ReviewApp.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/ReviewApp.tsx
index db6a3680f9b..c84f09aa15e 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/ReviewApp.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/ReviewApp.tsx
@@ -25,9 +25,10 @@ import { Alert } from 'sonar-ui-common/components/ui/Alert';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { getMeasures } from '../../../api/measures';
import DocTooltip from '../../../components/docs/DocTooltip';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
import { fetchBranchStatus } from '../../../store/rootActions';
import { getBranchStatusByBranchLike, Store } from '../../../store/rootReducer';
+import { BranchLike } from '../../../types/branch-like';
import QualityGateConditions from '../qualityGate/QualityGateConditions';
import '../styles.css';
import { IssueType, MeasurementType, PR_METRICS } from '../utils';
@@ -38,7 +39,7 @@ import LargeQualityGateBadge from './LargeQualityGateBadge';
import MeasurementLabel from './MeasurementLabel';
interface OwnProps {
- branchLike: T.PullRequest | T.ShortLivingBranch;
+ branchLike: BranchLike;
component: T.Component;
}
@@ -49,7 +50,7 @@ interface StateProps {
}
interface DispatchProps {
- fetchBranchStatus: (branchLike: T.BranchLike, projectKey: string) => Promise<void>;
+ fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>;
}
type Props = OwnProps & StateProps & DispatchProps;
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/IssueLabel-test.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/IssueLabel-test.tsx
index eda38e87bdc..96f2757a37d 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/IssueLabel-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/IssueLabel-test.tsx
@@ -19,7 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockComponent, mockMeasure, mockPullRequest } from '../../../../helpers/testMocks';
+import { mockPullRequest } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockMeasure } from '../../../../helpers/testMocks';
import IssueLabel, { Props } from '../IssueLabel';
it('should render correctly for bugs', () => {
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/IssueRating-test.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/IssueRating-test.tsx
index 0c35519a79b..794269988dd 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/IssueRating-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/IssueRating-test.tsx
@@ -19,7 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockComponent, mockMeasure, mockPullRequest } from '../../../../helpers/testMocks';
+import { mockPullRequest } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockMeasure } from '../../../../helpers/testMocks';
import IssueRating from '../IssueRating';
it('should render correctly for bugs', () => {
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/MeasurementLabel-test.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/MeasurementLabel-test.tsx
index 6e251163662..20d241b1a68 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/MeasurementLabel-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/MeasurementLabel-test.tsx
@@ -19,7 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockComponent, mockMeasure, mockShortLivingBranch } from '../../../../helpers/testMocks';
+import { mockBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockMeasure } from '../../../../helpers/testMocks';
import MeasurementLabel from '../MeasurementLabel';
it('should render correctly for coverage', () => {
@@ -50,7 +51,7 @@ it('should render correctly with no value', () => {
function shallowRender(props: Partial<MeasurementLabel['props']> = {}) {
return shallow(
<MeasurementLabel
- branchLike={mockShortLivingBranch()}
+ branchLike={mockBranch()}
component={mockComponent()}
measures={[mockMeasure({ metric: 'new_coverage' })]}
type="COVERAGE"
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/ReviewApp-test.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/ReviewApp-test.tsx
index a2c81894995..62ffcd9b64a 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/ReviewApp-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/ReviewApp-test.tsx
@@ -21,11 +21,8 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { getMeasures } from '../../../../api/measures';
-import {
- mockComponent,
- mockPullRequest,
- mockQualityGateStatusCondition
-} from '../../../../helpers/testMocks';
+import { mockPullRequest } from '../../../../helpers/mocks/branch-like';
+import { mockComponent, mockQualityGateStatusCondition } from '../../../../helpers/testMocks';
import { ReviewApp } from '../ReviewApp';
jest.mock('../../../../api/measures', () => {
diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/__snapshots__/MeasurementLabel-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/__snapshots__/MeasurementLabel-test.tsx.snap
index c43c7b55818..6c1396c176d 100644
--- a/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/__snapshots__/MeasurementLabel-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/__tests__/__snapshots__/MeasurementLabel-test.tsx.snap
@@ -16,9 +16,7 @@ exports[`should render correctly for coverage 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "feature/foo",
- "type": "SHORT",
+ "name": "branch-6.7",
}
}
component="my-project"
@@ -50,9 +48,7 @@ exports[`should render correctly for coverage 2`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "feature/foo",
- "type": "SHORT",
+ "name": "branch-6.7",
}
}
component="my-project"
@@ -74,9 +70,7 @@ exports[`should render correctly for coverage 2`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "feature/foo",
- "type": "SHORT",
+ "name": "branch-6.7",
}
}
component="my-project"
@@ -107,9 +101,7 @@ exports[`should render correctly for duplications 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "feature/foo",
- "type": "SHORT",
+ "name": "branch-6.7",
}
}
component="my-project"
diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx
index 98ffeb8798b..7293f91b062 100644
--- a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx
@@ -24,10 +24,11 @@ import Level from 'sonar-ui-common/components/ui/Level';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { ApplicationProject, getApplicationQualityGate } from '../../../api/quality-gates';
import DocTooltip from '../../../components/docs/DocTooltip';
+import { Branch } from '../../../types/branch-like';
import ApplicationQualityGateProject from './ApplicationQualityGateProject';
interface Props {
- branch?: T.LongLivingBranch;
+ branch?: Branch;
component: T.LightComponent;
}
diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx
index eb5b9d1911c..bfc0d0b2e02 100644
--- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx
@@ -23,11 +23,12 @@ import { Alert } from 'sonar-ui-common/components/ui/Alert';
import Level from 'sonar-ui-common/components/ui/Level';
import { translate } from 'sonar-ui-common/helpers/l10n';
import DocTooltip from '../../../components/docs/DocTooltip';
+import { BranchLike } from '../../../types/branch-like';
import EmptyQualityGate from './EmptyQualityGate';
import QualityGateConditions from './QualityGateConditions';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: Pick<T.Component, 'key' | 'qualifier'>;
measures: T.MeasureEnhanced[];
}
diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx
index cdad14829fb..c76b7fcca1e 100644
--- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx
@@ -28,12 +28,13 @@ import {
} from 'sonar-ui-common/helpers/measures';
import Measure from '../../../components/measure/Measure';
import DrilldownLink from '../../../components/shared/DrilldownLink';
-import { getBranchLikeQuery, isPullRequest, isShortLivingBranch } from '../../../helpers/branches';
+import { getBranchLikeQuery, isPullRequest } from '../../../helpers/branch-like';
import { getPeriodValue, isDiffMetric } from '../../../helpers/measures';
import { getComponentIssuesUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: Pick<T.Component, 'key'>;
condition: T.QualityGateStatusConditionEnhanced;
}
@@ -86,7 +87,7 @@ export default class QualityGateCondition extends React.PureComponent<Props> {
'overview-quality-gate-condition-' + condition.level.toLowerCase(),
{
'overview-quality-gate-condition-leak':
- condition.period != null && !isPullRequest(branchLike) && !isShortLivingBranch(branchLike)
+ condition.period != null && !isPullRequest(branchLike)
}
);
diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx
index ef6395132de..f6d2fc78a73 100644
--- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx
@@ -23,14 +23,15 @@ import { ButtonLink } from 'sonar-ui-common/components/controls/buttons';
import ChevronDownIcon from 'sonar-ui-common/components/icons/ChevronDownIcon';
import { translateWithParameters } from 'sonar-ui-common/helpers/l10n';
import { getMeasuresAndMeta } from '../../../api/measures';
-import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches';
+import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like';
import { enhanceMeasuresWithMetrics } from '../../../helpers/measures';
+import { BranchLike } from '../../../types/branch-like';
import QualityGateCondition from './QualityGateCondition';
const LEVEL_ORDER = ['ERROR', 'WARN'];
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: Pick<T.Component, 'key'>;
collapsible?: boolean;
conditions: T.QualityGateStatusCondition[];
diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.tsx
index df7be90d0f0..c5da438f7a7 100644
--- a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.tsx
@@ -19,7 +19,7 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockLongLivingBranch } from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
import QualityGateCondition from '../QualityGateCondition';
const mockRatingCondition = (metric: string): T.QualityGateStatusConditionEnhanced => ({
@@ -137,7 +137,7 @@ it('should work with branch', () => {
expect(
shallow(
<QualityGateCondition
- branchLike={mockLongLivingBranch()}
+ branchLike={mockMainBranch()}
component={{ key: 'abcd-key' }}
condition={condition}
/>
diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGateCondition-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGateCondition-test.tsx.snap
index 8d3510f4397..e94361e063d 100644
--- a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGateCondition-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGateCondition-test.tsx.snap
@@ -348,7 +348,6 @@ exports[`should work with branch 1`] = `
Object {
"pathname": "/project/issues",
"query": Object {
- "branch": "branch-6.7",
"id": "abcd-key",
"resolved": "false",
"sinceLeakPeriod": "true",
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx
index 5583a4e55fb..abae92b45b1 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx
@@ -22,13 +22,14 @@ import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router';
import { ResetButtonLink } from 'sonar-ui-common/components/controls/buttons';
+import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon';
import DropdownIcon from 'sonar-ui-common/components/icons/DropdownIcon';
-import LongLivingBranchIcon from 'sonar-ui-common/components/icons/LongLivingBranchIcon';
import ProjectEventIcon from 'sonar-ui-common/components/icons/ProjectEventIcon';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { limitComponentName } from 'sonar-ui-common/helpers/path';
-import { isMainBranch } from '../../../helpers/branches';
+import { isMainBranch } from '../../../helpers/branch-like';
import { getProjectUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
export type DefinitionChangeEvent = T.AnalysisEvent &
Required<Pick<T.AnalysisEvent, 'definitionChange'>>;
@@ -38,7 +39,7 @@ export function isDefinitionChangeEvent(event: T.AnalysisEvent): event is Defini
}
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
event: DefinitionChangeEvent;
}
@@ -68,7 +69,7 @@ export class DefinitionChangeEventInner extends React.PureComponent<Props, State
renderBranch = (branch = translate('branches.main_branch')) => (
<span className="nowrap" title={branch}>
- <LongLivingBranchIcon className="little-spacer-left text-text-top" />
+ <BranchIcon className="little-spacer-left text-text-top" />
{branch}
</span>
);
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx
index ce0e6a6196a..f3323e9ed5f 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx
@@ -24,7 +24,8 @@ import { parseDate } from 'sonar-ui-common/helpers/dates';
import { getAllMetrics } from '../../../api/metrics';
import * as api from '../../../api/projectActivity';
import { getAllTimeMachineData } from '../../../api/time-machine';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
import * as actions from '../actions';
import {
customMetricsChanged,
@@ -41,7 +42,7 @@ import {
import ProjectActivityApp from './ProjectActivityApp';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
component: T.Component;
location: Location;
router: Pick<InjectedRouter, 'push' | 'replace'>;
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx
index 78a466328e9..c38e028e5a5 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx
@@ -20,6 +20,7 @@
import { shallow } from 'enzyme';
import * as React from 'react';
import { click } from 'sonar-ui-common/helpers/testUtils';
+import { mockBranch } from '../../../../helpers/mocks/branch-like';
import { DefinitionChangeEvent, DefinitionChangeEventInner } from '../DefinitionChangeEventInner';
it('should render', () => {
@@ -43,12 +44,7 @@ it('should render', () => {
});
it('should render for a branch', () => {
- const branch: T.LongLivingBranch = {
- excludedFromPurge: true,
- name: 'feature-x',
- isMain: false,
- type: 'LONG'
- };
+ const branch = mockBranch({ name: 'feature-x' });
const event: DefinitionChangeEvent = {
category: 'DEFINITION_CHANGE',
key: 'foo1234',
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/DefinitionChangeEventInner-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/DefinitionChangeEventInner-test.tsx.snap
index 7ccfa49ae0f..04895e1a18a 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/DefinitionChangeEventInner-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/DefinitionChangeEventInner-test.tsx.snap
@@ -84,7 +84,7 @@ exports[`should render 2`] = `
className="nowrap"
title="master"
>
- <LongLivingBranchIcon
+ <BranchIcon
className="little-spacer-left text-text-top"
/>
master
@@ -127,7 +127,7 @@ exports[`should render 2`] = `
className="nowrap"
title="master"
>
- <LongLivingBranchIcon
+ <BranchIcon
className="little-spacer-left text-text-top"
/>
master
@@ -208,7 +208,7 @@ exports[`should render for a branch 1`] = `
className="nowrap"
title="feature-x"
>
- <LongLivingBranchIcon
+ <BranchIcon
className="little-spacer-left text-text-top"
/>
feature-x
@@ -248,7 +248,7 @@ exports[`should render for a branch 1`] = `
className="nowrap"
title="feature-y"
>
- <LongLivingBranchIcon
+ <BranchIcon
className="little-spacer-left text-text-top"
/>
feature-y
@@ -257,7 +257,7 @@ exports[`should render for a branch 1`] = `
className="nowrap"
title="master"
>
- <LongLivingBranchIcon
+ <BranchIcon
className="little-spacer-left text-text-top"
/>
master
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchBaselineSettingModal-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchBaselineSettingModal-test.tsx
index abe14e18235..cbae7bcc0a5 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchBaselineSettingModal-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchBaselineSettingModal-test.tsx
@@ -21,7 +21,7 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { mockEvent, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { setNewCodePeriod } from '../../../api/newCodePeriod';
-import { mockMainBranch } from '../../../helpers/testMocks';
+import { mockMainBranch } from '../../../helpers/mocks/branch-like';
import BranchBaselineSettingModal from '../components/BranchBaselineSettingModal';
jest.mock('../../../api/newCodePeriod', () => ({
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchList-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchList-test.tsx
index 3720e80afa3..9bf67e0519e 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchList-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchList-test.tsx
@@ -21,13 +21,8 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { listBranchesNewCodePeriod, resetNewCodePeriod } from '../../../api/newCodePeriod';
-import {
- mockComponent,
- mockLongLivingBranch,
- mockMainBranch,
- mockPullRequest,
- mockShortLivingBranch
-} from '../../../helpers/testMocks';
+import { mockBranch, mockMainBranch, mockPullRequest } from '../../../helpers/mocks/branch-like';
+import { mockComponent } from '../../../helpers/testMocks';
import BranchBaselineSettingModal from '../components/BranchBaselineSettingModal';
import BranchList from '../components/BranchList';
@@ -50,8 +45,8 @@ it('should render correctly', async () => {
const wrapper = shallowRender({
branchLikes: [
mockMainBranch(),
- mockLongLivingBranch(),
- mockShortLivingBranch(),
+ mockBranch(),
+ mockBranch({ name: 'branch-7.0' }),
mockPullRequest()
]
});
@@ -73,7 +68,7 @@ it('should handle reset', () => {
});
it('should toggle popup', async () => {
- const wrapper = shallowRender({ branchLikes: [mockMainBranch(), mockLongLivingBranch()] });
+ const wrapper = shallowRender({ branchLikes: [mockMainBranch(), mockBranch()] });
wrapper.setState({ editedBranch: mockMainBranch() });
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BranchList-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BranchList-test.tsx.snap
index aad80809688..5c2965d1178 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BranchList-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BranchList-test.tsx.snap
@@ -87,7 +87,6 @@ exports[`should render correctly 1`] = `
"excludedFromPurge": true,
"isMain": false,
"name": "branch-6.7",
- "type": "LONG",
}
}
className="little-spacer-right"
@@ -112,7 +111,7 @@ exports[`should render correctly 1`] = `
</td>
</tr>
<tr
- key="feature/foo"
+ key="branch-7.0"
>
<td
className="nowrap"
@@ -123,14 +122,12 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "feature/foo",
- "type": "SHORT",
+ "name": "branch-7.0",
}
}
className="little-spacer-right"
/>
- feature/foo
+ branch-7.0
</td>
<td
className="huge-spacer-right nowrap"
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx
index f13013635a7..8d676f1d4de 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx
@@ -24,13 +24,14 @@ import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { getNewCodePeriod, resetNewCodePeriod, setNewCodePeriod } from '../../../api/newCodePeriod';
import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
+import { BranchLike } from '../../../types/branch-like';
import '../styles.css';
import { getSettingValue } from '../utils';
import BranchList from './BranchList';
import ProjectBaselineSelector from './ProjectBaselineSelector';
interface Props {
- branchLikes: T.BranchLike[];
+ branchLikes: BranchLike[];
branchesEnabled?: boolean;
canAdmin?: boolean;
component: T.Component;
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchBaselineSettingModal.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchBaselineSettingModal.tsx
index 0a180907f92..97239756a53 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchBaselineSettingModal.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchBaselineSettingModal.tsx
@@ -24,6 +24,7 @@ import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner';
import { toNotSoISOString } from 'sonar-ui-common/helpers/dates';
import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n';
import { setNewCodePeriod } from '../../../api/newCodePeriod';
+import { BranchWithNewCodePeriod } from '../../../types/branch-like';
import { getSettingValue, validateSetting } from '../utils';
import BaselineSettingAnalysis from './BaselineSettingAnalysis';
import BaselineSettingDays from './BaselineSettingDays';
@@ -31,7 +32,7 @@ import BaselineSettingPreviousVersion from './BaselineSettingPreviousVersion';
import BranchAnalysisList from './BranchAnalysisList';
interface Props {
- branch: T.BranchWithNewCodePeriod;
+ branch: BranchWithNewCodePeriod;
component: string;
onClose: (branch?: string, newSetting?: T.NewCodePeriod) => void;
}
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchList.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchList.tsx
index 94cdebad8f7..189feed9848 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchList.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchList.tsx
@@ -26,18 +26,19 @@ import { translate } from 'sonar-ui-common/helpers/l10n';
import { listBranchesNewCodePeriod, resetNewCodePeriod } from '../../../api/newCodePeriod';
import BranchLikeIcon from '../../../components/icons/BranchLikeIcon';
import DateTimeFormatter from '../../../components/intl/DateTimeFormatter';
-import { isBranch, sortBranches } from '../../../helpers/branches';
+import { isBranch, sortBranches } from '../../../helpers/branch-like';
+import { BranchLike, BranchWithNewCodePeriod } from '../../../types/branch-like';
import BranchBaselineSettingModal from './BranchBaselineSettingModal';
interface Props {
- branchLikes: T.BranchLike[];
+ branchLikes: BranchLike[];
component: T.Component;
inheritedSetting: T.NewCodePeriod;
}
interface State {
- branches: T.BranchWithNewCodePeriod[];
- editedBranch?: T.BranchWithNewCodePeriod;
+ branches: BranchWithNewCodePeriod[];
+ editedBranch?: BranchWithNewCodePeriod;
loading: boolean;
}
@@ -57,7 +58,7 @@ export default class BranchList extends React.PureComponent<Props, State> {
this.mounted = false;
}
- sortAndFilterBranches(branchLikes: T.BranchLike[] = []) {
+ sortAndFilterBranches(branchLikes: BranchLike[] = []) {
return sortBranches(branchLikes.filter(isBranch));
}
@@ -103,7 +104,7 @@ export default class BranchList extends React.PureComponent<Props, State> {
return branches.slice(0);
};
- openEditModal = (branch: T.BranchWithNewCodePeriod) => {
+ openEditModal = (branch: BranchWithNewCodePeriod) => {
this.setState({ editedBranch: branch });
};
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx
index 770f58d818a..768916e34b4 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx
@@ -19,11 +19,12 @@
*/
import * as React from 'react';
import { translate } from 'sonar-ui-common/helpers/l10n';
+import { BranchLike } from '../../../types/branch-like';
import BranchLikeTabs from './BranchLikeTabs';
import LifetimeInformation from './LifetimeInformation';
export interface AppProps {
- branchLikes: T.BranchLike[];
+ branchLikes: BranchLike[];
component: T.Component;
onBranchesChange: () => void;
}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx
index 071cda5c964..c1b90f73115 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx
@@ -31,11 +31,12 @@ import {
isBranch,
isMainBranch,
isPullRequest
-} from '../../../helpers/branches';
+} from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
import BranchPurgeSetting from './BranchPurgeSetting';
export interface BranchLikeRowProps {
- branchLike: T.BranchLike;
+ branchLike: BranchLike;
component: T.Component;
displayPurgeSetting?: boolean;
onDelete: () => void;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx
index d4b90ed5fdb..9d1bb43cd33 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx
@@ -21,15 +21,16 @@
import * as React from 'react';
import HelpTooltip from 'sonar-ui-common/components/controls/HelpTooltip';
import { translate } from 'sonar-ui-common/helpers/l10n';
-import { getBranchLikeKey } from '../../../helpers/branches';
+import { getBranchLikeKey } from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
import BranchLikeRow from './BranchLikeRow';
export interface BranchLikeTableProps {
- branchLikes: T.BranchLike[];
+ branchLikes: BranchLike[];
component: T.Component;
displayPurgeSetting?: boolean;
- onDelete: (branchLike: T.BranchLike) => void;
- onRename: (branchLike: T.BranchLike) => void;
+ onDelete: (branchLike: BranchLike) => void;
+ onRename: (branchLike: BranchLike) => void;
title: string;
}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx
index 6e05bcbfcad..785cf78b58b 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx
@@ -20,8 +20,8 @@
import * as React from 'react';
import BoxedTabs from 'sonar-ui-common/components/controls/BoxedTabs';
+import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon';
import PullRequestIcon from 'sonar-ui-common/components/icons/PullRequestIcon';
-import ShortLivingBranchIcon from 'sonar-ui-common/components/icons/ShortLivingBranchIcon';
import { translate } from 'sonar-ui-common/helpers/l10n';
import {
isBranch,
@@ -29,21 +29,22 @@ import {
isPullRequest,
sortBranches,
sortPullRequests
-} from '../../../helpers/branches';
+} from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
import BranchLikeTable from './BranchLikeTable';
import DeleteBranchModal from './DeleteBranchModal';
import RenameBranchModal from './RenameBranchModal';
interface Props {
- branchLikes: T.BranchLike[];
+ branchLikes: BranchLike[];
component: T.Component;
onBranchesChange: () => void;
}
interface State {
currentTab: Tabs;
- deleting?: T.BranchLike;
- renaming?: T.BranchLike;
+ deleting?: BranchLike;
+ renaming?: BranchLike;
}
export enum Tabs {
@@ -56,7 +57,7 @@ const TABS = [
key: Tabs.Branch,
label: (
<>
- <ShortLivingBranchIcon />
+ <BranchIcon />
<span className="spacer-left">
{translate('project_branch_pull_request.tabs.branches')}
</span>
@@ -83,9 +84,9 @@ export default class BranchLikeTabs extends React.PureComponent<Props, State> {
this.setState({ currentTab });
};
- onDeleteBranchLike = (branchLike: T.BranchLike) => this.setState({ deleting: branchLike });
+ onDeleteBranchLike = (branchLike: BranchLike) => this.setState({ deleting: branchLike });
- onRenameBranchLike = (branchLike: T.BranchLike) => this.setState({ renaming: branchLike });
+ onRenameBranchLike = (branchLike: BranchLike) => this.setState({ renaming: branchLike });
onClose = () => this.setState({ deleting: undefined, renaming: undefined });
@@ -99,7 +100,7 @@ export default class BranchLikeTabs extends React.PureComponent<Props, State> {
const { currentTab, deleting, renaming } = this.state;
const isBranchMode = currentTab === Tabs.Branch;
- const branchLikesToDisplay: T.BranchLike[] = isBranchMode
+ const branchLikesToDisplay: BranchLike[] = isBranchMode
? sortBranches(branchLikes.filter(isBranch))
: sortPullRequests(branchLikes.filter(isPullRequest));
const title = translate(
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx
index dfe91f278ce..896521f600b 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx
@@ -24,10 +24,11 @@ import Toggle from 'sonar-ui-common/components/controls/Toggle';
import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { excludeBranchFromPurge } from '../../../api/branches';
-import { isMainBranch } from '../../../helpers/branches';
+import { isMainBranch } from '../../../helpers/branch-like';
+import { Branch } from '../../../types/branch-like';
interface Props {
- branch: T.Branch;
+ branch: Branch;
component: T.Component;
}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx
index a89bc85e157..b051fc67cc9 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx
@@ -22,10 +22,11 @@ import { ResetButtonLink, SubmitButton } from 'sonar-ui-common/components/contro
import Modal from 'sonar-ui-common/components/controls/Modal';
import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n';
import { deleteBranch, deletePullRequest } from '../../../api/branches';
-import { getBranchLikeDisplayName, isPullRequest } from '../../../helpers/branches';
+import { getBranchLikeDisplayName, isPullRequest } from '../../../helpers/branch-like';
+import { BranchLike } from '../../../types/branch-like';
interface Props {
- branchLike: T.BranchLike;
+ branchLike: BranchLike;
component: T.Component;
onClose: () => void;
onDelete: () => void;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx
index 6ec14c34324..125061368b4 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx
@@ -22,9 +22,10 @@ import { ResetButtonLink, SubmitButton } from 'sonar-ui-common/components/contro
import Modal from 'sonar-ui-common/components/controls/Modal';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { renameBranch } from '../../../api/branches';
+import { MainBranch } from '../../../types/branch-like';
interface Props {
- branch: T.MainBranch;
+ branch: MainBranch;
component: T.Component;
onClose: () => void;
onRename: () => void;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx
index 27e23b77806..7f25329c492 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx
@@ -20,7 +20,7 @@
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockSetOfBranchAndPullRequest } from '../../../../helpers/mocks/branch-pull-request';
+import { mockSetOfBranchAndPullRequest } from '../../../../helpers/mocks/branch-like';
import { mockComponent } from '../../../../helpers/testMocks';
import { App, AppProps } from '../App';
import BranchLikeTabs from '../BranchLikeTabs';
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx
index 0c162b9d435..80b8658ea39 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx
@@ -20,13 +20,8 @@
import { shallow } from 'enzyme';
import * as React from 'react';
-import {
- mockComponent,
- mockLongLivingBranch,
- mockMainBranch,
- mockPullRequest,
- mockShortLivingBranch
-} from '../../../../helpers/testMocks';
+import { mockBranch, mockMainBranch, mockPullRequest } from '../../../../helpers/mocks/branch-like';
+import { mockComponent } from '../../../../helpers/testMocks';
import { BranchLikeRow, BranchLikeRowProps } from '../BranchLikeRow';
it('should render correctly for pull request', () => {
@@ -34,13 +29,8 @@ it('should render correctly for pull request', () => {
expect(wrapper).toMatchSnapshot();
});
-it('should render correctly for short lived branch', () => {
- const wrapper = shallowRender({ branchLike: mockShortLivingBranch(), displayPurgeSetting: true });
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should render correctly for long lived branch', () => {
- const wrapper = shallowRender({ branchLike: mockLongLivingBranch(), displayPurgeSetting: true });
+it('should render correctly for branch', () => {
+ const wrapper = shallowRender({ branchLike: mockBranch(), displayPurgeSetting: true });
expect(wrapper).toMatchSnapshot();
});
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx
index 834c09db53e..acfc64cb99d 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx
@@ -20,7 +20,7 @@
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockSetOfBranchAndPullRequest } from '../../../../helpers/mocks/branch-pull-request';
+import { mockSetOfBranchAndPullRequest } from '../../../../helpers/mocks/branch-like';
import { mockComponent } from '../../../../helpers/testMocks';
import { BranchLikeRow } from '../BranchLikeRow';
import { BranchLikeTable, BranchLikeTableProps } from '../BranchLikeTable';
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTabs-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTabs-test.tsx
index 1fcf0a8ddbf..805017d88d0 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTabs-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTabs-test.tsx
@@ -21,8 +21,12 @@
import { shallow } from 'enzyme';
import * as React from 'react';
import BoxedTabs from 'sonar-ui-common/components/controls/BoxedTabs';
-import { mockSetOfBranchAndPullRequest } from '../../../../helpers/mocks/branch-pull-request';
-import { mockComponent, mockMainBranch, mockPullRequest } from '../../../../helpers/testMocks';
+import {
+ mockMainBranch,
+ mockPullRequest,
+ mockSetOfBranchAndPullRequest
+} from '../../../../helpers/mocks/branch-like';
+import { mockComponent } from '../../../../helpers/testMocks';
import { BranchLikeTable } from '../BranchLikeTable';
import BranchLikeTabs, { Tabs } from '../BranchLikeTabs';
import DeleteBranchModal from '../DeleteBranchModal';
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx
index bdac2023af4..882219f4275 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx
@@ -22,7 +22,8 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import Toggle from 'sonar-ui-common/components/controls/Toggle';
import { excludeBranchFromPurge } from '../../../../api/branches';
-import { mockComponent, mockLongLivingBranch, mockMainBranch } from '../../../../helpers/testMocks';
+import { mockBranch, mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponent } from '../../../../helpers/testMocks';
import BranchPurgeSetting from '../BranchPurgeSetting';
jest.mock('../../../../api/branches', () => ({
@@ -61,7 +62,7 @@ it('should correctly call the webservice if the user changes the value', () => {
function shallowRender(props?: Partial<BranchPurgeSetting['props']>) {
return shallow<BranchPurgeSetting>(
<BranchPurgeSetting
- branch={mockLongLivingBranch({ excludedFromPurge: true })}
+ branch={mockBranch({ excludedFromPurge: true })}
component={mockComponent()}
{...props}
/>
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx
index 198ed29d27e..9d297362864 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx
@@ -22,11 +22,9 @@ import { shallow, ShallowWrapper } from 'enzyme';
import * as React from 'react';
import { click, doAsync, submit, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { deleteBranch, deletePullRequest } from '../../../../api/branches';
-import {
- mockComponent,
- mockPullRequest,
- mockShortLivingBranch
-} from '../../../../helpers/testMocks';
+import { mockBranch, mockPullRequest } from '../../../../helpers/mocks/branch-like';
+import { mockComponent } from '../../../../helpers/testMocks';
+import { BranchLike } from '../../../../types/branch-like';
import DeleteBranchModal from '../DeleteBranchModal';
jest.mock('../../../../api/branches', () => ({
@@ -34,7 +32,7 @@ jest.mock('../../../../api/branches', () => ({
deletePullRequest: jest.fn()
}));
-const branch = mockShortLivingBranch();
+const branch = mockBranch({ name: 'feature/foo' });
beforeEach(() => {
jest.clearAllMocks();
@@ -99,7 +97,7 @@ it('stops loading on WS error', async () => {
});
function shallowRender(
- branchLike: T.BranchLike,
+ branchLike: BranchLike,
onDelete: () => void = jest.fn(),
onClose: () => void = jest.fn()
) {
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx
index 050ec427bb7..f78f10804cf 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx
@@ -22,7 +22,8 @@ import { shallow, ShallowWrapper } from 'enzyme';
import * as React from 'react';
import { change, click, doAsync, submit, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { renameBranch } from '../../../../api/branches';
-import { mockComponent, mockMainBranch } from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
+import { mockComponent } from '../../../../helpers/testMocks';
import RenameBranchModal from '../RenameBranchModal';
jest.mock('../../../../api/branches', () => ({ renameBranch: jest.fn() }));
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap
index f0cf79259bf..0e39878623b 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap
@@ -19,16 +19,13 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
},
Object {
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-1",
- "type": "LONG",
+ "name": "branch-1",
},
Object {
"analysisDate": "2018-01-01",
@@ -48,9 +45,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "llb-1",
- "name": "slb-2",
- "type": "SHORT",
+ "name": "branch-12",
},
Object {
"analysisDate": "2018-01-01",
@@ -64,15 +59,13 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-3",
- "type": "LONG",
+ "name": "branch-3",
},
Object {
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-2",
- "type": "LONG",
+ "name": "branch-2",
},
Object {
"analysisDate": "2018-01-01",
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap
index aa1b8391809..7406b9a94fa 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`should render correctly for long lived branch 1`] = `
+exports[`should render correctly for branch 1`] = `
<tr>
<td
className="nowrap hide-overflow"
@@ -12,7 +12,6 @@ exports[`should render correctly for long lived branch 1`] = `
"excludedFromPurge": true,
"isMain": false,
"name": "branch-6.7",
- "type": "LONG",
}
}
className="little-spacer-right"
@@ -34,7 +33,6 @@ exports[`should render correctly for long lived branch 1`] = `
"excludedFromPurge": true,
"isMain": false,
"name": "branch-6.7",
- "type": "LONG",
}
}
component="my-project"
@@ -57,7 +55,6 @@ exports[`should render correctly for long lived branch 1`] = `
"excludedFromPurge": true,
"isMain": false,
"name": "branch-6.7",
- "type": "LONG",
}
}
component={
@@ -268,107 +265,3 @@ exports[`should render correctly for pull request 1`] = `
</td>
</tr>
`;
-
-exports[`should render correctly for short lived branch 1`] = `
-<tr>
- <td
- className="nowrap hide-overflow"
- >
- <BranchLikeIcon
- branchLike={
- Object {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "mergeBranch": "master",
- "name": "feature/foo",
- "type": "SHORT",
- }
- }
- className="little-spacer-right"
- />
- <span
- title="feature/foo"
- >
- feature/foo
- </span>
- <span />
- </td>
- <td
- className="nowrap"
- >
- <Connect(BranchStatus)
- branchLike={
- Object {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "mergeBranch": "master",
- "name": "feature/foo",
- "type": "SHORT",
- }
- }
- component="my-project"
- />
- </td>
- <td
- className="nowrap"
- >
- <DateFromNow
- date="2018-01-01"
- />
- </td>
- <td
- className="nowrap"
- >
- <BranchPurgeSetting
- branch={
- Object {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "mergeBranch": "master",
- "name": "feature/foo",
- "type": "SHORT",
- }
- }
- component={
- Object {
- "breadcrumbs": Array [],
- "key": "my-project",
- "name": "MyProject",
- "organization": "foo",
- "qualifier": "TRK",
- "qualityGate": Object {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": Array [
- Object {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": Array [],
- }
- }
- />
- </td>
- <td
- className="nowrap"
- >
- <ActionsDropdown>
- <ActionsDropdownItem
- className="js-delete"
- destructive={true}
- onClick={[MockFunction]}
- >
- project_branch_pull_request.branch.delete
- </ActionsDropdownItem>
- </ActionsDropdown>
- </td>
-</tr>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap
index f56120ef7c5..bc1c1a44bd3 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap
@@ -53,9 +53,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
}
}
component={
@@ -81,7 +79,7 @@ exports[`should render correctly 1`] = `
"tags": Array [],
}
}
- key="branch-slb-1"
+ key="branch-branch-11"
onDelete={[Function]}
onRename={[Function]}
/>
@@ -91,8 +89,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-1",
- "type": "LONG",
+ "name": "branch-1",
}
}
component={
@@ -118,7 +115,7 @@ exports[`should render correctly 1`] = `
"tags": Array [],
}
}
- key="branch-llb-1"
+ key="branch-branch-1"
onDelete={[Function]}
onRename={[Function]}
/>
@@ -202,9 +199,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "llb-1",
- "name": "slb-2",
- "type": "SHORT",
+ "name": "branch-12",
}
}
component={
@@ -230,7 +225,7 @@ exports[`should render correctly 1`] = `
"tags": Array [],
}
}
- key="branch-slb-2"
+ key="branch-branch-12"
onDelete={[Function]}
onRename={[Function]}
/>
@@ -278,8 +273,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-3",
- "type": "LONG",
+ "name": "branch-3",
}
}
component={
@@ -305,7 +299,7 @@ exports[`should render correctly 1`] = `
"tags": Array [],
}
}
- key="branch-llb-3"
+ key="branch-branch-3"
onDelete={[Function]}
onRename={[Function]}
/>
@@ -315,8 +309,7 @@ exports[`should render correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-2",
- "type": "LONG",
+ "name": "branch-2",
}
}
component={
@@ -342,7 +335,7 @@ exports[`should render correctly 1`] = `
"tags": Array [],
}
}
- key="branch-llb-2"
+ key="branch-branch-2"
onDelete={[Function]}
onRename={[Function]}
/>
@@ -463,9 +456,7 @@ exports[`should render purge setting correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-11",
}
}
component={
@@ -492,7 +483,7 @@ exports[`should render purge setting correctly 1`] = `
}
}
displayPurgeSetting={true}
- key="branch-slb-1"
+ key="branch-branch-11"
onDelete={[Function]}
onRename={[Function]}
/>
@@ -502,8 +493,7 @@ exports[`should render purge setting correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-1",
- "type": "LONG",
+ "name": "branch-1",
}
}
component={
@@ -530,7 +520,7 @@ exports[`should render purge setting correctly 1`] = `
}
}
displayPurgeSetting={true}
- key="branch-llb-1"
+ key="branch-branch-1"
onDelete={[Function]}
onRename={[Function]}
/>
@@ -616,9 +606,7 @@ exports[`should render purge setting correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "llb-1",
- "name": "slb-2",
- "type": "SHORT",
+ "name": "branch-12",
}
}
component={
@@ -645,7 +633,7 @@ exports[`should render purge setting correctly 1`] = `
}
}
displayPurgeSetting={true}
- key="branch-slb-2"
+ key="branch-branch-12"
onDelete={[Function]}
onRename={[Function]}
/>
@@ -694,8 +682,7 @@ exports[`should render purge setting correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-3",
- "type": "LONG",
+ "name": "branch-3",
}
}
component={
@@ -722,7 +709,7 @@ exports[`should render purge setting correctly 1`] = `
}
}
displayPurgeSetting={true}
- key="branch-llb-3"
+ key="branch-branch-3"
onDelete={[Function]}
onRename={[Function]}
/>
@@ -732,8 +719,7 @@ exports[`should render purge setting correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-2",
- "type": "LONG",
+ "name": "branch-2",
}
}
component={
@@ -760,7 +746,7 @@ exports[`should render purge setting correctly 1`] = `
}
}
displayPurgeSetting={true}
- key="branch-llb-2"
+ key="branch-branch-2"
onDelete={[Function]}
onRename={[Function]}
/>
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTabs-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTabs-test.tsx.snap
index 805b5566eb6..3dfe2a1e639 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTabs-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTabs-test.tsx.snap
@@ -10,7 +10,7 @@ exports[`should render all tabs correctly 1`] = `
Object {
"key": 0,
"label": <React.Fragment>
- <ShortLivingBranchIcon />
+ <BranchIcon />
<span
className="spacer-left"
>
@@ -45,38 +45,31 @@ exports[`should render all tabs correctly 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-1",
- "type": "LONG",
+ "name": "branch-1",
},
Object {
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-2",
- "type": "LONG",
+ "name": "branch-11",
},
Object {
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "name": "llb-3",
- "type": "LONG",
+ "name": "branch-12",
},
Object {
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "slb-1",
- "type": "SHORT",
+ "name": "branch-2",
},
Object {
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "llb-1",
- "name": "slb-2",
- "type": "SHORT",
+ "name": "branch-3",
},
]
}
@@ -121,7 +114,7 @@ exports[`should render all tabs correctly 2`] = `
Object {
"key": 0,
"label": <React.Fragment>
- <ShortLivingBranchIcon />
+ <BranchIcon />
<span
className="spacer-left"
>
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx
index e66edd4fde0..a27b71d0b74 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx
@@ -28,7 +28,8 @@ import {
getDuplications,
getSources
} from '../../api/components';
-import { getBranchLikeQuery, isSameBranchLike } from '../../helpers/branches';
+import { getBranchLikeQuery, isSameBranchLike } from '../../helpers/branch-like';
+import { BranchLike } from '../../types/branch-like';
import { WorkspaceContext } from '../workspace/context';
import DuplicationPopup from './components/DuplicationPopup';
import {
@@ -54,7 +55,7 @@ import './styles.css';
export interface Props {
aroundLine?: number;
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
component: string;
componentMeasures?: T.Measure[];
displayAllIssues?: boolean;
@@ -68,19 +69,19 @@ export interface Props {
highlightedLocationMessage?: { index: number; text: string | undefined };
loadComponent: (
component: string,
- branchLike: T.BranchLike | undefined
+ branchLike: BranchLike | undefined
) => Promise<T.SourceViewerFile>;
loadIssues: (
component: string,
from: number,
to: number,
- branchLike: T.BranchLike | undefined
+ branchLike: BranchLike | undefined
) => Promise<T.Issue[]>;
loadSources: (
component: string,
from: number,
to: number,
- branchLike: T.BranchLike | undefined
+ branchLike: BranchLike | undefined
) => Promise<T.SourceLine[]>;
onLoaded?: (component: T.SourceViewerFile, sources: T.SourceLine[], issues: T.Issue[]) => void;
onLocationSelect?: (index: number) => void;
@@ -657,7 +658,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
);
}
- renderHeader(branchLike: T.BranchLike | undefined, sourceViewerFile: T.SourceViewerFile) {
+ renderHeader(branchLike: BranchLike | undefined, sourceViewerFile: T.SourceViewerFile) {
return this.props.slimHeader ? (
<SourceViewerHeaderSlim branchLike={branchLike} sourceViewerFile={sourceViewerFile} />
) : (
@@ -722,7 +723,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
}
}
-function defaultLoadComponent(component: string, branchLike: T.BranchLike | undefined) {
+function defaultLoadComponent(component: string, branchLike: BranchLike | undefined) {
return Promise.all([
getComponentForSourceViewer({ component, ...getBranchLikeQuery(branchLike) }),
getComponentData({ component, ...getBranchLikeQuery(branchLike) })
@@ -736,7 +737,7 @@ function defaultLoadSources(
key: string,
from: number | undefined,
to: number | undefined,
- branchLike: T.BranchLike | undefined
+ branchLike: BranchLike | undefined
) {
return getSources({ key, from, to, ...getBranchLikeQuery(branchLike) });
}
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx
index d6c8104533e..c92f8a3489d 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx
@@ -20,6 +20,7 @@
import * as React from 'react';
import { Button } from 'sonar-ui-common/components/controls/buttons';
import { translate } from 'sonar-ui-common/helpers/l10n';
+import { BranchLike } from '../../types/branch-like';
import Line from './components/Line';
import { getSecondaryIssueLocationsForLine } from './helpers/issueLocations';
import {
@@ -38,7 +39,7 @@ const ZERO_LINE = {
};
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
componentKey: string;
displayAllIssues?: boolean;
displayIssueLocationsCount?: boolean;
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerContext.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerContext.tsx
index 4a17a3a44bf..02383747670 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerContext.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerContext.tsx
@@ -18,13 +18,14 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { BranchLike } from '../../types/branch-like';
interface SourceViewerContextShape {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
file: T.SourceViewerFile;
}
export const SourceViewerContext = React.createContext<SourceViewerContextShape>({
- branchLike: {} as T.BranchLike,
+ branchLike: {} as BranchLike,
file: {} as T.SourceViewerFile
});
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx
index c54a71591b5..7c0318d1b5e 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx
@@ -31,14 +31,15 @@ import { formatMeasure } from 'sonar-ui-common/helpers/measures';
import { collapsedDirFromPath, fileFromPath } from 'sonar-ui-common/helpers/path';
import { omitNil } from 'sonar-ui-common/helpers/request';
import { getBaseUrl, getPathUrlAsString } from 'sonar-ui-common/helpers/urls';
-import { getBranchLikeQuery, isMainBranch } from '../../helpers/branches';
+import { getBranchLikeQuery, isMainBranch } from '../../helpers/branch-like';
import { getBranchLikeUrl, getCodeUrl, getComponentIssuesUrl } from '../../helpers/urls';
+import { BranchLike } from '../../types/branch-like';
import Favorite from '../controls/Favorite';
import { WorkspaceContextShape } from '../workspace/context';
import MeasuresOverlay from './components/MeasuresOverlay';
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
componentMeasures?: T.Measure[];
openComponent: WorkspaceContextShape['openComponent'];
showMeasures?: boolean;
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx
index b7c2199ab81..451f722c6a6 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx
@@ -28,13 +28,14 @@ import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { collapsedDirFromPath, fileFromPath } from 'sonar-ui-common/helpers/path';
import { getPathUrlAsString } from 'sonar-ui-common/helpers/urls';
-import { getBranchLikeQuery, isMainBranch } from '../../helpers/branches';
+import { getBranchLikeQuery, isMainBranch } from '../../helpers/branch-like';
import { getBranchLikeUrl, getComponentIssuesUrl } from '../../helpers/urls';
+import { BranchLike } from '../../types/branch-like';
import Favorite from '../controls/Favorite';
import './SourceViewerHeaderSlim.css';
export interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
expandable?: boolean;
loading?: boolean;
onExpand?: () => void;
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx
index 6a6ef630b2d..4a214cadc9d 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx
@@ -18,8 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { mockMainBranch } from '../../../helpers/mocks/branch-like';
import SourceViewerBase from '../SourceViewerBase';
-import { mockMainBranch } from '../../../helpers/testMocks';
it('should render correctly', () => {
expect(shallowRender()).toMatchSnapshot();
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeader-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeader-test.tsx
index 385046e2078..160e0ed9d12 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeader-test.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeader-test.tsx
@@ -19,7 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockMainBranch, mockSourceViewerFile } from '../../../helpers/testMocks';
+import { mockMainBranch } from '../../../helpers/mocks/branch-like';
+import { mockSourceViewerFile } from '../../../helpers/testMocks';
import SourceViewerHeader from '../SourceViewerHeader';
it('should render correctly for a regular file', () => {
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeaderSlim-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeaderSlim-test.tsx
index 4adb4391d1c..cda253b5f8d 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeaderSlim-test.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeaderSlim-test.tsx
@@ -19,7 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockMainBranch, mockSourceViewerFile } from '../../../helpers/testMocks';
+import { mockMainBranch } from '../../../helpers/mocks/branch-like';
+import { mockSourceViewerFile } from '../../../helpers/testMocks';
import SourceViewerHeaderSlim, { Props } from '../SourceViewerHeaderSlim';
it('should render correctly', () => {
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx
index 53b28bab2a8..f1dc5d56aa9 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx
@@ -26,13 +26,14 @@ import { Alert } from 'sonar-ui-common/components/ui/Alert';
import { PopupPlacement } from 'sonar-ui-common/components/ui/popups';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { collapsedDirFromPath, fileFromPath } from 'sonar-ui-common/helpers/path';
-import { isPullRequest, isShortLivingBranch } from '../../../helpers/branches';
+import { isPullRequest } from '../../../helpers/branch-like';
import { getProjectUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import { WorkspaceContextShape } from '../../workspace/context';
interface Props {
blocks: T.DuplicationBlock[];
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
duplicatedFiles?: T.Dict<T.DuplicatedFile>;
inRemovedComponent: boolean;
onClose: () => void;
@@ -43,7 +44,7 @@ interface Props {
export default class DuplicationPopup extends React.PureComponent<Props> {
shouldLink() {
const { branchLike } = this.props;
- return !isShortLivingBranch(branchLike) && !isPullRequest(branchLike);
+ return !isPullRequest(branchLike);
}
isDifferentComponent = (
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx
index 793c1384180..d15646955e9 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx
@@ -20,6 +20,7 @@
import * as classNames from 'classnames';
import { times } from 'lodash';
import * as React from 'react';
+import { BranchLike } from '../../../types/branch-like';
import './Line.css';
import LineCode from './LineCode';
import LineCoverage from './LineCoverage';
@@ -30,7 +31,7 @@ import LineNumber from './LineNumber';
import LineSCM from './LineSCM';
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
displayAllIssues?: boolean;
displayCoverage: boolean;
displayDuplications: boolean;
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx
index d80f2e8706b..eeb2a678131 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx
@@ -19,6 +19,7 @@
*/
import * as classNames from 'classnames';
import * as React from 'react';
+import { BranchLike } from '../../../types/branch-like';
import LocationIndex from '../../common/LocationIndex';
import LocationMessage from '../../common/LocationMessage';
import {
@@ -30,7 +31,7 @@ import {
import LineIssuesList from './LineIssuesList';
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
displayIssueLocationsCount?: boolean;
displayIssueLocationsLink?: boolean;
displayLocationMarkers?: boolean;
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.tsx
index f64da90def8..a37474ecbcf 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.tsx
@@ -18,10 +18,11 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { BranchLike } from '../../../types/branch-like';
import Issue from '../../issue/Issue';
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
displayIssueLocationsCount?: boolean;
displayIssueLocationsLink?: boolean;
issuePopup: { issue: string; name: string } | undefined;
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx
index 0f8a44d9c0a..ea2dac3fa06 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx
@@ -31,17 +31,18 @@ import { formatMeasure } from 'sonar-ui-common/helpers/measures';
import { getFacets } from '../../../api/issues';
import { getMeasures } from '../../../api/measures';
import { getAllMetrics } from '../../../api/metrics';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
import { ISSUE_TYPES, SEVERITIES } from '../../../helpers/constants';
import { enhanceMeasuresWithMetrics, getDisplayMetrics } from '../../../helpers/measures';
import { getBranchLikeUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import Measure from '../../measure/Measure';
import SeverityHelper from '../../shared/SeverityHelper';
import CoverageRating from '../../ui/CoverageRating';
import MeasuresOverlayMeasure from './MeasuresOverlayMeasure';
interface Props {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
onClose: () => void;
sourceViewerFile: T.SourceViewerFile;
}
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/Line-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/Line-test.tsx
index 45bfddc9169..1c7d4dca43e 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/Line-test.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/Line-test.tsx
@@ -19,7 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockIssue, mockPullRequest, mockSourceLine } from '../../../../helpers/testMocks';
+import { mockPullRequest } from '../../../../helpers/mocks/branch-like';
+import { mockIssue, mockSourceLine } from '../../../../helpers/testMocks';
import Line from '../Line';
it('should render correctly', () => {
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.tsx
index 36d94ea9beb..b6fbc7bc4c4 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.tsx
@@ -19,7 +19,8 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockIssue, mockShortLivingBranch, mockSourceLine } from '../../../../helpers/testMocks';
+import { mockBranch } from '../../../../helpers/mocks/branch-like';
+import { mockIssue, mockSourceLine } from '../../../../helpers/testMocks';
import LineCode from '../LineCode';
it('render code', () => {
@@ -29,7 +30,7 @@ it('render code', () => {
function shallowRender(props: Partial<LineCode['props']> = {}) {
return shallow(
<LineCode
- branchLike={mockShortLivingBranch()}
+ branchLike={mockBranch()}
displayLocationMarkers={true}
highlightedLocationMessage={{ index: 0, text: 'location description' }}
highlightedSymbols={['sym-9']}
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineOptionsPopup-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineOptionsPopup-test.tsx
index 81fc9ef1230..a0b4dc07f4c 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineOptionsPopup-test.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineOptionsPopup-test.tsx
@@ -19,13 +19,14 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
+import { mockBranch } from '../../../../helpers/mocks/branch-like';
import LineOptionsPopup from '../LineOptionsPopup';
jest.mock('../../SourceViewerContext', () => ({
SourceViewerContext: {
Consumer: (props: any) =>
props.children({
- branchLike: { isMain: false, name: 'feature', type: 'SHORT' },
+ branchLike: mockBranch({ name: 'feature' }),
file: { project: 'prj', key: 'foo' }
})
}
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx
index c2a0cad7bf9..e33660c2557 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx
@@ -20,6 +20,7 @@
import { shallow } from 'enzyme';
import * as React from 'react';
import { click, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
+import { mockBranch } from '../../../../helpers/mocks/branch-like';
import MeasuresOverlay from '../MeasuresOverlay';
jest.mock('../../../../api/issues', () => ({
@@ -149,13 +150,7 @@ const sourceViewerFile: T.SourceViewerFile = {
uuid: 'abcd123'
};
-const branchLike: T.ShortLivingBranch = {
- isMain: false,
- excludedFromPurge: true,
- mergeBranch: 'master',
- name: 'feature',
- type: 'SHORT'
-};
+const branchLike = mockBranch({ name: 'feature' });
it('should render source file', async () => {
const wrapper = shallowRender();
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineCode-test.tsx.snap b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineCode-test.tsx.snap
index 384c3c1e53b..fa3ee7c6dba 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineCode-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineCode-test.tsx.snap
@@ -47,9 +47,7 @@ exports[`render code 1`] = `
"analysisDate": "2018-01-01",
"excludedFromPurge": true,
"isMain": false,
- "mergeBranch": "master",
- "name": "feature/foo",
- "type": "SHORT",
+ "name": "branch-6.7",
}
}
issues={
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/__tests__/loadIssues-test.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/__tests__/loadIssues-test.ts
index aebc4fe7ce1..bfda8cc6990 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/__tests__/loadIssues-test.ts
+++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/__tests__/loadIssues-test.ts
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { mockMainBranch } from '../../../../helpers/testMocks';
+import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
import loadIssues from '../loadIssues';
jest.mock('../../../../api/issues', () => ({
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts
index 40070593100..031750302ed 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts
+++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts
@@ -18,13 +18,14 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { searchIssues } from '../../../api/issues';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
import { parseIssueFromResponse } from '../../../helpers/issues';
+import { BranchLike } from '../../../types/branch-like';
// maximum possible value
const PAGE_SIZE = 500;
-function buildQuery(component: string, branchLike: T.BranchLike | undefined) {
+function buildQuery(component: string, branchLike: BranchLike | undefined) {
return {
additionalFields: '_all',
resolved: 'false',
@@ -78,7 +79,7 @@ export default function loadIssues(
component: string,
_fromLine: number,
toLine: number,
- branchLike: T.BranchLike | undefined
+ branchLike: BranchLike | undefined
): Promise<T.Issue[]> {
const query = buildQuery(component, branchLike);
return new Promise(resolve => {
diff --git a/server/sonar-web/src/main/js/components/common/BranchStatus.tsx b/server/sonar-web/src/main/js/components/common/BranchStatus.tsx
index 3ed98bc0eb5..90dfd237ec1 100644
--- a/server/sonar-web/src/main/js/components/common/BranchStatus.tsx
+++ b/server/sonar-web/src/main/js/components/common/BranchStatus.tsx
@@ -21,9 +21,10 @@ import * as React from 'react';
import { connect } from 'react-redux';
import Level from 'sonar-ui-common/components/ui/Level';
import { getBranchStatusByBranchLike, Store } from '../../store/rootReducer';
+import { BranchLike } from '../../types/branch-like';
interface Props {
- branchLike: T.BranchLike;
+ branchLike: BranchLike;
component: string;
status?: string;
}
diff --git a/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx
index 6c3ea98d9b7..e684546641f 100644
--- a/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx
+++ b/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx
@@ -19,7 +19,7 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockLongLivingBranch } from '../../../helpers/testMocks';
+import { mockBranch } from '../../../helpers/mocks/branch-like';
import { BranchStatus } from '../BranchStatus';
it('should render correctly', () => {
@@ -29,7 +29,5 @@ it('should render correctly', () => {
});
function shallowRender(status?: string) {
- return shallow(
- <BranchStatus branchLike={mockLongLivingBranch()} component="foo" status={status} />
- );
+ return shallow(<BranchStatus branchLike={mockBranch()} component="foo" status={status} />);
}
diff --git a/server/sonar-web/src/main/js/components/icons/BranchLikeIcon.tsx b/server/sonar-web/src/main/js/components/icons/BranchLikeIcon.tsx
index 0307ad9f699..d9842ab740e 100644
--- a/server/sonar-web/src/main/js/components/icons/BranchLikeIcon.tsx
+++ b/server/sonar-web/src/main/js/components/icons/BranchLikeIcon.tsx
@@ -18,19 +18,20 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon';
import { IconProps } from 'sonar-ui-common/components/icons/Icon';
import PullRequestIcon from 'sonar-ui-common/components/icons/PullRequestIcon';
-import ShortLivingBranchIcon from 'sonar-ui-common/components/icons/ShortLivingBranchIcon';
-import { isPullRequest } from '../../helpers/branches';
+import { isPullRequest } from '../../helpers/branch-like';
+import { BranchLike } from '../../types/branch-like';
export interface BranchLikeIconProps extends IconProps {
- branchLike: T.BranchLike;
+ branchLike: BranchLike;
}
export default function BranchLikeIcon({ branchLike, ...props }: BranchLikeIconProps) {
if (isPullRequest(branchLike)) {
return <PullRequestIcon {...props} />;
} else {
- return <ShortLivingBranchIcon {...props} />;
+ return <BranchIcon {...props} />;
}
}
diff --git a/server/sonar-web/src/main/js/components/icons/__tests__/BranchLikeIcon-test.tsx b/server/sonar-web/src/main/js/components/icons/__tests__/BranchLikeIcon-test.tsx
index d4ea4f0bdf4..29616efa349 100644
--- a/server/sonar-web/src/main/js/components/icons/__tests__/BranchLikeIcon-test.tsx
+++ b/server/sonar-web/src/main/js/components/icons/__tests__/BranchLikeIcon-test.tsx
@@ -20,20 +20,11 @@
import { shallow } from 'enzyme';
import * as React from 'react';
-import {
- mockLongLivingBranch,
- mockPullRequest,
- mockShortLivingBranch
-} from '../../../helpers/testMocks';
+import { mockBranch, mockPullRequest } from '../../../helpers/mocks/branch-like';
import BranchLikeIcon, { BranchLikeIconProps } from '../BranchLikeIcon';
-it('should render short living branch icon for short living branch', () => {
- const wrapper = shallowRender({ branchLike: mockShortLivingBranch() });
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should render short living branch icon for long living branch', () => {
- const wrapper = shallowRender({ branchLike: mockLongLivingBranch() });
+it('should render branch icon correctly', () => {
+ const wrapper = shallowRender({ branchLike: mockBranch() });
expect(wrapper).toMatchSnapshot();
});
diff --git a/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/BranchLikeIcon-test.tsx.snap b/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/BranchLikeIcon-test.tsx.snap
index abc10820cf4..3387e59a0a7 100644
--- a/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/BranchLikeIcon-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/BranchLikeIcon-test.tsx.snap
@@ -1,7 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`should render pull request icon correctly 1`] = `<PullRequestIcon />`;
-
-exports[`should render short living branch icon for long living branch 1`] = `<ShortLivingBranchIcon />`;
+exports[`should render branch icon correctly 1`] = `<BranchIcon />`;
-exports[`should render short living branch icon for short living branch 1`] = `<ShortLivingBranchIcon />`;
+exports[`should render pull request icon correctly 1`] = `<PullRequestIcon />`;
diff --git a/server/sonar-web/src/main/js/components/issue/Issue.tsx b/server/sonar-web/src/main/js/components/issue/Issue.tsx
index 6bfaffd7c17..4aac3140b89 100644
--- a/server/sonar-web/src/main/js/components/issue/Issue.tsx
+++ b/server/sonar-web/src/main/js/components/issue/Issue.tsx
@@ -20,12 +20,13 @@
import * as key from 'keymaster';
import * as React from 'react';
import { setIssueAssignee } from '../../api/issues';
+import { BranchLike } from '../../types/branch-like';
import { updateIssue } from './actions';
import './Issue.css';
import IssueView from './IssueView';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
checked?: boolean;
displayLocationsCount?: boolean;
displayLocationsLink?: boolean;
diff --git a/server/sonar-web/src/main/js/components/issue/IssueView.tsx b/server/sonar-web/src/main/js/components/issue/IssueView.tsx
index 19fd1bea80a..3496d4da7bc 100644
--- a/server/sonar-web/src/main/js/components/issue/IssueView.tsx
+++ b/server/sonar-web/src/main/js/components/issue/IssueView.tsx
@@ -21,13 +21,14 @@ import classNames from 'classnames';
import * as React from 'react';
import Checkbox from 'sonar-ui-common/components/controls/Checkbox';
import { deleteIssueComment, editIssueComment } from '../../api/issues';
+import { BranchLike } from '../../types/branch-like';
import { updateIssue } from './actions';
import IssueActionsBar from './components/IssueActionsBar';
import IssueCommentLine from './components/IssueCommentLine';
import IssueTitleBar from './components/IssueTitleBar';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
checked?: boolean;
currentPopup?: string;
displayLocationsCount?: boolean;
diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueChangelogDiff.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueChangelogDiff.tsx
index 1334feae837..44cf088ecd5 100644
--- a/server/sonar-web/src/main/js/components/issue/components/IssueChangelogDiff.tsx
+++ b/server/sonar-web/src/main/js/components/issue/components/IssueChangelogDiff.tsx
@@ -36,21 +36,22 @@ export default function IssueChangelogDiff({ diff }: Props) {
)}
</p>
);
- } else if (diff.key === 'from_long_branch') {
+ } else if (['from_long_branch', 'from_branch'].includes(diff.key)) {
return (
<p>
{translateWithParameters(
- 'issue.change.from_long_branch',
+ 'issue.change.from_branch',
diff.oldValue || '',
diff.newValue || ''
)}
</p>
);
} else if (diff.key === 'from_short_branch') {
+ // Applies to both legacy short lived branch and pull request
return (
<p>
{translateWithParameters(
- 'issue.change.from_short_branch',
+ 'issue.change.from_non_branch',
diff.oldValue || '',
diff.newValue || ''
)}
diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx
index 7b52bd5979c..e143e4cc245 100644
--- a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx
+++ b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx
@@ -23,8 +23,9 @@ import Tooltip from 'sonar-ui-common/components/controls/Tooltip';
import LinkIcon from 'sonar-ui-common/components/icons/LinkIcon';
import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n';
import { formatMeasure } from 'sonar-ui-common/helpers/measures';
-import { getBranchLikeQuery } from '../../../helpers/branches';
+import { getBranchLikeQuery } from '../../../helpers/branch-like';
import { getComponentIssuesUrl } from '../../../helpers/urls';
+import { BranchLike } from '../../../types/branch-like';
import LocationIndex from '../../common/LocationIndex';
import { WorkspaceContext } from '../../workspace/context';
import IssueChangelog from './IssueChangelog';
@@ -32,7 +33,7 @@ import IssueMessage from './IssueMessage';
import SimilarIssuesFilter from './SimilarIssuesFilter';
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
currentPopup?: string;
displayLocationsCount?: boolean;
displayLocationsLink?: boolean;
diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelogDiff-test.tsx b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelogDiff-test.tsx
index 7465e5c5954..b28a355f366 100644
--- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelogDiff-test.tsx
+++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelogDiff-test.tsx
@@ -23,16 +23,53 @@ import IssueChangelogDiff from '../IssueChangelogDiff';
it('should render correctly', () => {
expect(shallowRender()).toMatchSnapshot();
+});
+
+it('should render correctly file diff', () => {
expect(
shallowRender({ diff: { key: 'file', oldValue: 'foo/bar.js', newValue: 'bar/baz.js' } })
).toMatchSnapshot();
+});
+
+it('should render correctly branch diff', () => {
+ expect(
+ shallowRender({
+ diff: {
+ // Legacy key
+ key: 'from_long_branch',
+ oldValue: 'foo',
+ newValue: 'bar'
+ }
+ })
+ ).toMatchSnapshot();
+
expect(
- shallowRender({ diff: { key: 'from_long_branch', oldValue: 'foo', newValue: 'bar' } })
+ shallowRender({
+ diff: {
+ // Legacy key
+ key: 'from_short_branch',
+ oldValue: 'foo',
+ newValue: 'bar'
+ }
+ })
).toMatchSnapshot();
+
expect(
- shallowRender({ diff: { key: 'from_short_branch', oldValue: 'foo', newValue: 'bar' } })
+ shallowRender({
+ diff: {
+ key: 'from_branch',
+ oldValue: 'foo',
+ newValue: 'bar'
+ }
+ })
).toMatchSnapshot();
+});
+
+it('should render correctly line diff', () => {
expect(shallowRender({ diff: { key: 'line', oldValue: '80' } })).toMatchSnapshot();
+});
+
+it('should render correctly effort diff', () => {
expect(shallowRender({ diff: { key: 'effort', newValue: '12' } })).toMatchSnapshot();
expect(
shallowRender({ diff: { key: 'effort', newValue: '12', oldValue: '10' } })
diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.tsx b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.tsx
index 32c7e440977..b839e6d1095 100644
--- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.tsx
+++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.tsx
@@ -19,6 +19,7 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
+import { mockBranch } from '../../../../helpers/mocks/branch-like';
import { mockIssue } from '../../../../helpers/testMocks';
import IssueTitleBar from '../IssueTitleBar';
@@ -26,13 +27,7 @@ const issue: T.Issue = mockIssue();
const issueWithLocations: T.Issue = mockIssue(true);
it('should render the titlebar correctly', () => {
- const branch: T.ShortLivingBranch = {
- isMain: false,
- excludedFromPurge: true,
- mergeBranch: 'master',
- name: 'feature-1.0',
- type: 'SHORT'
- };
+ const branch = mockBranch({ name: 'feature-1.0' });
const element = shallow(
<IssueTitleBar branchLike={branch} issue={issue} togglePopup={jest.fn()} />
);
diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueChangelogDiff-test.tsx.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueChangelogDiff-test.tsx.snap
index f2af70e4bf2..1e953fa8a4e 100644
--- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueChangelogDiff-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueChangelogDiff-test.tsx.snap
@@ -6,44 +6,50 @@ exports[`should render correctly 1`] = `
</p>
`;
-exports[`should render correctly 2`] = `
+exports[`should render correctly branch diff 1`] = `
<p>
- issue.change.file_move.foo/bar.js.bar/baz.js
+ issue.change.from_branch.foo.bar
</p>
`;
-exports[`should render correctly 3`] = `
+exports[`should render correctly branch diff 2`] = `
<p>
- issue.change.from_long_branch.foo.bar
+ issue.change.from_non_branch.foo.bar
</p>
`;
-exports[`should render correctly 4`] = `
+exports[`should render correctly branch diff 3`] = `
<p>
- issue.change.from_short_branch.foo.bar
+ issue.change.from_branch.foo.bar
</p>
`;
-exports[`should render correctly 5`] = `
+exports[`should render correctly effort diff 1`] = `
<p>
- issue.changelog.line_removed_X.80
+ issue.changelog.changed_to.issue.changelog.field.effort.work_duration.x_minutes.12
</p>
`;
-exports[`should render correctly 6`] = `
+exports[`should render correctly effort diff 2`] = `
<p>
- issue.changelog.changed_to.issue.changelog.field.effort.work_duration.x_minutes.12
+ issue.changelog.changed_to.issue.changelog.field.effort.work_duration.x_minutes.12 (issue.changelog.was.work_duration.x_minutes.10)
</p>
`;
-exports[`should render correctly 7`] = `
+exports[`should render correctly effort diff 3`] = `
<p>
- issue.changelog.changed_to.issue.changelog.field.effort.work_duration.x_minutes.12 (issue.changelog.was.work_duration.x_minutes.10)
+ issue.changelog.removed.issue.changelog.field.effort (issue.changelog.was.work_duration.x_minutes.10)
</p>
`;
-exports[`should render correctly 8`] = `
+exports[`should render correctly file diff 1`] = `
<p>
- issue.changelog.removed.issue.changelog.field.effort (issue.changelog.was.work_duration.x_minutes.10)
+ issue.change.file_move.foo/bar.js.bar/baz.js
+</p>
+`;
+
+exports[`should render correctly line diff 1`] = `
+<p>
+ issue.changelog.line_removed_X.80
</p>
`;
diff --git a/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx b/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx
index 6be67ae4a64..55f3fb74f93 100644
--- a/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx
+++ b/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx
@@ -33,8 +33,9 @@ import {
Serie,
splitSeriesInGraphs
} from '../../apps/projectActivity/utils';
-import { getBranchLikeQuery } from '../../helpers/branches';
+import { getBranchLikeQuery } from '../../helpers/branch-like';
import { getShortType } from '../../helpers/measures';
+import { BranchLike } from '../../types/branch-like';
import { Router, withRouter } from '../hoc/withRouter';
import PreviewGraphTooltips from './PreviewGraphTooltips';
@@ -43,7 +44,7 @@ interface History {
}
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
history?: History;
metrics: T.Dict<T.Metric>;
project: string;
diff --git a/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx b/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx
index 7b08d04e807..6cd53399386 100644
--- a/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx
+++ b/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx
@@ -19,8 +19,9 @@
*/
import * as React from 'react';
import { Link } from 'react-router';
-import { getBranchLikeQuery } from '../../helpers/branches';
+import { getBranchLikeQuery } from '../../helpers/branch-like';
import { getComponentDrilldownUrl, getComponentIssuesUrl } from '../../helpers/urls';
+import { BranchLike } from '../../types/branch-like';
const ISSUE_MEASURES = [
'violations',
@@ -71,7 +72,7 @@ const issueParamsPerMetric: T.Dict<T.Dict<string>> = {
};
interface Props {
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
children?: React.ReactNode;
className?: string;
component: string;
diff --git a/server/sonar-web/src/main/js/components/workspace/WorkspaceComponentViewer.tsx b/server/sonar-web/src/main/js/components/workspace/WorkspaceComponentViewer.tsx
index e33e921db80..62dc83c67f0 100644
--- a/server/sonar-web/src/main/js/components/workspace/WorkspaceComponentViewer.tsx
+++ b/server/sonar-web/src/main/js/components/workspace/WorkspaceComponentViewer.tsx
@@ -17,13 +17,14 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import { debounce } from 'lodash';
import * as React from 'react';
import { connect } from 'react-redux';
-import { debounce } from 'lodash';
import { scrollToElement } from 'sonar-ui-common/helpers/scrolling';
import { getParents } from '../../api/components';
-import { isPullRequest, isShortLivingBranch } from '../../helpers/branches';
+import { isPullRequest } from '../../helpers/branch-like';
import { fetchBranchStatus } from '../../store/rootActions';
+import { BranchLike } from '../../types/branch-like';
import SourceViewer from '../SourceViewer/SourceViewer';
import { ComponentDescriptor } from './context';
import WorkspaceComponentTitle from './WorkspaceComponentTitle';
@@ -31,7 +32,7 @@ import WorkspaceHeader, { Props as WorkspaceHeaderProps } from './WorkspaceHeade
export interface Props extends T.Omit<WorkspaceHeaderProps, 'children' | 'onClose'> {
component: ComponentDescriptor;
- fetchBranchStatus: (branchLike: T.BranchLike, projectKey: string) => Promise<void>;
+ fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>;
height: number;
onClose: (componentKey: string) => void;
onLoad: (details: { key: string; name: string; qualifier: string }) => void;
@@ -90,7 +91,7 @@ export class WorkspaceComponentViewer extends React.PureComponent<Props> {
refreshBranchStatus = () => {
const { component } = this.props;
const { branchLike } = component;
- if (branchLike && (isPullRequest(branchLike) || isShortLivingBranch(branchLike))) {
+ if (branchLike && isPullRequest(branchLike)) {
getParents(component.key).then(
(parents?: any[]) => {
if (parents && parents.length > 0) {
diff --git a/server/sonar-web/src/main/js/components/workspace/__tests__/WorkspaceComponentViewer-test.tsx b/server/sonar-web/src/main/js/components/workspace/__tests__/WorkspaceComponentViewer-test.tsx
index c2a35daf318..9bc0955957d 100644
--- a/server/sonar-web/src/main/js/components/workspace/__tests__/WorkspaceComponentViewer-test.tsx
+++ b/server/sonar-web/src/main/js/components/workspace/__tests__/WorkspaceComponentViewer-test.tsx
@@ -21,7 +21,8 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { getParents } from '../../../api/components';
-import { mockIssue, mockPullRequest } from '../../../helpers/testMocks';
+import { mockPullRequest } from '../../../helpers/mocks/branch-like';
+import { mockIssue } from '../../../helpers/testMocks';
import { Props, WorkspaceComponentViewer } from '../WorkspaceComponentViewer';
jest.mock('../../../api/components', () => ({
diff --git a/server/sonar-web/src/main/js/components/workspace/context.ts b/server/sonar-web/src/main/js/components/workspace/context.ts
index fdc06371a07..ea39d8906c7 100644
--- a/server/sonar-web/src/main/js/components/workspace/context.ts
+++ b/server/sonar-web/src/main/js/components/workspace/context.ts
@@ -18,9 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { createContext } from 'react';
+import { BranchLike } from '../../types/branch-like';
export interface ComponentDescriptor {
- branchLike: T.BranchLike | undefined;
+ branchLike: BranchLike | undefined;
key: string;
line?: number;
name?: string;
diff --git a/server/sonar-web/src/main/js/helpers/__tests__/branches-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/branches-test.ts
index 09b9442991c..b137c1be6b5 100644
--- a/server/sonar-web/src/main/js/helpers/__tests__/branches-test.ts
+++ b/server/sonar-web/src/main/js/helpers/__tests__/branches-test.ts
@@ -18,28 +18,23 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { getBrancheLikesAsTree, isSameBranchLike, sortBranches } from '../branches';
-import {
- mockLongLivingBranch,
- mockMainBranch,
- mockPullRequest,
- mockShortLivingBranch
-} from '../testMocks';
+import { getBrancheLikesAsTree, isSameBranchLike, sortBranches } from '../branch-like';
+import { mockBranch, mockMainBranch, mockPullRequest } from '../mocks/branch-like';
describe('#getBrancheLikesAsTree', () => {
it('should correctly map branches and prs to tree object', () => {
const main = mockMainBranch({ name: 'master' });
- const llb1 = mockLongLivingBranch({ name: 'llb1' });
- const llb2 = mockLongLivingBranch({ name: 'llb2' });
- const slb1 = mockShortLivingBranch({ name: 'slb1' });
- const slb2 = mockShortLivingBranch({ name: 'slb2' });
+ const branch1 = mockBranch({ name: 'branch-1' });
+ const branch2 = mockBranch({ name: 'branch-2' });
+ const branch3 = mockBranch({ name: 'branch-3' });
+ const branch4 = mockBranch({ name: 'branch-4' });
const mainPr1 = mockPullRequest({ base: main.name, key: 'PR1' });
const mainPr2 = mockPullRequest({ base: main.name, key: 'PR2' });
- const llb1Pr1 = mockPullRequest({ base: llb1.name, key: 'PR1' });
- const llb1Pr2 = mockPullRequest({ base: llb1.name, key: 'PR2' });
- const llb2Pr1 = mockPullRequest({ base: llb2.name, key: 'PR1' });
- const llb2Pr2 = mockPullRequest({ base: llb2.name, key: 'PR1' });
+ const llb1Pr1 = mockPullRequest({ base: branch1.name, key: 'PR1' });
+ const llb1Pr2 = mockPullRequest({ base: branch1.name, key: 'PR2' });
+ const llb2Pr1 = mockPullRequest({ base: branch2.name, key: 'PR1' });
+ const llb2Pr2 = mockPullRequest({ base: branch2.name, key: 'PR1' });
const orphanPR1 = mockPullRequest({ isOrphan: true, key: 'PR1' });
const orphanPR2 = mockPullRequest({ isOrphan: true, key: 'PR2' });
const parentlessPR1 = mockPullRequest({ base: 'not_present_branch_1', key: 'PR1' });
@@ -47,13 +42,13 @@ describe('#getBrancheLikesAsTree', () => {
expect(
getBrancheLikesAsTree([
- llb2,
- llb1,
+ branch2,
+ branch1,
main,
orphanPR2,
orphanPR1,
- slb2,
- slb1,
+ branch4,
+ branch3,
mainPr2,
mainPr1,
parentlessPR2,
@@ -69,10 +64,10 @@ describe('#getBrancheLikesAsTree', () => {
pullRequests: [mainPr1, mainPr2]
},
branchTree: [
- { branch: llb1, pullRequests: [llb1Pr1, llb1Pr2] },
- { branch: llb2, pullRequests: [llb2Pr1, llb2Pr1] },
- { branch: slb1, pullRequests: [] },
- { branch: slb2, pullRequests: [] }
+ { branch: branch1, pullRequests: [llb1Pr1, llb1Pr2] },
+ { branch: branch2, pullRequests: [llb2Pr1, llb2Pr1] },
+ { branch: branch3, pullRequests: [] },
+ { branch: branch4, pullRequests: [] }
],
parentlessPullRequests: [parentlessPR1, parentlessPR2],
orphanPullRequests: [orphanPR1, orphanPR2]
@@ -83,40 +78,32 @@ describe('#getBrancheLikesAsTree', () => {
describe('#sortBranches', () => {
it('should sort branches correctly', () => {
const main = mockMainBranch();
- const shortFoo = mockShortLivingBranch({ name: 'shortFoo', mergeBranch: 'master' });
- const shortBar = mockShortLivingBranch({ name: 'shortBar', mergeBranch: 'longBaz' });
- const shortPre = mockShortLivingBranch({ name: 'shortPre', mergeBranch: 'shortFoo' });
- const longBaz = mockLongLivingBranch({ name: 'longBaz' });
- const longQux = mockLongLivingBranch({ name: 'longQux' });
- const longQwe = mockLongLivingBranch({ name: 'longQwe' });
- const branchList = [shortFoo, longBaz, shortPre, longQux, main, longQwe, shortBar];
+ const foo = mockBranch({ name: 'shortFoo' });
+ const bar = mockBranch({ name: 'shortBar' });
+ const pre = mockBranch({ name: 'shortPre' });
+ const baz = mockBranch({ name: 'longBaz' });
+ const qux = mockBranch({ name: 'longQux' });
+ const qwe = mockBranch({ name: 'longQwe' });
+ const branchList = [foo, baz, pre, qux, main, qwe, bar];
const sortedBrancList = sortBranches(branchList);
- expect(sortedBrancList).toEqual([
- main,
- longBaz,
- longQux,
- longQwe,
- shortBar,
- shortFoo,
- shortPre
- ]);
+ expect(sortedBrancList).toEqual([main, baz, qux, qwe, bar, foo, pre]);
});
});
describe('#isSameBranchLike', () => {
it('compares different kinds', () => {
const main = mockMainBranch();
- const short = mockShortLivingBranch({ name: 'foo' });
- const long = mockLongLivingBranch({ name: 'foo' });
+ const foo = mockBranch({ name: 'foo' });
+ const foo1 = mockBranch({ name: 'foo-1' });
const pr = mockPullRequest();
expect(isSameBranchLike(main, pr)).toBeFalsy();
- expect(isSameBranchLike(main, short)).toBeFalsy();
- expect(isSameBranchLike(main, long)).toBeFalsy();
- expect(isSameBranchLike(pr, short)).toBeFalsy();
- expect(isSameBranchLike(pr, long)).toBeFalsy();
- expect(isSameBranchLike(short, long)).toBeFalsy();
+ expect(isSameBranchLike(main, foo1)).toBeFalsy();
+ expect(isSameBranchLike(main, foo)).toBeFalsy();
+ expect(isSameBranchLike(pr, foo1)).toBeFalsy();
+ expect(isSameBranchLike(pr, foo)).toBeFalsy();
+ expect(isSameBranchLike(foo1, foo)).toBeFalsy();
});
it('compares pull requests', () => {
@@ -129,23 +116,9 @@ describe('#isSameBranchLike', () => {
});
it('compares branches', () => {
- expect(
- isSameBranchLike(mockLongLivingBranch({ name: 'foo' }), mockLongLivingBranch({ name: 'foo' }))
- ).toBeTruthy();
- expect(
- isSameBranchLike(
- mockShortLivingBranch({ name: 'foo' }),
- mockShortLivingBranch({ name: 'foo' })
- )
- ).toBeTruthy();
- expect(
- isSameBranchLike(mockLongLivingBranch({ name: 'foo' }), mockLongLivingBranch({ name: 'bar' }))
- ).toBeFalsy();
- expect(
- isSameBranchLike(
- mockShortLivingBranch({ name: 'foo' }),
- mockShortLivingBranch({ name: 'bar' })
- )
- ).toBeFalsy();
+ expect(isSameBranchLike(mockBranch({ name: 'foo' }), mockBranch({ name: 'foo' }))).toBeTruthy();
+ expect(isSameBranchLike(mockBranch({ name: 'foo' }), mockBranch({ name: 'foo' }))).toBeTruthy();
+ expect(isSameBranchLike(mockBranch({ name: 'foo' }), mockBranch({ name: 'bar' }))).toBeFalsy();
+ expect(isSameBranchLike(mockBranch({ name: 'foo' }), mockBranch({ name: 'bar' }))).toBeFalsy();
});
});
diff --git a/server/sonar-web/src/main/js/helpers/branches.ts b/server/sonar-web/src/main/js/helpers/branch-like.ts
index 851cff80ff9..31da280cf59 100644
--- a/server/sonar-web/src/main/js/helpers/branches.ts
+++ b/server/sonar-web/src/main/js/helpers/branch-like.ts
@@ -19,50 +19,44 @@
*/
import { orderBy } from 'lodash';
-
-export function isBranch(branchLike?: T.BranchLike): branchLike is T.Branch {
- return branchLike !== undefined && (branchLike as T.Branch).isMain !== undefined;
-}
-
-export function isShortLivingBranch(branchLike?: T.BranchLike): branchLike is T.ShortLivingBranch {
- return (
- isBranch(branchLike) &&
- !branchLike.isMain &&
- (branchLike as T.ShortLivingBranch).type === 'SHORT'
- );
-}
-
-export function isLongLivingBranch(branchLike?: T.BranchLike): branchLike is T.LongLivingBranch {
- return (
- isBranch(branchLike) && !branchLike.isMain && (branchLike as T.LongLivingBranch).type === 'LONG'
- );
+import {
+ Branch,
+ BranchLike,
+ BranchLikeTree,
+ BranchParameters,
+ MainBranch,
+ PullRequest
+} from '../types/branch-like';
+
+export function isBranch(branchLike?: BranchLike): branchLike is Branch {
+ return branchLike !== undefined && (branchLike as Branch).isMain !== undefined;
}
-export function isMainBranch(branchLike?: T.BranchLike): branchLike is T.MainBranch {
+export function isMainBranch(branchLike?: BranchLike): branchLike is MainBranch {
return isBranch(branchLike) && branchLike.isMain;
}
-export function sortBranches(branches: T.Branch[]) {
+export function sortBranches(branches: Branch[]) {
return orderBy(branches, [b => b.isMain, b => b.name], ['desc', 'asc']);
}
-export function isPullRequest(branchLike?: T.BranchLike): branchLike is T.PullRequest {
- return branchLike !== undefined && (branchLike as T.PullRequest).key !== undefined;
+export function isPullRequest(branchLike?: BranchLike): branchLike is PullRequest {
+ return branchLike !== undefined && (branchLike as PullRequest).key !== undefined;
}
-export function sortPullRequests(pullRequests: T.PullRequest[]) {
+export function sortPullRequests(pullRequests: PullRequest[]) {
return orderBy(pullRequests, pr => getPullRequestDisplayName(pr));
}
-export function getPullRequestDisplayName(pullRequest: T.PullRequest) {
+export function getPullRequestDisplayName(pullRequest: PullRequest) {
return `${pullRequest.key} – ${pullRequest.title}`;
}
-export function getBranchLikeDisplayName(branchLike: T.BranchLike) {
+export function getBranchLikeDisplayName(branchLike: BranchLike) {
return isPullRequest(branchLike) ? getPullRequestDisplayName(branchLike) : branchLike.name;
}
-export function getBranchLikeKey(branchLike: T.BranchLike) {
+export function getBranchLikeKey(branchLike: BranchLike) {
return isPullRequest(branchLike) ? `pull-request-${branchLike.key}` : `branch-${branchLike.name}`;
}
@@ -78,18 +72,15 @@ export function getBranchQualityGateColor(status: string) {
return indicatorColor;
}
-export function isSameBranchLike(a: T.BranchLike | undefined, b: T.BranchLike | undefined) {
+export function isSameBranchLike(a: BranchLike | undefined, b: BranchLike | undefined) {
// main branches are always equal
if (isMainBranch(a) && isMainBranch(b)) {
return true;
}
- // short- and long-living branches are compared by type and name
- if (
- (isLongLivingBranch(a) && isLongLivingBranch(b)) ||
- (isShortLivingBranch(a) && isShortLivingBranch(b))
- ) {
- return a.type === b.type && a.name === b.name;
+ // Branches are compared by name
+ if (isBranch(a) && isBranch(b)) {
+ return a.name === b.name;
}
// pull requests are compared by id
@@ -101,7 +92,7 @@ export function isSameBranchLike(a: T.BranchLike | undefined, b: T.BranchLike |
return a === b;
}
-export function getBrancheLikesAsTree(branchLikes: T.BranchLike[]): T.BranchLikeTree {
+export function getBrancheLikesAsTree(branchLikes: BranchLike[]): BranchLikeTree {
const mainBranch = branchLikes.find(isMainBranch);
const branches = orderBy(branchLikes.filter(isBranch).filter(b => !isMainBranch(b)), b => b.name);
const pullRequests = orderBy(branchLikes.filter(isPullRequest), b => b.key);
@@ -110,7 +101,7 @@ export function getBrancheLikesAsTree(branchLikes: T.BranchLike[]): T.BranchLike
);
const orphanPullRequests = pullRequests.filter(pr => pr.isOrphan);
- const tree: T.BranchLikeTree = {
+ const tree: BranchLikeTree = {
branchTree: branches.map(b => ({ branch: b, pullRequests: getPullRequests(b) })),
parentlessPullRequests,
orphanPullRequests
@@ -125,13 +116,13 @@ export function getBrancheLikesAsTree(branchLikes: T.BranchLike[]): T.BranchLike
return tree;
- function getPullRequests(branch: T.Branch) {
+ function getPullRequests(branch: Branch) {
return pullRequests.filter(pr => !pr.isOrphan && pr.base === branch.name);
}
}
-export function getBranchLikeQuery(branchLike?: T.BranchLike): T.BranchParameters {
- if (isShortLivingBranch(branchLike) || isLongLivingBranch(branchLike)) {
+export function getBranchLikeQuery(branchLike?: BranchLike): BranchParameters {
+ if (isBranch(branchLike) && !isMainBranch(branchLike)) {
return { branch: branchLike.name };
} else if (isPullRequest(branchLike)) {
return { pullRequest: branchLike.key };
@@ -144,16 +135,14 @@ export function getBranchLikeQuery(branchLike?: T.BranchLike): T.BranchParameter
export function fillBranchLike(
branch?: string,
pullRequest?: string
-): T.ShortLivingBranch | T.PullRequest | undefined {
+): Branch | PullRequest | undefined {
if (branch) {
return {
isMain: false,
- mergeBranch: '',
- name: branch,
- type: 'SHORT'
- } as T.ShortLivingBranch;
+ name: branch
+ } as Branch;
} else if (pullRequest) {
- return { base: '', branch: '', key: pullRequest, title: '' } as T.PullRequest;
+ return { base: '', branch: '', key: pullRequest, title: '' } as PullRequest;
}
return undefined;
}
diff --git a/server/sonar-web/src/main/js/helpers/mocks/branch-pull-request.tsx b/server/sonar-web/src/main/js/helpers/mocks/branch-like.ts
index 1d2c53e92c7..ecf0e0c3874 100644
--- a/server/sonar-web/src/main/js/helpers/mocks/branch-pull-request.tsx
+++ b/server/sonar-web/src/main/js/helpers/mocks/branch-like.ts
@@ -18,23 +18,48 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import {
- mockLongLivingBranch,
- mockMainBranch,
- mockPullRequest,
- mockShortLivingBranch
-} from '../testMocks';
+import { Branch, BranchLike, MainBranch, PullRequest } from '../../types/branch-like';
-export function mockSetOfBranchAndPullRequest(): T.BranchLike[] {
+export function mockBranch(overrides: Partial<Branch> = {}): Branch {
+ return {
+ analysisDate: '2018-01-01',
+ excludedFromPurge: true,
+ isMain: false,
+ name: 'branch-6.7',
+ ...overrides
+ };
+}
+
+export function mockMainBranch(overrides: Partial<MainBranch> = {}): MainBranch {
+ return mockBranch({
+ isMain: true,
+ name: 'master',
+ ...overrides
+ }) as MainBranch;
+}
+
+export function mockPullRequest(overrides: Partial<PullRequest> = {}): PullRequest {
+ return {
+ analysisDate: '2018-01-01',
+ base: 'master',
+ branch: 'feature/foo/bar',
+ key: '1001',
+ target: 'master',
+ title: 'Foo Bar feature',
+ ...overrides
+ };
+}
+
+export function mockSetOfBranchAndPullRequest(): BranchLike[] {
return [
- mockShortLivingBranch({ name: 'slb-1' }),
- mockLongLivingBranch({ name: 'llb-1' }),
+ mockBranch({ name: 'branch-11' }),
+ mockBranch({ name: 'branch-1' }),
mockMainBranch(),
mockPullRequest({ key: '1', title: 'PR-1' }),
- mockShortLivingBranch({ name: 'slb-2', mergeBranch: 'llb-1' }),
+ mockBranch({ name: 'branch-12' }),
mockPullRequest({ key: '2', title: 'PR-2' }),
- mockLongLivingBranch({ name: 'llb-3' }),
- mockLongLivingBranch({ name: 'llb-2' }),
+ mockBranch({ name: 'branch-3' }),
+ mockBranch({ name: 'branch-2' }),
mockPullRequest({ key: '2', title: 'PR-2', target: 'llb-100', isOrphan: true })
];
}
diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts
index 7a296269754..8be68f81346 100644
--- a/server/sonar-web/src/main/js/helpers/testMocks.ts
+++ b/server/sonar-web/src/main/js/helpers/testMocks.ts
@@ -577,18 +577,6 @@ export function mockQualityGate(overrides: Partial<T.QualityGate> = {}): T.Quali
};
}
-export function mockPullRequest(overrides: Partial<T.PullRequest> = {}): T.PullRequest {
- return {
- analysisDate: '2018-01-01',
- base: 'master',
- branch: 'feature/foo/bar',
- key: '1001',
- target: 'master',
- title: 'Foo Bar feature',
- ...overrides
- };
-}
-
export function mockQualityProfile(overrides: Partial<Profile> = {}): Profile {
return {
activeDeprecatedRuleCount: 2,
@@ -738,20 +726,6 @@ export function mockRuleDetailsParameter(
};
}
-export function mockShortLivingBranch(
- overrides: Partial<T.ShortLivingBranch> = {}
-): T.ShortLivingBranch {
- return {
- analysisDate: '2018-01-01',
- excludedFromPurge: true,
- isMain: false,
- name: 'feature/foo',
- mergeBranch: 'master',
- type: 'SHORT',
- ...overrides
- };
-}
-
export function mockSourceViewerFile(
overrides: Partial<T.SourceViewerFile> = {}
): T.SourceViewerFile {
@@ -822,19 +796,6 @@ export function mockStandaloneSysInfo(overrides: Partial<any> = {}): T.SysInfoSt
};
}
-export function mockLongLivingBranch(
- overrides: Partial<T.LongLivingBranch> = {}
-): T.LongLivingBranch {
- return {
- analysisDate: '2018-01-01',
- excludedFromPurge: true,
- isMain: false,
- name: 'branch-6.7',
- type: 'LONG',
- ...overrides
- };
-}
-
export function mockStore(state: any = {}, reducer = (state: any) => state): Store {
return createStore(reducer, state);
}
@@ -885,16 +846,6 @@ export function mockDocumentationEntry(
};
}
-export function mockMainBranch(overrides: Partial<T.MainBranch> = {}): T.MainBranch {
- return {
- analysisDate: '2018-01-01',
- excludedFromPurge: true,
- isMain: true,
- name: 'master',
- ...overrides
- };
-}
-
export function mockLanguage(overrides: Partial<T.Language> = {}): T.Language {
return {
key: 'css',
diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts
index 11e34a1311c..e842be4f2c7 100644
--- a/server/sonar-web/src/main/js/helpers/urls.ts
+++ b/server/sonar-web/src/main/js/helpers/urls.ts
@@ -19,7 +19,8 @@
*/
import { getBaseUrl, Location } from 'sonar-ui-common/helpers/urls';
import { getProfilePath } from '../apps/quality-profiles/utils';
-import { getBranchLikeQuery, isBranch, isMainBranch, isPullRequest } from './branches';
+import { BranchLike } from '../types/branch-like';
+import { getBranchLikeQuery, isBranch, isMainBranch, isPullRequest } from './branch-like';
type Query = Location['query'];
@@ -39,21 +40,17 @@ export function getComponentBackgroundTaskUrl(componentKey: string, status?: str
return { pathname: '/project/background_tasks', query: { id: componentKey, status } };
}
-export function getBranchLikeUrl(project: string, branchLike?: T.BranchLike): Location {
+export function getBranchLikeUrl(project: string, branchLike?: BranchLike): Location {
if (isPullRequest(branchLike)) {
return getPullRequestUrl(project, branchLike.key);
} else if (isBranch(branchLike) && !isMainBranch(branchLike)) {
- return getShortLivingBranchUrl(project, branchLike.name);
+ return getBranchUrl(project, branchLike.name);
} else {
return getProjectUrl(project);
}
}
-export function getLongLivingBranchUrl(project: string, branch: string): Location {
- return { pathname: '/dashboard', query: { branch, id: project } };
-}
-
-export function getShortLivingBranchUrl(project: string, branch: string): Location {
+export function getBranchUrl(project: string, branch: string): Location {
return { pathname: '/dashboard', query: { branch, id: project } };
}
@@ -82,7 +79,7 @@ export function getComponentIssuesUrl(componentKey: string, query?: Query): Loca
export function getComponentDrilldownUrl(options: {
componentKey: string;
metric: string;
- branchLike?: T.BranchLike;
+ branchLike?: BranchLike;
selectionKey?: string;
treemapView?: boolean;
listView?: boolean;
@@ -105,7 +102,7 @@ export function getComponentDrilldownUrlWithSelection(
componentKey: string,
selectionKey: string,
metric: string,
- branchLike?: T.BranchLike
+ branchLike?: BranchLike
): Location {
return getComponentDrilldownUrl({ componentKey, selectionKey, metric, branchLike });
}
@@ -114,7 +111,7 @@ export function getMeasureTreemapUrl(componentKey: string, metric: string) {
return getComponentDrilldownUrl({ componentKey, metric, treemapView: true });
}
-export function getActivityUrl(component: string, branchLike?: T.BranchLike) {
+export function getActivityUrl(component: string, branchLike?: BranchLike) {
return {
pathname: '/project/activity',
query: { id: component, ...getBranchLikeQuery(branchLike) }
@@ -124,7 +121,7 @@ export function getActivityUrl(component: string, branchLike?: T.BranchLike) {
/**
* Generate URL for a component's measure history
*/
-export function getMeasureHistoryUrl(component: string, metric: string, branchLike?: T.BranchLike) {
+export function getMeasureHistoryUrl(component: string, metric: string, branchLike?: BranchLike) {
return {
pathname: '/project/activity',
query: {
@@ -196,7 +193,7 @@ export function getMarkdownHelpUrl(): string {
export function getCodeUrl(
project: string,
- branchLike?: T.BranchLike,
+ branchLike?: BranchLike,
selected?: string,
line?: number
) {
@@ -218,7 +215,7 @@ export function getHomePageUrl(homepage: T.HomePage) {
: getProjectUrl(homepage.component);
case 'PROJECT':
return homepage.branch
- ? getLongLivingBranchUrl(homepage.component, homepage.branch)
+ ? getBranchUrl(homepage.component, homepage.branch)
: getProjectUrl(homepage.component);
case 'ORGANIZATION':
return getOrganizationUrl(homepage.organization);
diff --git a/server/sonar-web/src/main/js/store/__tests__/branches-test.ts b/server/sonar-web/src/main/js/store/__tests__/branches-test.ts
index 875736d7a63..8d1067858d6 100644
--- a/server/sonar-web/src/main/js/store/__tests__/branches-test.ts
+++ b/server/sonar-web/src/main/js/store/__tests__/branches-test.ts
@@ -17,26 +17,23 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { getBranchLikeKey } from '../../helpers/branches';
-import {
- mockLongLivingBranch,
- mockPullRequest,
- mockQualityGateStatusCondition,
- mockShortLivingBranch
-} from '../../helpers/testMocks';
+import { getBranchLikeKey } from '../../helpers/branch-like';
+import { mockBranch, mockPullRequest } from '../../helpers/mocks/branch-like';
+import { mockQualityGateStatusCondition } from '../../helpers/testMocks';
+import { BranchLike } from '../../types/branch-like';
import reducer, {
getBranchStatusByBranchLike,
registerBranchStatusAction,
State
} from '../branches';
-type TestArgs = [T.BranchLike, string, T.Status, T.QualityGateStatusCondition[], boolean?];
+type TestArgs = [BranchLike, string, T.Status, T.QualityGateStatusCondition[], boolean?];
const FAILING_CONDITION = mockQualityGateStatusCondition();
const COMPONENT = 'foo';
const BRANCH_STATUS_1: TestArgs = [mockPullRequest(), COMPONENT, 'ERROR', [FAILING_CONDITION]];
-const BRANCH_STATUS_2: TestArgs = [mockLongLivingBranch(), 'bar', 'OK', [], true];
-const BRANCH_STATUS_3: TestArgs = [mockShortLivingBranch(), COMPONENT, 'OK', []];
+const BRANCH_STATUS_2: TestArgs = [mockBranch(), 'bar', 'OK', [], true];
+const BRANCH_STATUS_3: TestArgs = [mockBranch(), COMPONENT, 'OK', []];
it('should allow to register new branche statuses', () => {
const initialState: State = convertToState();
@@ -51,7 +48,7 @@ it('should allow to register new branche statuses', () => {
it('should allow to update branche statuses', () => {
const initialState: State = convertToState([BRANCH_STATUS_1, BRANCH_STATUS_2, BRANCH_STATUS_3]);
- const branchLike: T.BranchLike = { ...BRANCH_STATUS_1[0], status: { qualityGateStatus: 'OK' } };
+ const branchLike: BranchLike = { ...BRANCH_STATUS_1[0], status: { qualityGateStatus: 'OK' } };
const branchStatus: TestArgs = [branchLike, COMPONENT, 'OK', []];
const newState = reducer(initialState, registerBranchStatusAction(...branchStatus));
diff --git a/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx b/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx
index d4f9c887b64..10e24925393 100644
--- a/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx
+++ b/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx
@@ -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 { mockLongLivingBranch, mockQualityGateStatusCondition } from '../../helpers/testMocks';
+import { mockBranch } from '../../helpers/mocks/branch-like';
+import { mockQualityGateStatusCondition } from '../../helpers/testMocks';
import { registerBranchStatusAction } from '../branches';
import { fetchBranchStatus, registerBranchStatus } from '../rootActions';
@@ -47,7 +48,7 @@ jest.mock('../../api/quality-gates', () => {
});
describe('branch store actions', () => {
- const branchLike = mockLongLivingBranch();
+ const branchLike = mockBranch();
const component = 'foo';
const status = 'OK';
diff --git a/server/sonar-web/src/main/js/store/__tests__/rootReducers-test.tsx b/server/sonar-web/src/main/js/store/__tests__/rootReducers-test.tsx
index e55d671c55e..216cc9ce204 100644
--- a/server/sonar-web/src/main/js/store/__tests__/rootReducers-test.tsx
+++ b/server/sonar-web/src/main/js/store/__tests__/rootReducers-test.tsx
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { mockPullRequest } from '../../helpers/testMocks';
+import { mockPullRequest } from '../../helpers/mocks/branch-like';
import * as fromBranches from '../branches';
import { getBranchStatusByBranchLike, Store } from '../rootReducer';
diff --git a/server/sonar-web/src/main/js/store/branches.ts b/server/sonar-web/src/main/js/store/branches.ts
index fee3975287b..cfeb3dba46f 100644
--- a/server/sonar-web/src/main/js/store/branches.ts
+++ b/server/sonar-web/src/main/js/store/branches.ts
@@ -17,7 +17,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { getBranchLikeKey } from '../helpers/branches';
+import { getBranchLikeKey } from '../helpers/branch-like';
+import { BranchLike } from '../types/branch-like';
import { ActionType } from './utils/actions';
export interface BranchStatusData {
@@ -37,7 +38,7 @@ const enum Actions {
type Action = ActionType<typeof registerBranchStatusAction, Actions.RegisterBranchStatus>;
export function registerBranchStatusAction(
- branchLike: T.BranchLike,
+ branchLike: BranchLike,
component: string,
status: T.Status,
conditions?: T.QualityGateStatusCondition[],
@@ -78,7 +79,7 @@ export default function(state: State = { byComponent: {} }, action: Action): Sta
export function getBranchStatusByBranchLike(
state: State,
component: string,
- branchLike: T.BranchLike
+ branchLike: BranchLike
): BranchStatusData {
const branchLikeKey = getBranchLikeKey(branchLike);
return state.byComponent[component] && state.byComponent[component][branchLikeKey];
diff --git a/server/sonar-web/src/main/js/store/rootActions.ts b/server/sonar-web/src/main/js/store/rootActions.ts
index f77391118cb..1d18796935f 100644
--- a/server/sonar-web/src/main/js/store/rootActions.ts
+++ b/server/sonar-web/src/main/js/store/rootActions.ts
@@ -24,8 +24,9 @@ import { getLanguages } from '../api/languages';
import { getAllMetrics } from '../api/metrics';
import { getOrganization, getOrganizationNavigation, getOrganizations } from '../api/organizations';
import { getQualityGateProjectStatus } from '../api/quality-gates';
-import { getBranchLikeQuery } from '../helpers/branches';
+import { getBranchLikeQuery } from '../helpers/branch-like';
import { extractStatusConditionsFromProjectStatus } from '../helpers/qualityGates';
+import { BranchLike } from '../types/branch-like';
import { requireAuthorization as requireAuthorizationAction } from './appState';
import { registerBranchStatusAction } from './branches';
import { addGlobalErrorMessage } from './globalMessages';
@@ -65,7 +66,7 @@ export const fetchOrganization = (key: string) => (dispatch: Dispatch) => {
);
};
-export function fetchBranchStatus(branchLike: T.BranchLike, projectKey: string) {
+export function fetchBranchStatus(branchLike: BranchLike, projectKey: string) {
return (dispatch: Dispatch<any>) => {
getQualityGateProjectStatus({ projectKey, ...getBranchLikeQuery(branchLike) }).then(
projectStatus => {
@@ -114,11 +115,7 @@ export function requireAuthorization(router: Pick<InjectedRouter, 'replace'>) {
return requireAuthorizationAction();
}
-export function registerBranchStatus(
- branchLike: T.BranchLike,
- component: string,
- status: T.Status
-) {
+export function registerBranchStatus(branchLike: BranchLike, component: string, status: T.Status) {
return (dispatch: Dispatch) => {
dispatch(registerBranchStatusAction(branchLike, component, status));
};
diff --git a/server/sonar-web/src/main/js/store/rootReducer.ts b/server/sonar-web/src/main/js/store/rootReducer.ts
index e489bc707e1..3a6d8ab2c90 100644
--- a/server/sonar-web/src/main/js/store/rootReducer.ts
+++ b/server/sonar-web/src/main/js/store/rootReducer.ts
@@ -19,6 +19,7 @@
*/
import { combineReducers } from 'redux';
import settingsApp, * as fromSettingsApp from '../apps/settings/store/rootReducer';
+import { BranchLike } from '../types/branch-like';
import appState from './appState';
import branches, * as fromBranches from './branches';
import globalMessages, * as fromGlobalMessages from './globalMessages';
@@ -136,7 +137,7 @@ export function getSettingsAppValidationMessage(state: Store, key: string) {
export function getBranchStatusByBranchLike(
state: Store,
component: string,
- branchLike: T.BranchLike
+ branchLike: BranchLike
) {
return fromBranches.getBranchStatusByBranchLike(state.branches, component, branchLike);
}
diff --git a/server/sonar-web/src/main/js/types/branch-like.d.ts b/server/sonar-web/src/main/js/types/branch-like.d.ts
deleted file mode 100644
index e4b4eeb11a1..00000000000
--- a/server/sonar-web/src/main/js/types/branch-like.d.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2019 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.
- */
-
-declare namespace T {
- export type BranchType = 'LONG' | 'SHORT';
-
- export interface Branch {
- analysisDate?: string;
- excludedFromPurge: boolean;
- isMain: boolean;
- name: string;
- status?: { qualityGateStatus: Status };
- }
-
- export interface MainBranch extends Branch {
- isMain: true;
- }
-
- export interface LongLivingBranch extends Branch {
- isMain: false;
- type: 'LONG';
- }
-
- export interface ShortLivingBranch extends Branch {
- isMain: false;
- isOrphan?: true;
- mergeBranch: string;
- type: 'SHORT';
- }
-
- export interface PullRequest {
- analysisDate?: string;
- base: string;
- branch: string;
- key: string;
- isOrphan?: true;
- status?: { qualityGateStatus: Status };
- target: string;
- title: string;
- url?: string;
- }
-
- export type BranchLike = Branch | PullRequest;
-
- export interface BranchTree {
- branch: Branch;
- pullRequests: PullRequest[];
- }
-
- export interface BranchLikeTree {
- mainBranchTree?: BranchTree;
- branchTree: BranchTree[];
- parentlessPullRequests: PullRequest[];
- orphanPullRequests: PullRequest[];
- }
-
- export type BranchParameters = { branch?: string } | { pullRequest?: string };
-
- export interface BranchWithNewCodePeriod extends Branch {
- newCodePeriod?: NewCodePeriod;
- }
-}
diff --git a/server/sonar-web/src/main/js/types/branch-like.ts b/server/sonar-web/src/main/js/types/branch-like.ts
new file mode 100644
index 00000000000..fc01ebaaad1
--- /dev/null
+++ b/server/sonar-web/src/main/js/types/branch-like.ts
@@ -0,0 +1,63 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 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 interface Branch {
+ analysisDate?: string;
+ excludedFromPurge: boolean;
+ isMain: boolean;
+ name: string;
+ status?: { qualityGateStatus: T.Status };
+}
+
+export interface MainBranch extends Branch {
+ isMain: true;
+}
+
+export interface PullRequest {
+ analysisDate?: string;
+ base: string;
+ branch: string;
+ key: string;
+ isOrphan?: true;
+ status?: { qualityGateStatus: T.Status };
+ target: string;
+ title: string;
+ url?: string;
+}
+
+export type BranchLike = Branch | PullRequest;
+
+export interface BranchTree {
+ branch: Branch;
+ pullRequests: PullRequest[];
+}
+
+export interface BranchLikeTree {
+ mainBranchTree?: BranchTree;
+ branchTree: BranchTree[];
+ parentlessPullRequests: PullRequest[];
+ orphanPullRequests: PullRequest[];
+}
+
+export type BranchParameters = { branch?: string } | { pullRequest?: string };
+
+export interface BranchWithNewCodePeriod extends Branch {
+ newCodePeriod?: T.NewCodePeriod;
+}
diff --git a/server/sonar-web/src/main/js/types/types.d.ts b/server/sonar-web/src/main/js/types/types.d.ts
index 91d2c2b8e4e..bf1e9254dcd 100644
--- a/server/sonar-web/src/main/js/types/types.d.ts
+++ b/server/sonar-web/src/main/js/types/types.d.ts
@@ -944,7 +944,6 @@ declare namespace T {
export interface Task {
analysisId?: string;
branch?: string;
- branchType?: string;
componentKey?: string;
componentName?: string;
componentQualifier?: string;