From a98070323ef55ce3934a564e0cf49a5e8fe03971 Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Thu, 14 Nov 2019 14:48:12 +0100 Subject: [PATCH] SONAR-12636 Exlude branches from purge --- server/sonar-docs/package.json | 2 +- server/sonar-docs/yarn.lock | 8 +- server/sonar-web/package.json | 2 +- server/sonar-web/src/main/js/api/branches.ts | 8 + .../__tests__/ComponentContainer-test.tsx | 4 +- .../__tests__/ComponentNavMenu-test.tsx | 11 +- .../ComponentNavHeader-test.tsx.snap | 9 + .../ComponentNavMeta-test.tsx.snap | 1 + .../BranchLikeNavigation-test.tsx.snap | 9 + .../CurrentBranchLike-test.tsx.snap | 6 + .../__snapshots__/Menu-test.tsx.snap | 14 + .../__snapshots__/MenuItem-test.tsx.snap | 2 + .../__snapshots__/MenuItemList-test.tsx.snap | 6 + .../components/__tests__/Components-test.tsx | 3 +- .../__snapshots__/Components-test.tsx.snap | 2 + .../__tests__/MeasureHeader-test.tsx | 15 +- .../__tests__/__snapshots__/App-test.tsx.snap | 1 + .../IssuesSourceViewer-test.tsx.snap | 2 + ...ComponentSourceSnippetViewer-test.tsx.snap | 1 + .../__snapshots__/SnippetViewer-test.tsx.snap | 14 + .../badges/__tests__/ProjectBadges-test.tsx | 1 + .../__snapshots__/EmptyOverview-test.tsx.snap | 6 + .../__snapshots__/OverviewApp-test.tsx.snap | 7 + .../events/__tests__/AnalysesList-test.tsx | 3 +- .../__snapshots__/Bugs-test.tsx.snap | 2 + .../__snapshots__/CodeSmells-test.tsx.snap | 4 + .../__snapshots__/Coverage-test.tsx.snap | 4 + .../__snapshots__/Duplications-test.tsx.snap | 4 + .../VulnerabilitiesAndHotspots-test.tsx.snap | 2 + .../MeasurementLabel-test.tsx.snap | 4 + .../__tests__/QualityGateCondition-test.tsx | 3 +- .../QualityGateCondition-test.tsx.snap | 1 + .../DefinitionChangeEventInner-test.tsx | 7 +- .../__tests__/BranchList-test.tsx | 1 + .../__snapshots__/BranchList-test.tsx.snap | 3 + ...hLikeRowRenderer.tsx => BranchLikeRow.tsx} | 43 +- ...eTableRenderer.tsx => BranchLikeTable.tsx} | 50 +- .../components/BranchLikeTabs.tsx | 34 +- .../components/BranchPurgeSetting.tsx | 102 +++ ...nderer-test.tsx => BranchLikeRow-test.tsx} | 14 +- ...erer-test.tsx => BranchLikeTable-test.tsx} | 19 +- .../__tests__/BranchLikeTabs-test.tsx | 12 +- .../__tests__/BranchPurgeSetting-test.tsx | 69 ++ .../__tests__/RenameBranchModal-test.tsx | 4 +- .../__tests__/__snapshots__/App-test.tsx.snap | 6 + .../__snapshots__/BranchLikeRow-test.tsx.snap | 374 ++++++++ .../BranchLikeRowRenderer-test.tsx.snap | 233 ----- .../BranchLikeTable-test.tsx.snap | 810 ++++++++++++++++++ .../BranchLikeTableRenderer-test.tsx.snap | 368 -------- .../BranchLikeTabs-test.tsx.snap | 17 +- .../BranchPurgeSetting-test.tsx.snap | 40 + .../SourceViewerBase-test.tsx.snap | 1 + .../__tests__/MeasuresOverlay-test.tsx | 1 + .../__snapshots__/LineCode-test.tsx.snap | 1 + .../__tests__/IssueTitleBar-test.tsx | 1 + .../sonar-web/src/main/js/helpers/branches.ts | 4 + .../src/main/js/helpers/testMocks.ts | 3 + .../src/main/js/types/branch-like.d.ts | 1 + server/sonar-web/yarn.lock | 8 +- .../resources/org/sonar/l10n/core.properties | 3 + 60 files changed, 1702 insertions(+), 688 deletions(-) rename server/sonar-web/src/main/js/apps/projectBranches/components/{BranchLikeRowRenderer.tsx => BranchLikeRow.tsx} (67%) rename server/sonar-web/src/main/js/apps/projectBranches/components/{BranchLikeTableRenderer.tsx => BranchLikeTable.tsx} (52%) create mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx rename server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/{BranchLikeRowRenderer-test.tsx => BranchLikeRow-test.tsx} (82%) rename server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/{BranchLikeTableRenderer-test.tsx => BranchLikeTable-test.tsx} (80%) create mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRowRenderer-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTableRenderer-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchPurgeSetting-test.tsx.snap diff --git a/server/sonar-docs/package.json b/server/sonar-docs/package.json index b9314c94180..8e827511fec 100644 --- a/server/sonar-docs/package.json +++ b/server/sonar-docs/package.json @@ -21,7 +21,7 @@ "react-dom": "16.8.6", "react-helmet": "5.2.0", "react-typography": "0.16.19", - "sonar-ui-common": "0.0.36", + "sonar-ui-common": "0.0.40", "typography": "0.16.19" }, "devDependencies": { diff --git a/server/sonar-docs/yarn.lock b/server/sonar-docs/yarn.lock index 9b3027e4877..6dc1ffe91e3 100644 --- a/server/sonar-docs/yarn.lock +++ b/server/sonar-docs/yarn.lock @@ -11158,10 +11158,10 @@ sockjs@0.3.19: faye-websocket "^0.10.0" uuid "^3.0.1" -sonar-ui-common@0.0.36: - version "0.0.36" - resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-0.0.36.tgz#30c4705d907f2453ce9a113af660bf4ff536af67" - integrity sha1-MMRwXZB/JFPOmhE69mC/T/U2r2c= +sonar-ui-common@0.0.40: + version "0.0.40" + resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-0.0.40.tgz#1b6ec48e74c74b84254669d0798216073b368cec" + integrity sha1-G27EjnTHS4QlRmnQeYIWBzs2jOw= dependencies: "@types/react-select" "1.2.6" classnames "2.2.6" diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 96f17935a0c..876948cc93e 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -38,7 +38,7 @@ "regenerator-runtime": "0.13.2", "remark-custom-blocks": "2.3.0", "remark-slug": "5.1.0", - "sonar-ui-common": "0.0.36", + "sonar-ui-common": "0.0.40", "unist-util-visit": "1.4.0", "valid-url": "1.0.9", "whatwg-fetch": "2.0.4" diff --git a/server/sonar-web/src/main/js/api/branches.ts b/server/sonar-web/src/main/js/api/branches.ts index 9985a20b04f..0bf62d734b6 100644 --- a/server/sonar-web/src/main/js/api/branches.ts +++ b/server/sonar-web/src/main/js/api/branches.ts @@ -42,3 +42,11 @@ export function deletePullRequest(data: { project: string; pullRequest: string } export function renameBranch(project: string, name: string) { return post('/api/project_branches/rename', { project, name }).catch(throwGlobalError); } + +export function excludeBranchFromPurge(projectKey: string, branchName: string, excluded: boolean) { + return post('/api/project_branches/set_automatic_deletion_protection', { + project: projectKey, + branch: branchName, + value: excluded + }).catch(throwGlobalError); +} 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 0af5a54b7a3..20a412bbee3 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 @@ -79,7 +79,7 @@ jest.mock('../nav/component/ComponentNav', () => ({ const Inner = () =>
; -const mainBranch: T.MainBranch = { isMain: true, name: 'master' }; +const mainBranch: T.MainBranch = mockMainBranch(); beforeEach(() => { jest.clearAllMocks(); @@ -88,7 +88,7 @@ beforeEach(() => { it('changes component', () => { const wrapper = shallowRender(); wrapper.setState({ - branchLikes: [{ isMain: true, name: 'master' }], + branchLikes: [mockMainBranch()], component: { qualifier: 'TRK', visibility: 'public' } as T.Component, loading: false }); 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 732501693d2..466d0c9c0e6 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,9 +19,10 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { mockMainBranch } from '../../../../../helpers/testMocks'; import { ComponentNavMenu } from '../ComponentNavMenu'; -const mainBranch: T.MainBranch = { isMain: true, name: 'master' }; +const mainBranch: T.MainBranch = mockMainBranch(); const baseComponent = { breadcrumbs: [], @@ -97,6 +98,7 @@ it('should render correctly for security extensions', () => { it('should work for short-living branches', () => { const branch: T.ShortLivingBranch = { isMain: false, + excludedFromPurge: true, mergeBranch: 'master', name: 'feature', type: 'SHORT' @@ -118,7 +120,12 @@ it('should work for short-living branches', () => { }); it('should work for long-living branches', () => { - const branch: T.LongLivingBranch = { isMain: false, name: 'release', type: 'LONG' }; + const branch: T.LongLivingBranch = { + excludedFromPurge: true, + isMain: false, + name: 'release', + type: 'LONG' + }; [true, false].forEach(showSettings => expect( shallow( 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 341033a7752..eb495bb4149 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 @@ -37,6 +37,7 @@ exports[`should render correctly 1`] = ` currentBranchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -49,6 +50,7 @@ exports[`should render correctly 1`] = ` Array [ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -56,12 +58,14 @@ exports[`should render correctly 1`] = ` }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-1", "type": "LONG", }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", }, @@ -75,6 +79,7 @@ exports[`should render correctly 1`] = ` }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "llb-1", "name": "slb-2", @@ -90,12 +95,14 @@ exports[`should render correctly 1`] = ` }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-3", "type": "LONG", }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-2", "type": "LONG", @@ -137,6 +144,7 @@ exports[`should render correctly 1`] = ` currentBranchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -148,6 +156,7 @@ exports[`should render correctly 1`] = ` currentBranchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", 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 81301515cef..190780d385d 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 @@ -102,6 +102,7 @@ exports[`#ComponentNavMeta renders status of short-living branch 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "feature/foo", 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 b235ccee944..1bae73bfd18 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 @@ -32,6 +32,7 @@ exports[`should render correctly 1`] = ` currentBranchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -56,6 +57,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` Array [ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -63,12 +65,14 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-1", "type": "LONG", }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", }, @@ -82,6 +86,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "llb-1", "name": "slb-2", @@ -97,12 +102,14 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-3", "type": "LONG", }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-2", "type": "LONG", @@ -144,6 +151,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` currentBranchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -187,6 +195,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` currentBranchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/CurrentBranchLike-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/CurrentBranchLike-test.tsx.snap index cd18a3b5b47..98676917267 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/CurrentBranchLike-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/CurrentBranchLike-test.tsx.snap @@ -8,6 +8,7 @@ exports[`CurrentBranchLikeRenderer should render correctly for application when branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -31,6 +32,7 @@ exports[`CurrentBranchLikeRenderer should render correctly for application when branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -53,6 +55,7 @@ exports[`CurrentBranchLikeRenderer should render correctly for application when branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -107,6 +110,7 @@ exports[`CurrentBranchLikeRenderer should render correctly for project when bran branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -138,6 +142,7 @@ exports[`CurrentBranchLikeRenderer should render correctly for project when ther branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -161,6 +166,7 @@ exports[`CurrentBranchLikeRenderer should render correctly for project when ther branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } 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 9455b556ffd..999f8552e96 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 @@ -26,6 +26,7 @@ exports[`should render correctly 1`] = ` Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-1", "type": "LONG", @@ -35,6 +36,7 @@ exports[`should render correctly 1`] = ` Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-2", "type": "LONG", @@ -44,6 +46,7 @@ exports[`should render correctly 1`] = ` Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-3", "type": "LONG", @@ -53,6 +56,7 @@ exports[`should render correctly 1`] = ` Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -63,6 +67,7 @@ exports[`should render correctly 1`] = ` Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "llb-1", "name": "slb-2", @@ -74,6 +79,7 @@ exports[`should render correctly 1`] = ` "mainBranchTree": Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", }, @@ -138,6 +144,7 @@ exports[`should render correctly 1`] = ` selectedBranchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -192,6 +199,7 @@ exports[`should render correctly with no current branch like 1`] = ` Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-1", "type": "LONG", @@ -201,6 +209,7 @@ exports[`should render correctly with no current branch like 1`] = ` Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-2", "type": "LONG", @@ -210,6 +219,7 @@ exports[`should render correctly with no current branch like 1`] = ` Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-3", "type": "LONG", @@ -219,6 +229,7 @@ exports[`should render correctly with no current branch like 1`] = ` Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -229,6 +240,7 @@ exports[`should render correctly with no current branch like 1`] = ` Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "llb-1", "name": "slb-2", @@ -240,6 +252,7 @@ exports[`should render correctly with no current branch like 1`] = ` "mainBranchTree": Object { "branch": Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", }, @@ -304,6 +317,7 @@ exports[`should render correctly with no current branch like 1`] = ` selectedBranchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/MenuItem-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/MenuItem-test.tsx.snap index 91ae3e4c65f..393f960966d 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/MenuItem-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/MenuItem-test.tsx.snap @@ -16,6 +16,7 @@ exports[`should render a main branch correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -39,6 +40,7 @@ exports[`should render a main branch correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } 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 891c36c58f6..96ce5bea8b6 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 @@ -17,6 +17,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -143,6 +144,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-1", "type": "LONG", @@ -181,6 +183,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-2", "type": "LONG", @@ -219,6 +222,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-3", "type": "LONG", @@ -257,6 +261,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -296,6 +301,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "llb-1", "name": "slb-2", 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 210667dcec3..6b3f69fb0ad 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 @@ -24,8 +24,9 @@ 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 = { +const BRANCH: T.ShortLivingBranch = { isMain: false, + excludedFromPurge: true, name: 'feature', mergeBranch: 'master', type: 'SHORT' 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 b7df151910c..80bb548aad6 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 @@ -178,6 +178,7 @@ exports[`renders correctly for leak 1`] = ` { }); it('should render with long living branch', () => { - const longBranch = { isMain: false, name: 'branch-6.7', type: 'LONG' }; + const longBranch: T.LongLivingBranch = { + isMain: false, + excludedFromPurge: true, + name: 'branch-6.7', + type: 'LONG' + }; expect( shallow().find('Link') ).toMatchSnapshot(); }); it('should render with short living branch', () => { - const shortBranch = { isMain: false, name: 'feature', mergeBranch: 'master', type: 'SHORT' }; + const shortBranch: T.ShortLivingBranch = { + isMain: false, + excludedFromPurge: true, + name: 'feature', + mergeBranch: 'master', + type: 'SHORT' + }; expect( shallow( ({ jest.mock('../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); const shortBranch: T.ShortLivingBranch = { + excludedFromPurge: true, isMain: false, mergeBranch: '', name: 'branch-6.6', diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap index f789b6aff75..99f1d1577a4 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap @@ -53,6 +53,7 @@ exports[`renders correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -105,6 +106,7 @@ exports[`should not render the tutorial 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -154,6 +156,7 @@ exports[`should render another message when there are branches 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -168,6 +171,7 @@ exports[`should render another message when there are branches 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -217,6 +221,7 @@ exports[`should render another message when there are branches 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -231,6 +236,7 @@ exports[`should render another message when there are branches 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/OverviewApp-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/OverviewApp-test.tsx.snap index 9ae1295b871..626c8770e47 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/OverviewApp-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/OverviewApp-test.tsx.snap @@ -27,6 +27,7 @@ exports[`should render correctly 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -100,6 +101,7 @@ exports[`should render correctly 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -211,6 +213,7 @@ exports[`should render correctly 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -322,6 +325,7 @@ exports[`should render correctly 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -433,6 +437,7 @@ exports[`should render correctly 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -544,6 +549,7 @@ exports[`should render correctly 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -660,6 +666,7 @@ exports[`should render correctly 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } 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 cf25a4e9c18..d2ebc93333a 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,10 +19,11 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { mockMainBranch } from '../../../../helpers/testMocks'; import AnalysesList from '../AnalysesList'; it('should render show more link', () => { - const branchLike = { analysisDate: '2018-03-08T09:49:22+0100', isMain: true, name: 'master' }; + const branchLike: T.MainBranch = mockMainBranch(); const component = { breadcrumbs: [{ key: 'foo', name: 'foo', qualifier: 'TRK' }], key: 'foo', diff --git a/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Bugs-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Bugs-test.tsx.snap index 99c1780ab27..83f8ef8442a 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Bugs-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Bugs-test.tsx.snap @@ -76,6 +76,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -189,6 +190,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } diff --git a/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/CodeSmells-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/CodeSmells-test.tsx.snap index dd190f58fd9..88d0a6bac8b 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/CodeSmells-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/CodeSmells-test.tsx.snap @@ -54,6 +54,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -74,6 +75,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -203,6 +205,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -223,6 +226,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } diff --git a/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Coverage-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Coverage-test.tsx.snap index b97d3dc9eb5..53140c34d90 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Coverage-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Coverage-test.tsx.snap @@ -61,6 +61,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -136,6 +137,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -199,6 +201,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -223,6 +226,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } diff --git a/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Duplications-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Duplications-test.tsx.snap index 62e46d36a2b..af8b3b669d3 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Duplications-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/Duplications-test.tsx.snap @@ -61,6 +61,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -112,6 +113,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -175,6 +177,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -199,6 +202,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } diff --git a/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/VulnerabilitiesAndHotspots-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/VulnerabilitiesAndHotspots-test.tsx.snap index 04386abdc13..ec2a9b4e238 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/VulnerabilitiesAndHotspots-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/overview/main/__tests__/__snapshots__/VulnerabilitiesAndHotspots-test.tsx.snap @@ -76,6 +76,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -232,6 +233,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } 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 5551434b586..c43c7b55818 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 @@ -14,6 +14,7 @@ exports[`should render correctly for coverage 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "feature/foo", @@ -47,6 +48,7 @@ exports[`should render correctly for coverage 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "feature/foo", @@ -70,6 +72,7 @@ exports[`should render correctly for coverage 2`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "feature/foo", @@ -102,6 +105,7 @@ exports[`should render correctly for duplications 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "feature/foo", 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 ad2e8b7c4cc..df7be90d0f0 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,6 +19,7 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { mockLongLivingBranch } from '../../../../helpers/testMocks'; import QualityGateCondition from '../QualityGateCondition'; const mockRatingCondition = (metric: string): T.QualityGateStatusConditionEnhanced => ({ @@ -136,7 +137,7 @@ it('should work with branch', () => { expect( shallow( 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 e94361e063d..8d3510f4397 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,6 +348,7 @@ 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/__tests__/DefinitionChangeEventInner-test.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx index c176bf584de..78a466328e9 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 @@ -43,7 +43,12 @@ it('should render', () => { }); it('should render for a branch', () => { - const branch: T.LongLivingBranch = { name: 'feature-x', isMain: false, type: 'LONG' }; + const branch: T.LongLivingBranch = { + excludedFromPurge: true, + name: 'feature-x', + isMain: false, + type: 'LONG' + }; const event: DefinitionChangeEvent = { category: 'DEFINITION_CHANGE', key: 'foo1234', 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 c74164771e5..3720e80afa3 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 @@ -88,6 +88,7 @@ it('should toggle popup', async () => { expect(wrapper.find('BranchBaselineSettingModal')).toHaveLength(0); expect(wrapper.state().branches.find(b => b.name === 'master')).toEqual({ analysisDate: '2018-01-01', + excludedFromPurge: true, isMain: true, name: 'master', newCodePeriod: { 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 96c102bf2ec..aad80809688 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 @@ -33,6 +33,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", "newCodePeriod": Object { @@ -83,6 +84,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "branch-6.7", "type": "LONG", @@ -119,6 +121,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "feature/foo", diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRowRenderer.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx similarity index 67% rename from server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRowRenderer.tsx rename to server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx index 34439e3e2cb..071cda5c964 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRowRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx @@ -26,35 +26,50 @@ import { translate } from 'sonar-ui-common/helpers/l10n'; import BranchStatus from '../../../components/common/BranchStatus'; import BranchLikeIcon from '../../../components/icons/BranchLikeIcon'; import DateFromNow from '../../../components/intl/DateFromNow'; -import { getBranchLikeDisplayName, isMainBranch, isPullRequest } from '../../../helpers/branches'; +import { + getBranchLikeDisplayName, + isBranch, + isMainBranch, + isPullRequest +} from '../../../helpers/branches'; +import BranchPurgeSetting from './BranchPurgeSetting'; -export interface BranchLikeRowRendererProps { +export interface BranchLikeRowProps { branchLike: T.BranchLike; component: T.Component; + displayPurgeSetting?: boolean; onDelete: () => void; onRename: () => void; } -export function BranchLikeRowRenderer(props: BranchLikeRowRendererProps) { - const { branchLike, component, onDelete, onRename } = props; +export function BranchLikeRow(props: BranchLikeRowProps) { + const { branchLike, component, displayPurgeSetting, onDelete, onRename } = props; + const branchLikeDisplayName = getBranchLikeDisplayName(branchLike); return ( - + - {getBranchLikeDisplayName(branchLike)} - {isMainBranch(branchLike) && ( -
{translate('branches.main_branch')}
- )} + {branchLikeDisplayName} + + {isMainBranch(branchLike) && ( +
{translate('branches.main_branch')}
+ )} +
- + - + {branchLike.analysisDate && } - - + {displayPurgeSetting && isBranch(branchLike) && ( + + + + )} + + {isMainBranch(branchLike) ? ( {translate('project_branch_pull_request.branch.rename')} @@ -74,4 +89,4 @@ export function BranchLikeRowRenderer(props: BranchLikeRowRendererProps) { ); } -export default React.memo(BranchLikeRowRenderer); +export default React.memo(BranchLikeRow); diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTableRenderer.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx similarity index 52% rename from server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTableRenderer.tsx rename to server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx index 2d4b6aa5b6f..d4b90ed5fdb 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTableRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx @@ -19,39 +19,63 @@ */ 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 BranchLikeRowRenderer from './BranchLikeRowRenderer'; +import BranchLikeRow from './BranchLikeRow'; -export interface BranchLikeTableRendererProps { - component: T.Component; - tableTitle: string; +export interface BranchLikeTableProps { branchLikes: T.BranchLike[]; + component: T.Component; + displayPurgeSetting?: boolean; onDelete: (branchLike: T.BranchLike) => void; onRename: (branchLike: T.BranchLike) => void; + title: string; } -export function BranchLikeTableRenderer(props: BranchLikeTableRendererProps) { - const { branchLikes, component, onDelete, onRename, tableTitle } = props; +export function BranchLikeTable(props: BranchLikeTableProps) { + const { branchLikes, component, displayPurgeSetting, onDelete, onRename, title } = props; return (
- +
- - - + + - + {displayPurgeSetting && ( + + )} + {branchLikes.map(branchLike => ( - onDelete(branchLike)} onRename={() => onRename(branchLike)} @@ -63,4 +87,4 @@ export function BranchLikeTableRenderer(props: BranchLikeTableRendererProps) { ); } -export default React.memo(BranchLikeTableRenderer); +export default React.memo(BranchLikeTable); 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 6be75430037..6e05bcbfcad 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 @@ -23,8 +23,14 @@ import BoxedTabs from 'sonar-ui-common/components/controls/BoxedTabs'; 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, isMainBranch, isPullRequest, sortBranches } from '../../../helpers/branches'; -import BranchLikeTableRenderer from './BranchLikeTableRenderer'; +import { + isBranch, + isMainBranch, + isPullRequest, + sortBranches, + sortPullRequests +} from '../../../helpers/branches'; +import BranchLikeTable from './BranchLikeTable'; import DeleteBranchModal from './DeleteBranchModal'; import RenameBranchModal from './RenameBranchModal'; @@ -92,27 +98,27 @@ export default class BranchLikeTabs extends React.PureComponent { const { branchLikes, component } = this.props; const { currentTab, deleting, renaming } = this.state; - let tableTitle = ''; - let branchLikesToDisplay: T.BranchLike[] = []; - - if (currentTab === Tabs.Branch) { - tableTitle = translate('project_branch_pull_request.table.branch'); - branchLikesToDisplay = sortBranches(branchLikes.filter(isBranch)); - } else if (currentTab === Tabs.PullRequest) { - tableTitle = translate('project_branch_pull_request.table.pull_request'); - branchLikesToDisplay = branchLikes.filter(isPullRequest); - } + const isBranchMode = currentTab === Tabs.Branch; + const branchLikesToDisplay: T.BranchLike[] = isBranchMode + ? sortBranches(branchLikes.filter(isBranch)) + : sortPullRequests(branchLikes.filter(isPullRequest)); + const title = translate( + isBranchMode + ? 'project_branch_pull_request.table.branch' + : 'project_branch_pull_request.table.pull_request' + ); return ( <> - {deleting && ( 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 new file mode 100644 index 00000000000..dfe91f278ce --- /dev/null +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx @@ -0,0 +1,102 @@ +/* + * 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. + */ + +import * as React from 'react'; +import HelpTooltip from 'sonar-ui-common/components/controls/HelpTooltip'; +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'; + +interface Props { + branch: T.Branch; + component: T.Component; +} + +interface State { + excludedFromPurge: boolean; + loading: boolean; +} + +export default class BranchPurgeSetting extends React.PureComponent { + mounted = false; + + constructor(props: Props) { + super(props); + + this.state = { excludedFromPurge: props.branch.excludedFromPurge, loading: false }; + } + + componentDidMount() { + this.mounted = true; + } + + componentWillUnmount() { + this.mounted = false; + } + + handleOnChange = () => { + const { branch, component } = this.props; + const { excludedFromPurge } = this.state; + const newValue = !excludedFromPurge; + + this.setState({ loading: true }); + + excludeBranchFromPurge(component.key, branch.name, newValue) + .then(() => { + if (this.mounted) { + this.setState({ + excludedFromPurge: newValue, + loading: false + }); + } + }) + .catch(() => { + if (this.mounted) { + this.setState({ loading: false }); + } + }); + }; + + render() { + const { branch } = this.props; + const { excludedFromPurge, loading } = this.state; + + const isTheMainBranch = isMainBranch(branch); + const disabled = isTheMainBranch || loading; + + return ( + <> + + + + + {isTheMainBranch && ( + + )} + + ); + } +} diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRowRenderer-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx similarity index 82% rename from server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRowRenderer-test.tsx rename to server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx index 15eb4004164..0c162b9d435 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRowRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx @@ -27,7 +27,7 @@ import { mockPullRequest, mockShortLivingBranch } from '../../../../helpers/testMocks'; -import { BranchLikeRowRenderer, BranchLikeRowRendererProps } from '../BranchLikeRowRenderer'; +import { BranchLikeRow, BranchLikeRowProps } from '../BranchLikeRow'; it('should render correctly for pull request', () => { const wrapper = shallowRender(); @@ -35,23 +35,23 @@ it('should render correctly for pull request', () => { }); it('should render correctly for short lived branch', () => { - const wrapper = shallowRender({ branchLike: mockShortLivingBranch() }); + const wrapper = shallowRender({ branchLike: mockShortLivingBranch(), displayPurgeSetting: true }); expect(wrapper).toMatchSnapshot(); }); it('should render correctly for long lived branch', () => { - const wrapper = shallowRender({ branchLike: mockLongLivingBranch() }); + const wrapper = shallowRender({ branchLike: mockLongLivingBranch(), displayPurgeSetting: true }); expect(wrapper).toMatchSnapshot(); }); -it('should render correctly for mai branch', () => { - const wrapper = shallowRender({ branchLike: mockMainBranch() }); +it('should render correctly for main branch', () => { + const wrapper = shallowRender({ branchLike: mockMainBranch(), displayPurgeSetting: true }); expect(wrapper).toMatchSnapshot(); }); -function shallowRender(props?: Partial) { +function shallowRender(props?: Partial) { return shallow( - { const wrapper = shallowRender(); expect(wrapper).toMatchSnapshot(); }); +it('should render purge setting correctly', () => { + const wrapper = shallowRender({ displayPurgeSetting: true }); + expect(wrapper).toMatchSnapshot(); +}); + it('should properly propagate delete event', () => { const onDelete = jest.fn(); const wrapper = shallowRender({ onDelete }); wrapper - .find(BranchLikeRowRenderer) + .find(BranchLikeRow) .first() .props() .onDelete(); @@ -49,7 +54,7 @@ it('should properly propagate rename event', () => { const wrapper = shallowRender({ onDelete, onRename }); wrapper - .find(BranchLikeRowRenderer) + .find(BranchLikeRow) .first() .props() .onRename(); @@ -57,14 +62,14 @@ it('should properly propagate rename event', () => { expect(onRename).toHaveBeenCalled(); }); -function shallowRender(props?: Partial) { +function shallowRender(props?: Partial) { return shallow( - ); 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 46f12e62b56..1fcf0a8ddbf 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 @@ -23,7 +23,7 @@ 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 { BranchLikeTableRenderer } from '../BranchLikeTableRenderer'; +import { BranchLikeTable } from '../BranchLikeTable'; import BranchLikeTabs, { Tabs } from '../BranchLikeTabs'; import DeleteBranchModal from '../DeleteBranchModal'; import RenameBranchModal from '../RenameBranchModal'; @@ -46,7 +46,7 @@ it('should render deletion modal correctly', () => { const wrapper = shallowRender({ onBranchesChange }); wrapper - .find(BranchLikeTableRenderer) + .find(BranchLikeTable) .props() .onDelete(mockPullRequest()); expect(wrapper.state().deleting).toBeDefined(); @@ -60,7 +60,7 @@ it('should render deletion modal correctly', () => { expect(wrapper.find(DeleteBranchModal).exists()).toBeFalsy(); wrapper - .find(BranchLikeTableRenderer) + .find(BranchLikeTable) .props() .onDelete(mockPullRequest()); wrapper @@ -77,7 +77,7 @@ it('should render renaming modal correctly', () => { const wrapper = shallowRender({ onBranchesChange }); wrapper - .find(BranchLikeTableRenderer) + .find(BranchLikeTable) .props() .onRename(mockMainBranch()); expect(wrapper.state().renaming).toBeDefined(); @@ -91,7 +91,7 @@ it('should render renaming modal correctly', () => { expect(wrapper.find(RenameBranchModal).exists()).toBeFalsy(); wrapper - .find(BranchLikeTableRenderer) + .find(BranchLikeTable) .props() .onRename(mockMainBranch()); wrapper @@ -107,7 +107,7 @@ it('should NOT render renaming modal for non-main branch', () => { const wrapper = shallowRender(); wrapper - .find(BranchLikeTableRenderer) + .find(BranchLikeTable) .props() .onRename(mockPullRequest()); expect(wrapper.state().renaming).toBeDefined(); 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 new file mode 100644 index 00000000000..bdac2023af4 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx @@ -0,0 +1,69 @@ +/* + * 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. + */ + +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 BranchPurgeSetting from '../BranchPurgeSetting'; + +jest.mock('../../../../api/branches', () => ({ + excludeBranchFromPurge: jest.fn().mockResolvedValue({}) +})); + +beforeEach(() => jest.clearAllMocks()); + +it('should render correctly for a non-main branch', () => { + const wrapper = shallowRender(); + expect(wrapper).toMatchSnapshot(); + expect(wrapper.state().excludedFromPurge).toBe(true); +}); + +it('should render correctly for a main branch', () => { + const wrapper = shallowRender({ branch: mockMainBranch({ excludedFromPurge: true }) }); + expect(wrapper).toMatchSnapshot(); + expect(wrapper.state().excludedFromPurge).toBe(true); +}); + +it('should correctly call the webservice if the user changes the value', () => { + const wrapper = shallowRender(); + expect(wrapper.state().excludedFromPurge).toBe(true); + + const { onChange } = wrapper.find(Toggle).props(); + + if (!onChange) { + fail(); + } else { + onChange(false); + expect(excludeBranchFromPurge).toHaveBeenCalled(); + expect(wrapper.state().excludedFromPurge).toBe(true); + } +}); + +function shallowRender(props?: Partial) { + return shallow( + + ); +} 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 b90c66b60f0..050ec427bb7 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,7 @@ 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 } from '../../../../helpers/testMocks'; +import { mockComponent, mockMainBranch } from '../../../../helpers/testMocks'; import RenameBranchModal from '../RenameBranchModal'; jest.mock('../../../../api/branches', () => ({ renameBranch: jest.fn() })); @@ -77,7 +77,7 @@ it('stops loading on WS error', async () => { }); function shallowRender(onRename: () => void = jest.fn(), onClose: () => void = jest.fn()) { - const branch: T.MainBranch = { isMain: true, name: 'master' }; + const branch = mockMainBranch(); const wrapper = shallow( + + + + + + +`; + +exports[`should render correctly for main branch 1`] = ` + + + + + + + +`; + +exports[`should render correctly for pull request 1`] = ` + + + + + + +`; + +exports[`should render correctly for short lived branch 1`] = ` + + + + + + + +`; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRowRenderer-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRowRenderer-test.tsx.snap deleted file mode 100644 index 3cc09481ada..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRowRenderer-test.tsx.snap +++ /dev/null @@ -1,233 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for long lived branch 1`] = ` - - - - - - -`; - -exports[`should render correctly for mai branch 1`] = ` - - - - - - -`; - -exports[`should render correctly for pull request 1`] = ` - - - - - - -`; - -exports[`should render correctly for short lived branch 1`] = ` - - - - - - -`; 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 new file mode 100644 index 00000000000..f56120ef7c5 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap @@ -0,0 +1,810 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +
+
{tableTitle}{translate('status')} + {title} + {translate('status')} + {translate('project_branch_pull_request.last_analysis_date')} {translate('actions')} +
+ + {translate( + 'project_branch_pull_request.branch.auto_deletion.keep_when_inactive' + )} + + +
+
+ {translate('actions')} +
+ + + branch-6.7 + + + + + + + + + + + + project_branch_pull_request.branch.delete + + +
+ + + master + + +
+ branches.main_branch +
+
+
+ + + + + + + + + project_branch_pull_request.branch.rename + + +
+ + + 1001 – Foo Bar feature + + + + + + + + + + project_branch_pull_request.pull_request.delete + + +
+ + + feature/foo + + + + + + + + + + + + project_branch_pull_request.branch.delete + + +
- - branch-6.7 - - - - - - - - project_branch_pull_request.branch.delete - - -
- - master -
- branches.main_branch -
-
- - - - - - - project_branch_pull_request.branch.rename - - -
- - 1001 – Foo Bar feature - - - - - - - - project_branch_pull_request.pull_request.delete - - -
- - feature/foo - - - - - - - - project_branch_pull_request.branch.delete - - -
+ + + + + + + + + + + + + + + + + + + +
+ title + + status + + project_branch_pull_request.last_analysis_date + + actions +
+
+`; + +exports[`should render purge setting correctly 1`] = ` +
+ + + + + + + + + + + + + + + + + + + + + +
+ title + + status + + project_branch_pull_request.last_analysis_date + +
+ + project_branch_pull_request.branch.auto_deletion.keep_when_inactive + + +
+
+ actions +
+
+`; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTableRenderer-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTableRenderer-test.tsx.snap deleted file mode 100644 index c26c41e5225..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTableRenderer-test.tsx.snap +++ /dev/null @@ -1,368 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
- - - - - - - - - - - - - - - - - - - - -
- tableTitle - - status - - project_branch_pull_request.last_analysis_date - - actions -
-
-`; 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 941f087638b..805b5566eb6 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 @@ -32,34 +32,39 @@ exports[`should render all tabs correctly 1`] = ` ] } /> - `; @@ -136,7 +143,7 @@ exports[`should render all tabs correctly 2`] = ` ] } /> - `; @@ -241,6 +249,7 @@ exports[`should render renaming modal correctly 1`] = ` branch={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchPurgeSetting-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchPurgeSetting-test.tsx.snap new file mode 100644 index 00000000000..f5c556b606c --- /dev/null +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchPurgeSetting-test.tsx.snap @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly for a main branch 1`] = ` + + + + + + + +`; + +exports[`should render correctly for a non-main branch 1`] = ` + + + + + + +`; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerBase-test.tsx.snap b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerBase-test.tsx.snap index 91750341a24..8b0b0958b9f 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerBase-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerBase-test.tsx.snap @@ -5,6 +5,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } 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 1c831cf717f..c2a0cad7bf9 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 @@ -151,6 +151,7 @@ const sourceViewerFile: T.SourceViewerFile = { const branchLike: T.ShortLivingBranch = { isMain: false, + excludedFromPurge: true, mergeBranch: 'master', name: 'feature', type: 'SHORT' 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 cffede6b404..384c3c1e53b 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 @@ -45,6 +45,7 @@ exports[`render code 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "feature/foo", 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 1699912d706..32c7e440977 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 @@ -28,6 +28,7 @@ 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' diff --git a/server/sonar-web/src/main/js/helpers/branches.ts b/server/sonar-web/src/main/js/helpers/branches.ts index 9e3c705e225..851cff80ff9 100644 --- a/server/sonar-web/src/main/js/helpers/branches.ts +++ b/server/sonar-web/src/main/js/helpers/branches.ts @@ -50,6 +50,10 @@ export function isPullRequest(branchLike?: T.BranchLike): branchLike is T.PullRe return branchLike !== undefined && (branchLike as T.PullRequest).key !== undefined; } +export function sortPullRequests(pullRequests: T.PullRequest[]) { + return orderBy(pullRequests, pr => getPullRequestDisplayName(pr)); +} + export function getPullRequestDisplayName(pullRequest: T.PullRequest) { return `${pullRequest.key} – ${pullRequest.title}`; } diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts index 6f03f437b11..7a296269754 100644 --- a/server/sonar-web/src/main/js/helpers/testMocks.ts +++ b/server/sonar-web/src/main/js/helpers/testMocks.ts @@ -743,6 +743,7 @@ export function mockShortLivingBranch( ): T.ShortLivingBranch { return { analysisDate: '2018-01-01', + excludedFromPurge: true, isMain: false, name: 'feature/foo', mergeBranch: 'master', @@ -826,6 +827,7 @@ export function mockLongLivingBranch( ): T.LongLivingBranch { return { analysisDate: '2018-01-01', + excludedFromPurge: true, isMain: false, name: 'branch-6.7', type: 'LONG', @@ -886,6 +888,7 @@ export function mockDocumentationEntry( export function mockMainBranch(overrides: Partial = {}): T.MainBranch { return { analysisDate: '2018-01-01', + excludedFromPurge: true, isMain: true, name: 'master', ...overrides 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 index 5b83375ca32..e4b4eeb11a1 100644 --- a/server/sonar-web/src/main/js/types/branch-like.d.ts +++ b/server/sonar-web/src/main/js/types/branch-like.d.ts @@ -23,6 +23,7 @@ declare namespace T { export interface Branch { analysisDate?: string; + excludedFromPurge: boolean; isMain: boolean; name: string; status?: { qualityGateStatus: Status }; diff --git a/server/sonar-web/yarn.lock b/server/sonar-web/yarn.lock index 95350f12b1f..46c5f182910 100644 --- a/server/sonar-web/yarn.lock +++ b/server/sonar-web/yarn.lock @@ -9457,10 +9457,10 @@ sockjs@0.3.19: faye-websocket "^0.10.0" uuid "^3.0.1" -sonar-ui-common@0.0.36: - version "0.0.36" - resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-0.0.36.tgz#30c4705d907f2453ce9a113af660bf4ff536af67" - integrity sha1-MMRwXZB/JFPOmhE69mC/T/U2r2c= +sonar-ui-common@0.0.40: + version "0.0.40" + resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-0.0.40.tgz#1b6ec48e74c74b84254669d0798216073b368cec" + integrity sha1-G27EjnTHS4QlRmnQeYIWBzs2jOw= dependencies: "@types/react-select" "1.2.6" classnames "2.2.6" diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index b97a782d043..27e8b2bb8d8 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -540,6 +540,9 @@ project_branch_pull_request.lifetime_information.admin=You can adjust this value project_branch_pull_request.branch.rename=Rename branch project_branch_pull_request.branch.delete=Delete branch project_branch_pull_request.branch.delete.are_you_sure=Are you sure you want to delete branch "{0}"? +project_branch_pull_request.branch.auto_deletion.keep_when_inactive=Keep when inactive +project_branch_pull_request.branch.auto_deletion.keep_when_inactive.tooltip=When turned on, the branch will not be automatically deleted when inactive. +project_branch_pull_request.branch.auto_deletion.main_branch_tooltip=The main branch is always excluded from automatic deletion. project_branch_pull_request.pull_request.delete=Delete Pull Request project_branch_pull_request.pull_request.delete.are_you_sure=Are you sure you want to delete Pull Request "{0}"? project_branch_pull_request.tabs.branches=Branches -- 2.39.5