diff options
author | Philippe Perrin <philippe.perrin@sonarsource.com> | 2019-11-14 14:48:12 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-12-09 20:46:17 +0100 |
commit | a98070323ef55ce3934a564e0cf49a5e8fe03971 (patch) | |
tree | 648a05d5f65f0f7755b6579beeed4bc7733de13a /server | |
parent | f13b0df538063f349e4fd50009cc826cda276252 (diff) | |
download | sonarqube-a98070323ef55ce3934a564e0cf49a5e8fe03971.tar.gz sonarqube-a98070323ef55ce3934a564e0cf49a5e8fe03971.zip |
SONAR-12636 Exlude branches from purge
Diffstat (limited to 'server')
59 files changed, 1699 insertions, 688 deletions
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 = () => <div />; -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`] = ` <withScrollTo(Component) branchLike={ Object { + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "feature", @@ -221,6 +222,7 @@ exports[`renders correctly for leak 1`] = ` <withScrollTo(Component) branchLike={ Object { + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "feature", 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 6be137a7735..2dbe1bb2b19 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 @@ -65,14 +65,25 @@ it('should render correctly for leak', () => { }); 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(<MeasureHeader branchLike={longBranch} {...PROPS} />).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( <MeasureHeader diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap index 8b6cc89cb9a..2cf9448032f 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap @@ -77,6 +77,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/issues/components/__tests__/__snapshots__/IssuesSourceViewer-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesSourceViewer-test.tsx.snap index 723c6c1aa3c..090eac8205a 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesSourceViewer-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesSourceViewer-test.tsx.snap @@ -6,6 +6,7 @@ exports[`should render CrossComponentSourceViewer correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -273,6 +274,7 @@ exports[`should render SourceViewer correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/ComponentSourceSnippetViewer-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/ComponentSourceSnippetViewer-test.tsx.snap index 136d07a4e9e..49f004c7337 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/ComponentSourceSnippetViewer-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/ComponentSourceSnippetViewer-test.tsx.snap @@ -8,6 +8,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/issues/crossComponentSourceViewer/__tests__/__snapshots__/SnippetViewer-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/SnippetViewer-test.tsx.snap index 1dccbb712e6..2a36a69cd18 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/SnippetViewer-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/SnippetViewer-test.tsx.snap @@ -24,6 +24,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -72,6 +73,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -133,6 +135,7 @@ exports[`should render correctly 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -231,6 +234,7 @@ exports[`should render correctly when at the bottom of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -279,6 +283,7 @@ exports[`should render correctly when at the bottom of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -340,6 +345,7 @@ exports[`should render correctly when at the bottom of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -401,6 +407,7 @@ exports[`should render correctly when at the bottom of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -488,6 +495,7 @@ exports[`should render correctly when at the top of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -536,6 +544,7 @@ exports[`should render correctly when at the top of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -597,6 +606,7 @@ exports[`should render correctly when at the top of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -658,6 +668,7 @@ exports[`should render correctly when at the top of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -719,6 +730,7 @@ exports[`should render correctly when at the top of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -780,6 +792,7 @@ exports[`should render correctly when at the top of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } @@ -841,6 +854,7 @@ exports[`should render correctly when at the top of the file 1`] = ` branchLike={ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", } 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 b356b45a78d..d911a9f1fa8 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 @@ -36,6 +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', 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( <QualityGateCondition - branchLike={{ isMain: false, name: 'feature' }} + branchLike={mockLongLivingBranch()} 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 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 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 ( <tr> - <td> + <td className="nowrap hide-overflow"> <BranchLikeIcon branchLike={branchLike} className="little-spacer-right" /> - {getBranchLikeDisplayName(branchLike)} - {isMainBranch(branchLike) && ( - <div className="badge spacer-left">{translate('branches.main_branch')}</div> - )} + <span title={branchLikeDisplayName}>{branchLikeDisplayName}</span> + <span> + {isMainBranch(branchLike) && ( + <div className="badge spacer-left">{translate('branches.main_branch')}</div> + )} + </span> </td> - <td className="thin nowrap"> + <td className="nowrap"> <BranchStatus branchLike={branchLike} component={component.key} /> </td> - <td className="thin nowrap text-right big-spacer-left"> + <td className="nowrap"> {branchLike.analysisDate && <DateFromNow date={branchLike.analysisDate} />} </td> - <td className="thin nowrap text-right"> - <ActionsDropdown className="big-spacer-left"> + {displayPurgeSetting && isBranch(branchLike) && ( + <td className="nowrap"> + <BranchPurgeSetting branch={branchLike} component={component} /> + </td> + )} + <td className="nowrap"> + <ActionsDropdown> {isMainBranch(branchLike) ? ( <ActionsDropdownItem className="js-rename" onClick={onRename}> {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 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 ( <div className="boxed-group boxed-group-inner"> - <table className="data zebra zebra-hover"> + <table className="data zebra zebra-hover fixed"> <thead> <tr> - <th>{tableTitle}</th> - <th className="thin nowrap">{translate('status')}</th> - <th className="thin nowrap text-right big-spacer-left"> + <th className="nowrap">{title}</th> + <th className="nowrap" style={{ width: '80px' }}> + {translate('status')} + </th> + <th className="nowrap" style={{ width: '140px' }}> {translate('project_branch_pull_request.last_analysis_date')} </th> - <th className="thin nowrap text-right">{translate('actions')}</th> + {displayPurgeSetting && ( + <th className="nowrap" style={{ width: '150px' }}> + <div className="display-flex-center"> + <span> + {translate( + 'project_branch_pull_request.branch.auto_deletion.keep_when_inactive' + )} + </span> + <HelpTooltip + className="little-spacer-left" + overlay={translate( + 'project_branch_pull_request.branch.auto_deletion.keep_when_inactive.tooltip' + )} + /> + </div> + </th> + )} + <th className="nowrap" style={{ width: '50px' }}> + {translate('actions')} + </th> </tr> </thead> <tbody> {branchLikes.map(branchLike => ( - <BranchLikeRowRenderer + <BranchLikeRow branchLike={branchLike} component={component} + displayPurgeSetting={displayPurgeSetting} key={getBranchLikeKey(branchLike)} onDelete={() => 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<Props, State> { 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 ( <> <BoxedTabs onSelect={this.onTabSelect} selected={currentTab} tabs={TABS} /> - <BranchLikeTableRenderer + <BranchLikeTable branchLikes={branchLikesToDisplay} component={component} + displayPurgeSetting={isBranchMode} onDelete={this.onDeleteBranchLike} onRename={this.onRenameBranchLike} - tableTitle={tableTitle} + title={title} /> {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<Props, State> { + 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 ( + <> + <Toggle disabled={disabled} onChange={this.handleOnChange} value={excludedFromPurge} /> + <span className="spacer-left"> + <DeferredSpinner loading={loading} /> + </span> + {isTheMainBranch && ( + <HelpTooltip + overlay={translate( + 'project_branch_pull_request.branch.auto_deletion.main_branch_tooltip' + )} + /> + )} + </> + ); + } +} 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 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<BranchLikeRowRendererProps>) { +function shallowRender(props?: Partial<BranchLikeRowProps>) { return shallow( - <BranchLikeRowRenderer + <BranchLikeRow branchLike={mockPullRequest()} component={mockComponent()} onDelete={jest.fn()} diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTableRenderer-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx index fc4b7087fcf..834c09db53e 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTableRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx @@ -22,20 +22,25 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockSetOfBranchAndPullRequest } from '../../../../helpers/mocks/branch-pull-request'; import { mockComponent } from '../../../../helpers/testMocks'; -import { BranchLikeRowRenderer } from '../BranchLikeRowRenderer'; -import { BranchLikeTableRenderer, BranchLikeTableRendererProps } from '../BranchLikeTableRenderer'; +import { BranchLikeRow } from '../BranchLikeRow'; +import { BranchLikeTable, BranchLikeTableProps } from '../BranchLikeTable'; it('should render correctly', () => { 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<BranchLikeTableRendererProps>) { +function shallowRender(props?: Partial<BranchLikeTableProps>) { return shallow( - <BranchLikeTableRenderer + <BranchLikeTable branchLikes={mockSetOfBranchAndPullRequest()} component={mockComponent()} onDelete={jest.fn()} onRename={jest.fn()} - tableTitle="tableTitle" + title="title" {...props} /> ); 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<BranchPurgeSetting['props']>) { + return shallow<BranchPurgeSetting>( + <BranchPurgeSetting + branch={mockLongLivingBranch({ excludedFromPurge: true })} + component={mockComponent()} + {...props} + /> + ); +} 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<RenameBranchModal>( <RenameBranchModal branch={branch} 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 e8e9f1ae6e8..f0cf79259bf 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 @@ -17,6 +17,7 @@ exports[`should render correctly 1`] = ` Array [ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -24,12 +25,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", }, @@ -43,6 +46,7 @@ exports[`should render correctly 1`] = ` }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "llb-1", "name": "slb-2", @@ -58,12 +62,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", 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 new file mode 100644 index 00000000000..aa1b8391809 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap @@ -0,0 +1,374 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly for long lived branch 1`] = ` +<tr> + <td + className="nowrap hide-overflow" + > + <BranchLikeIcon + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "name": "branch-6.7", + "type": "LONG", + } + } + className="little-spacer-right" + /> + <span + title="branch-6.7" + > + branch-6.7 + </span> + <span /> + </td> + <td + className="nowrap" + > + <Connect(BranchStatus) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "name": "branch-6.7", + "type": "LONG", + } + } + 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, + "name": "branch-6.7", + "type": "LONG", + } + } + 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> +`; + +exports[`should render correctly for main branch 1`] = ` +<tr> + <td + className="nowrap hide-overflow" + > + <BranchLikeIcon + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": true, + "name": "master", + } + } + className="little-spacer-right" + /> + <span + title="master" + > + master + </span> + <span> + <div + className="badge spacer-left" + > + branches.main_branch + </div> + </span> + </td> + <td + className="nowrap" + > + <Connect(BranchStatus) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": true, + "name": "master", + } + } + 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": true, + "name": "master", + } + } + 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-rename" + onClick={[MockFunction]} + > + project_branch_pull_request.branch.rename + </ActionsDropdownItem> + </ActionsDropdown> + </td> +</tr> +`; + +exports[`should render correctly for pull request 1`] = ` +<tr> + <td + className="nowrap hide-overflow" + > + <BranchLikeIcon + branchLike={ + Object { + "analysisDate": "2018-01-01", + "base": "master", + "branch": "feature/foo/bar", + "key": "1001", + "target": "master", + "title": "Foo Bar feature", + } + } + className="little-spacer-right" + /> + <span + title="1001 – Foo Bar feature" + > + 1001 – Foo Bar feature + </span> + <span /> + </td> + <td + className="nowrap" + > + <Connect(BranchStatus) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "base": "master", + "branch": "feature/foo/bar", + "key": "1001", + "target": "master", + "title": "Foo Bar feature", + } + } + component="my-project" + /> + </td> + <td + className="nowrap" + > + <DateFromNow + date="2018-01-01" + /> + </td> + <td + className="nowrap" + > + <ActionsDropdown> + <ActionsDropdownItem + className="js-delete" + destructive={true} + onClick={[MockFunction]} + > + project_branch_pull_request.pull_request.delete + </ActionsDropdownItem> + </ActionsDropdown> + </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__/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`] = ` -<tr> - <td> - <BranchLikeIcon - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": false, - "name": "branch-6.7", - "type": "LONG", - } - } - className="little-spacer-right" - /> - branch-6.7 - </td> - <td - className="thin nowrap" - > - <Connect(BranchStatus) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": false, - "name": "branch-6.7", - "type": "LONG", - } - } - component="my-project" - /> - </td> - <td - className="thin nowrap text-right big-spacer-left" - > - <DateFromNow - date="2018-01-01" - /> - </td> - <td - className="thin nowrap text-right" - > - <ActionsDropdown - className="big-spacer-left" - > - <ActionsDropdownItem - className="js-delete" - destructive={true} - onClick={[MockFunction]} - > - project_branch_pull_request.branch.delete - </ActionsDropdownItem> - </ActionsDropdown> - </td> -</tr> -`; - -exports[`should render correctly for mai branch 1`] = ` -<tr> - <td> - <BranchLikeIcon - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": true, - "name": "master", - } - } - className="little-spacer-right" - /> - master - <div - className="badge spacer-left" - > - branches.main_branch - </div> - </td> - <td - className="thin nowrap" - > - <Connect(BranchStatus) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": true, - "name": "master", - } - } - component="my-project" - /> - </td> - <td - className="thin nowrap text-right big-spacer-left" - > - <DateFromNow - date="2018-01-01" - /> - </td> - <td - className="thin nowrap text-right" - > - <ActionsDropdown - className="big-spacer-left" - > - <ActionsDropdownItem - className="js-rename" - onClick={[MockFunction]} - > - project_branch_pull_request.branch.rename - </ActionsDropdownItem> - </ActionsDropdown> - </td> -</tr> -`; - -exports[`should render correctly for pull request 1`] = ` -<tr> - <td> - <BranchLikeIcon - branchLike={ - Object { - "analysisDate": "2018-01-01", - "base": "master", - "branch": "feature/foo/bar", - "key": "1001", - "target": "master", - "title": "Foo Bar feature", - } - } - className="little-spacer-right" - /> - 1001 – Foo Bar feature - </td> - <td - className="thin nowrap" - > - <Connect(BranchStatus) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "base": "master", - "branch": "feature/foo/bar", - "key": "1001", - "target": "master", - "title": "Foo Bar feature", - } - } - component="my-project" - /> - </td> - <td - className="thin nowrap text-right big-spacer-left" - > - <DateFromNow - date="2018-01-01" - /> - </td> - <td - className="thin nowrap text-right" - > - <ActionsDropdown - className="big-spacer-left" - > - <ActionsDropdownItem - className="js-delete" - destructive={true} - onClick={[MockFunction]} - > - project_branch_pull_request.pull_request.delete - </ActionsDropdownItem> - </ActionsDropdown> - </td> -</tr> -`; - -exports[`should render correctly for short lived branch 1`] = ` -<tr> - <td> - <BranchLikeIcon - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": false, - "mergeBranch": "master", - "name": "feature/foo", - "type": "SHORT", - } - } - className="little-spacer-right" - /> - feature/foo - </td> - <td - className="thin nowrap" - > - <Connect(BranchStatus) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": false, - "mergeBranch": "master", - "name": "feature/foo", - "type": "SHORT", - } - } - component="my-project" - /> - </td> - <td - className="thin nowrap text-right big-spacer-left" - > - <DateFromNow - date="2018-01-01" - /> - </td> - <td - className="thin nowrap text-right" - > - <ActionsDropdown - className="big-spacer-left" - > - <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 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`] = ` +<div + className="boxed-group boxed-group-inner" +> + <table + className="data zebra zebra-hover fixed" + > + <thead> + <tr> + <th + className="nowrap" + > + title + </th> + <th + className="nowrap" + style={ + Object { + "width": "80px", + } + } + > + status + </th> + <th + className="nowrap" + style={ + Object { + "width": "140px", + } + } + > + project_branch_pull_request.last_analysis_date + </th> + <th + className="nowrap" + style={ + Object { + "width": "50px", + } + } + > + actions + </th> + </tr> + </thead> + <tbody> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "mergeBranch": "master", + "name": "slb-1", + "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 [], + } + } + key="branch-slb-1" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "name": "llb-1", + "type": "LONG", + } + } + 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 [], + } + } + key="branch-llb-1" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": true, + "name": "master", + } + } + 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 [], + } + } + key="branch-master" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "base": "master", + "branch": "feature/foo/bar", + "key": "1", + "target": "master", + "title": "PR-1", + } + } + 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 [], + } + } + key="pull-request-1" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "mergeBranch": "llb-1", + "name": "slb-2", + "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 [], + } + } + key="branch-slb-2" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "base": "master", + "branch": "feature/foo/bar", + "key": "2", + "target": "master", + "title": "PR-2", + } + } + 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 [], + } + } + key="pull-request-2" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "name": "llb-3", + "type": "LONG", + } + } + 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 [], + } + } + key="branch-llb-3" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "name": "llb-2", + "type": "LONG", + } + } + 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 [], + } + } + key="branch-llb-2" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "base": "master", + "branch": "feature/foo/bar", + "isOrphan": true, + "key": "2", + "target": "llb-100", + "title": "PR-2", + } + } + 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 [], + } + } + key="pull-request-2" + onDelete={[Function]} + onRename={[Function]} + /> + </tbody> + </table> +</div> +`; + +exports[`should render purge setting correctly 1`] = ` +<div + className="boxed-group boxed-group-inner" +> + <table + className="data zebra zebra-hover fixed" + > + <thead> + <tr> + <th + className="nowrap" + > + title + </th> + <th + className="nowrap" + style={ + Object { + "width": "80px", + } + } + > + status + </th> + <th + className="nowrap" + style={ + Object { + "width": "140px", + } + } + > + project_branch_pull_request.last_analysis_date + </th> + <th + className="nowrap" + style={ + Object { + "width": "150px", + } + } + > + <div + className="display-flex-center" + > + <span> + project_branch_pull_request.branch.auto_deletion.keep_when_inactive + </span> + <HelpTooltip + className="little-spacer-left" + overlay="project_branch_pull_request.branch.auto_deletion.keep_when_inactive.tooltip" + /> + </div> + </th> + <th + className="nowrap" + style={ + Object { + "width": "50px", + } + } + > + actions + </th> + </tr> + </thead> + <tbody> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "mergeBranch": "master", + "name": "slb-1", + "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 [], + } + } + displayPurgeSetting={true} + key="branch-slb-1" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "name": "llb-1", + "type": "LONG", + } + } + 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 [], + } + } + displayPurgeSetting={true} + key="branch-llb-1" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": true, + "name": "master", + } + } + 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 [], + } + } + displayPurgeSetting={true} + key="branch-master" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "base": "master", + "branch": "feature/foo/bar", + "key": "1", + "target": "master", + "title": "PR-1", + } + } + 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 [], + } + } + displayPurgeSetting={true} + key="pull-request-1" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "mergeBranch": "llb-1", + "name": "slb-2", + "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 [], + } + } + displayPurgeSetting={true} + key="branch-slb-2" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "base": "master", + "branch": "feature/foo/bar", + "key": "2", + "target": "master", + "title": "PR-2", + } + } + 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 [], + } + } + displayPurgeSetting={true} + key="pull-request-2" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "name": "llb-3", + "type": "LONG", + } + } + 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 [], + } + } + displayPurgeSetting={true} + key="branch-llb-3" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "excludedFromPurge": true, + "isMain": false, + "name": "llb-2", + "type": "LONG", + } + } + 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 [], + } + } + displayPurgeSetting={true} + key="branch-llb-2" + onDelete={[Function]} + onRename={[Function]} + /> + <Memo(BranchLikeRow) + branchLike={ + Object { + "analysisDate": "2018-01-01", + "base": "master", + "branch": "feature/foo/bar", + "isOrphan": true, + "key": "2", + "target": "llb-100", + "title": "PR-2", + } + } + 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 [], + } + } + displayPurgeSetting={true} + key="pull-request-2" + onDelete={[Function]} + onRename={[Function]} + /> + </tbody> + </table> +</div> +`; 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`] = ` -<div - className="boxed-group boxed-group-inner" -> - <table - className="data zebra zebra-hover" - > - <thead> - <tr> - <th> - tableTitle - </th> - <th - className="thin nowrap" - > - status - </th> - <th - className="thin nowrap text-right big-spacer-left" - > - project_branch_pull_request.last_analysis_date - </th> - <th - className="thin nowrap text-right" - > - actions - </th> - </tr> - </thead> - <tbody> - <Memo(BranchLikeRowRenderer) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": false, - "mergeBranch": "master", - "name": "slb-1", - "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 [], - } - } - key="branch-slb-1" - onDelete={[Function]} - onRename={[Function]} - /> - <Memo(BranchLikeRowRenderer) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": false, - "name": "llb-1", - "type": "LONG", - } - } - 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 [], - } - } - key="branch-llb-1" - onDelete={[Function]} - onRename={[Function]} - /> - <Memo(BranchLikeRowRenderer) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": true, - "name": "master", - } - } - 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 [], - } - } - key="branch-master" - onDelete={[Function]} - onRename={[Function]} - /> - <Memo(BranchLikeRowRenderer) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "base": "master", - "branch": "feature/foo/bar", - "key": "1", - "target": "master", - "title": "PR-1", - } - } - 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 [], - } - } - key="pull-request-1" - onDelete={[Function]} - onRename={[Function]} - /> - <Memo(BranchLikeRowRenderer) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": false, - "mergeBranch": "llb-1", - "name": "slb-2", - "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 [], - } - } - key="branch-slb-2" - onDelete={[Function]} - onRename={[Function]} - /> - <Memo(BranchLikeRowRenderer) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "base": "master", - "branch": "feature/foo/bar", - "key": "2", - "target": "master", - "title": "PR-2", - } - } - 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 [], - } - } - key="pull-request-2" - onDelete={[Function]} - onRename={[Function]} - /> - <Memo(BranchLikeRowRenderer) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": false, - "name": "llb-3", - "type": "LONG", - } - } - 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 [], - } - } - key="branch-llb-3" - onDelete={[Function]} - onRename={[Function]} - /> - <Memo(BranchLikeRowRenderer) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "isMain": false, - "name": "llb-2", - "type": "LONG", - } - } - 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 [], - } - } - key="branch-llb-2" - onDelete={[Function]} - onRename={[Function]} - /> - <Memo(BranchLikeRowRenderer) - branchLike={ - Object { - "analysisDate": "2018-01-01", - "base": "master", - "branch": "feature/foo/bar", - "isOrphan": true, - "key": "2", - "target": "llb-100", - "title": "PR-2", - } - } - 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 [], - } - } - key="pull-request-2" - onDelete={[Function]} - onRename={[Function]} - /> - </tbody> - </table> -</div> -`; 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`] = ` ] } /> - <Memo(BranchLikeTableRenderer) + <Memo(BranchLikeTable) branchLikes={ Array [ Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": true, "name": "master", }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-1", "type": "LONG", }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-2", "type": "LONG", }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "name": "llb-3", "type": "LONG", }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "master", "name": "slb-1", @@ -67,6 +72,7 @@ exports[`should render all tabs correctly 1`] = ` }, Object { "analysisDate": "2018-01-01", + "excludedFromPurge": true, "isMain": false, "mergeBranch": "llb-1", "name": "slb-2", @@ -97,9 +103,10 @@ exports[`should render all tabs correctly 1`] = ` "tags": Array [], } } + displayPurgeSetting={true} onDelete={[Function]} onRename={[Function]} - tableTitle="project_branch_pull_request.table.branch" + title="project_branch_pull_request.table.branch" /> </Fragment> `; @@ -136,7 +143,7 @@ exports[`should render all tabs correctly 2`] = ` ] } /> - <Memo(BranchLikeTableRenderer) + <Memo(BranchLikeTable) branchLikes={ Array [ Object { @@ -189,9 +196,10 @@ exports[`should render all tabs correctly 2`] = ` "tags": Array [], } } + displayPurgeSetting={false} onDelete={[Function]} onRename={[Function]} - tableTitle="project_branch_pull_request.table.pull_request" + title="project_branch_pull_request.table.pull_request" /> </Fragment> `; @@ -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`] = ` +<Fragment> + <Toggle + disabled={true} + onChange={[Function]} + value={true} + /> + <span + className="spacer-left" + > + <DeferredSpinner + loading={false} + timeout={100} + /> + </span> + <HelpTooltip + overlay="project_branch_pull_request.branch.auto_deletion.main_branch_tooltip" + /> +</Fragment> +`; + +exports[`should render correctly for a non-main branch 1`] = ` +<Fragment> + <Toggle + disabled={false} + onChange={[Function]} + value={true} + /> + <span + className="spacer-left" + > + <DeferredSpinner + loading={false} + timeout={100} + /> + </span> +</Fragment> +`; 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> = {}): 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" |