]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13202 Fix homepage icon checked for main branch.
authorMathieu Suen <mathieu.suen@sonarsource.com>
Mon, 27 Apr 2020 13:00:44 +0000 (15:00 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 1 May 2020 20:03:42 +0000 (20:03 +0000)
server/sonar-web/src/main/js/app/components/nav/component/HeaderMeta.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/HeaderMeta-test.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/HeaderMeta-test.tsx.snap

index ab8275d6b5ecb96a860190843ccff516732bf700..5706d62927c8a3bf79a2cde587b12ba0425c862a 100644 (file)
@@ -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;
   }
index 871ba889cee3c62ec32c5f4bd9b99d123b0c6823..b918bdacb38ea404f3d9f53f40765600e3056a1a 100644 (file)
@@ -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 })
index 60e7f6c630cb9900ac804b261b21f27f65979c4a..4ad191b493cd7e5ba668d5d6d2a28f3da7524592 100644 (file)
@@ -43,6 +43,49 @@ exports[`should render correctly for a branch 1`] = `
 </Fragment>
 `;
 
+exports[`should render correctly for a main project branch 1`] = `
+<Fragment>
+  <div
+    className="display-flex-center flex-0 small"
+  >
+    <span
+      className="header-meta-warnings"
+    >
+      <ComponentNavWarnings
+        warnings={
+          Array [
+            "ERROR_1",
+            "ERROR_2",
+          ]
+        }
+      />
+    </span>
+    <span
+      className="spacer-left nowrap note"
+    >
+      <DateTimeFormatter
+        date="2017-01-02T00:00:00.000Z"
+      />
+    </span>
+    <span
+      className="spacer-left nowrap note"
+    >
+      version 0.0.1
+    </span>
+    <Connect(HomePageSelect)
+      className="spacer-left"
+      currentPage={
+        Object {
+          "branch": undefined,
+          "component": "my-project",
+          "type": "PROJECT",
+        }
+      }
+    />
+  </div>
+</Fragment>
+`;
+
 exports[`should render correctly for a portfolio 1`] = `
 <Fragment>
   <div