]> source.dussan.org Git - sonarqube.git/commitdiff
Display settings menu for all type branches (still not for PR)
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Thu, 21 Nov 2019 14:07:25 +0000 (15:07 +0100)
committerSonarTech <sonartech@sonarsource.com>
Mon, 10 Feb 2020 19:46:13 +0000 (20:46 +0100)
server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMenu-test.tsx.snap

index 72030ec00cd6d93563a0bc0cd0779520b6979598..081582530b595be86b60348ea0a305675c7993a7 100644 (file)
@@ -198,7 +198,7 @@ export class ComponentNavMenu extends React.PureComponent<Props> {
   renderAdministration() {
     const { branchLike } = this.props;
 
-    if (!this.getConfiguration().showSettings || (branchLike && !isMainBranch(branchLike))) {
+    if (!this.getConfiguration().showSettings || isPullRequest(branchLike)) {
       return null;
     }
 
index 06362038183c5d7ea7dc4f2a6ff4ba808d96c4c9..bc27db6e1efd2c40141d0fc5535f0238571cd74c 100644 (file)
  */
 import { shallow } from 'enzyme';
 import * as React from 'react';
-import { mockBranch, mockMainBranch } from '../../../../../helpers/mocks/branch-like';
+import {
+  mockBranch,
+  mockMainBranch,
+  mockPullRequest
+} from '../../../../../helpers/mocks/branch-like';
 import { ComponentNavMenu } from '../ComponentNavMenu';
 
 const mainBranch = mockMainBranch();
@@ -122,6 +126,24 @@ it('should work for a branch', () => {
   );
 });
 
+it('should work for pull requests', () => {
+  [true, false].forEach(showSettings =>
+    expect(
+      shallow(
+        <ComponentNavMenu
+          appState={{ branchesEnabled: true }}
+          branchLike={mockPullRequest()}
+          component={{
+            ...baseComponent,
+            configuration: { showSettings },
+            extensions: [{ key: 'component-foo', name: 'ComponentFoo' }]
+          }}
+        />
+      )
+    ).toMatchSnapshot()
+  );
+});
+
 it('should work for all qualifiers', () => {
   ['TRK', 'VW', 'SVW', 'APP'].forEach(checkWithQualifier);
   expect.assertions(4);
index a9d856cf7c70fcd9fe904e690805a7c0580d46fa..940c071c2401bef331dc9c43c02d9b29f6782aa0 100644 (file)
@@ -147,6 +147,104 @@ exports[`should work for a branch 1`] = `
       project_activity.page
     </Link>
   </li>
+  <Dropdown
+    data-test="administration"
+    overlay={
+      <ul
+        className="menu"
+      >
+        <li>
+          <Link
+            activeClassName="active"
+            onlyActiveOnIndex={false}
+            style={Object {}}
+            to={
+              Object {
+                "pathname": "/project/settings",
+                "query": Object {
+                  "branch": "release",
+                  "id": "foo",
+                },
+              }
+            }
+          >
+            project_settings.page
+          </Link>
+        </li>
+        <li>
+          <Link
+            activeClassName="active"
+            onlyActiveOnIndex={false}
+            style={Object {}}
+            to={
+              Object {
+                "pathname": "/project/branches",
+                "query": Object {
+                  "id": "foo",
+                },
+              }
+            }
+          >
+            project_branch_pull_request.page
+          </Link>
+        </li>
+        <li>
+          <Link
+            activeClassName="active"
+            onlyActiveOnIndex={false}
+            style={Object {}}
+            to={
+              Object {
+                "pathname": "/project/baseline",
+                "query": Object {
+                  "id": "foo",
+                },
+              }
+            }
+          >
+            project_baseline.page
+          </Link>
+        </li>
+        <li>
+          <Link
+            activeClassName="active"
+            onlyActiveOnIndex={false}
+            style={Object {}}
+            to={
+              Object {
+                "pathname": "/project/webhooks",
+                "query": Object {
+                  "id": "foo",
+                },
+              }
+            }
+          >
+            webhooks.page
+          </Link>
+        </li>
+        <li>
+          <Link
+            activeClassName="active"
+            onlyActiveOnIndex={false}
+            style={Object {}}
+            to={
+              Object {
+                "pathname": "/project/deletion",
+                "query": Object {
+                  "id": "foo",
+                },
+              }
+            }
+          >
+            deletion.page
+          </Link>
+        </li>
+      </ul>
+    }
+    tagName="li"
+  >
+    <Component />
+  </Dropdown>
 </NavBarTabs>
 `;
 
@@ -822,6 +920,164 @@ exports[`should work for all qualifiers 4`] = `
 </NavBarTabs>
 `;
 
+exports[`should work for pull requests 1`] = `
+<NavBarTabs>
+  <li>
+    <Link
+      activeClassName="active"
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to={
+        Object {
+          "pathname": "/dashboard",
+          "query": Object {
+            "id": "foo",
+            "pullRequest": "1001",
+          },
+        }
+      }
+    >
+      overview.page
+    </Link>
+  </li>
+  <li>
+    <Link
+      activeClassName="active"
+      className=""
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to={
+        Object {
+          "pathname": "/project/issues",
+          "query": Object {
+            "id": "foo",
+            "pullRequest": "1001",
+            "resolved": "false",
+          },
+        }
+      }
+    >
+      issues.page
+    </Link>
+  </li>
+  <li>
+    <Link
+      activeClassName="active"
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to={
+        Object {
+          "pathname": "/component_measures",
+          "query": Object {
+            "id": "foo",
+            "pullRequest": "1001",
+          },
+        }
+      }
+    >
+      layout.measures
+    </Link>
+  </li>
+  <li>
+    <Link
+      activeClassName="active"
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to={
+        Object {
+          "pathname": "/code",
+          "query": Object {
+            "id": "foo",
+            "pullRequest": "1001",
+          },
+        }
+      }
+    >
+      code.page
+    </Link>
+  </li>
+</NavBarTabs>
+`;
+
+exports[`should work for pull requests 2`] = `
+<NavBarTabs>
+  <li>
+    <Link
+      activeClassName="active"
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to={
+        Object {
+          "pathname": "/dashboard",
+          "query": Object {
+            "id": "foo",
+            "pullRequest": "1001",
+          },
+        }
+      }
+    >
+      overview.page
+    </Link>
+  </li>
+  <li>
+    <Link
+      activeClassName="active"
+      className=""
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to={
+        Object {
+          "pathname": "/project/issues",
+          "query": Object {
+            "id": "foo",
+            "pullRequest": "1001",
+            "resolved": "false",
+          },
+        }
+      }
+    >
+      issues.page
+    </Link>
+  </li>
+  <li>
+    <Link
+      activeClassName="active"
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to={
+        Object {
+          "pathname": "/component_measures",
+          "query": Object {
+            "id": "foo",
+            "pullRequest": "1001",
+          },
+        }
+      }
+    >
+      layout.measures
+    </Link>
+  </li>
+  <li>
+    <Link
+      activeClassName="active"
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to={
+        Object {
+          "pathname": "/code",
+          "query": Object {
+            "id": "foo",
+            "pullRequest": "1001",
+          },
+        }
+      }
+    >
+      code.page
+    </Link>
+  </li>
+</NavBarTabs>
+`;
+
 exports[`should work with extensions 1`] = `
 <Dropdown
   data-test="extensions"