]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9966 Page extensions are shown for branches
authorStas Vilchik <stas.vilchik@sonarsource.com>
Thu, 12 Oct 2017 11:50:33 +0000 (13:50 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 16 Oct 2017 09:08:02 +0000 (11:08 +0200)
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

index 0cee6379a785532351bbfd5f65a70aa2fbe56d9e..3d38f0517a62e5e621e3624d8a167cbc43d5c578 100644 (file)
@@ -434,13 +434,16 @@ export default class ComponentNavMenu extends React.PureComponent<Props> {
   };
 
   renderAdminExtensions() {
+    if (this.props.branch && !this.props.branch.isMain) {
+      return [];
+    }
     const extensions = this.getConfiguration().extensions || [];
     return extensions.map(e => this.renderExtension(e, true));
   }
 
   renderExtensions() {
     const extensions = this.props.component.extensions || [];
-    if (!extensions.length) {
+    if (!extensions.length || (this.props.branch && !this.props.branch.isMain)) {
       return null;
     }
 
index 8405e371da7bdb2024814d81a31b1110e1ae5d4f..68bb1f5c4581625e7eb2581fac4d7ead5950a7dc 100644 (file)
@@ -71,7 +71,11 @@ it('should work for short-living branches', () => {
     name: 'feature',
     type: BranchType.SHORT
   };
-  const component = { ...baseComponent, configuration: { showSettings: true } };
+  const component = {
+    ...baseComponent,
+    configuration: { showSettings: true },
+    extensions: [{ key: 'component-foo', name: 'ComponentFoo' }]
+  };
   expect(
     shallow(<ComponentNavMenu branch={branch} component={component} />, {
       context: { branchesEnabled: true }
@@ -86,7 +90,11 @@ it('should work for long-living branches', () => {
       shallow(
         <ComponentNavMenu
           branch={branch}
-          component={{ ...baseComponent, configuration: { showSettings } }}
+          component={{
+            ...baseComponent,
+            configuration: { showSettings },
+            extensions: [{ key: 'component-foo', name: 'ComponentFoo' }]
+          }}
         />,
         { context: { branchesEnabled: true } }
       )