From: Mathieu Suen Date: Mon, 27 Apr 2020 13:00:44 +0000 (+0200) Subject: SONAR-13202 Fix homepage icon checked for main branch. X-Git-Tag: 8.4.0.35506~238 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5f0c85650faf2514b1c74fe6389a80574a415e39;p=sonarqube.git SONAR-13202 Fix homepage icon checked for main branch. --- diff --git a/server/sonar-web/src/main/js/app/components/nav/component/HeaderMeta.tsx b/server/sonar-web/src/main/js/app/components/nav/component/HeaderMeta.tsx index ab8275d6b5e..5706d62927c 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/HeaderMeta.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/HeaderMeta.tsx @@ -90,6 +90,8 @@ export function HeaderMeta(props: HeaderMetaProps) { export function getCurrentPage(component: T.Component, branchLike: BranchLike | undefined) { let currentPage: T.HomePage | undefined; + const branch = isBranch(branchLike) && !branchLike.isMain ? branchLike.name : undefined; + switch (component.qualifier) { case ComponentQualifier.Portfolio: case ComponentQualifier.SubPortfolio: @@ -99,7 +101,7 @@ export function getCurrentPage(component: T.Component, branchLike: BranchLike | currentPage = { type: 'APPLICATION', component: component.key, - branch: isBranch(branchLike) ? branchLike.name : undefined + branch }; break; case ComponentQualifier.Project: @@ -107,7 +109,7 @@ export function getCurrentPage(component: T.Component, branchLike: BranchLike | currentPage = { type: 'PROJECT', component: component.key, - branch: isBranch(branchLike) ? branchLike.name : undefined + branch }; break; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/HeaderMeta-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/HeaderMeta-test.tsx index 871ba889cee..b918bdacb38 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/HeaderMeta-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/HeaderMeta-test.tsx @@ -30,6 +30,13 @@ it('should render correctly for a branch', () => { expect(wrapper).toMatchSnapshot(); }); +it('should render correctly for a main project branch', () => { + const wrapper = shallowRender({ + branchLike: mockBranch({ isMain: true }) + }); + expect(wrapper).toMatchSnapshot(); +}); + it('should render correctly for a portfolio', () => { const wrapper = shallowRender({ component: mockComponent({ key: 'foo', qualifier: ComponentQualifier.Portfolio }) diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/HeaderMeta-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/HeaderMeta-test.tsx.snap index 60e7f6c630c..4ad191b493c 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/HeaderMeta-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/HeaderMeta-test.tsx.snap @@ -43,6 +43,49 @@ exports[`should render correctly for a branch 1`] = ` `; +exports[`should render correctly for a main project branch 1`] = ` + +
+ + + + + + + + version 0.0.1 + + +
+
+`; + exports[`should render correctly for a portfolio 1`] = `