From 5f0c85650faf2514b1c74fe6389a80574a415e39 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Mon, 27 Apr 2020 15:00:44 +0200 Subject: [PATCH] SONAR-13202 Fix homepage icon checked for main branch. --- .../components/nav/component/HeaderMeta.tsx | 6 ++- .../component/__tests__/HeaderMeta-test.tsx | 7 +++ .../__snapshots__/HeaderMeta-test.tsx.snap | 43 +++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) 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`] = `