From: Wouter Admiraal Date: Wed, 6 Mar 2019 15:28:10 +0000 (+0100) Subject: SONAR-10994 Connect BranchStatus component to new branch store X-Git-Tag: 7.8~488 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c19e3ba3d999c51e3d7ef1d4b9f7ec3129a9a12f;p=sonarqube.git SONAR-10994 Connect BranchStatus component to new branch store --- diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenuItem.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenuItem.tsx index f05afbd4bfe..8455831806e 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenuItem.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenuItem.tsx @@ -69,7 +69,7 @@ export default function ComponentNavBranchesMenuItem({ branchLike, ...props }: P )}
- +
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx index 9eb4704aa43..f72338ef2e8 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx @@ -95,7 +95,7 @@ export function ComponentNavMeta({ branchLike, component, currentUser, warnings )} - + )} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranchesMenuItem-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranchesMenuItem-test.tsx.snap index 3d0620b4377..04c1bf0c791 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranchesMenuItem-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranchesMenuItem-test.tsx.snap @@ -42,13 +42,14 @@ exports[`renders main branch 1`] = `
-
@@ -97,7 +98,7 @@ exports[`renders short-living branch 1`] = `
-
@@ -158,7 +160,7 @@ exports[`renders short-living orhpan branch 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 efe7cceabd8..fdd4a833114 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 @@ -52,7 +52,7 @@ exports[`renders meta for pull request 1`] = ` size={12} /> - @@ -82,7 +83,7 @@ exports[`renders status of short-living branch 1`] = `
-
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx index 0bdf8ee4576..60011b07ab1 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx @@ -157,7 +157,7 @@ export default class BranchRow extends React.PureComponent { } render() { - const { branchLike, isOrphan } = this.props; + const { branchLike, component, isOrphan } = this.props; const indented = (isShortLivingBranch(branchLike) || isPullRequest(branchLike)) && !isOrphan; return ( @@ -173,7 +173,7 @@ export default class BranchRow extends React.PureComponent { )} - + {branchLike.analysisDate && } diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchRow-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchRow-test.tsx.snap index cc9f9c8b924..1a2b636607c 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchRow-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchRow-test.tsx.snap @@ -22,13 +22,14 @@ exports[`renders main branch 1`] = ` - - - ; + return ; } + +const mapStateToProps = (state: Store, { branchLike, component }: Props) => { + const status = getBranchStatusByBranchLike(state, component, branchLike); + return { status }; +}; + +export default connect(mapStateToProps)(BranchStatus); diff --git a/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx index c09200b9880..345a6ec8ae9 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx +++ b/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx @@ -19,18 +19,17 @@ */ import * as React from 'react'; import { shallow } from 'enzyme'; -import BranchStatus from '../BranchStatus'; +import { BranchStatus } from '../BranchStatus'; +import { mockLongLivingBranch } from '../../../helpers/testMocks'; it('should render correctly', () => { - const branch: T.MainBranch = { isMain: true, name: 'foo' }; - expect(getWrapper(branch).type()).toBeNull(); - expect(getWrapper(branch, 'OK')).toMatchSnapshot(); - expect(getWrapper(branch, 'ERROR')).toMatchSnapshot(); + expect(shallowRender().type()).toBeNull(); + expect(shallowRender('OK')).toMatchSnapshot(); + expect(shallowRender('ERROR')).toMatchSnapshot(); }); -function getWrapper(branch: T.MainBranch, qualityGateStatus?: string) { - if (qualityGateStatus) { - branch.status = { qualityGateStatus }; - } - return shallow(); +function shallowRender(status?: string) { + return shallow( + + ); }