]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13713 Remove file and directory facet for App&Portfolio
authorMathieu Suen <mathieu.suen@sonarsource.com>
Wed, 14 Apr 2021 08:29:45 +0000 (10:29 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 15 Apr 2021 20:03:43 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx
server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx
server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/Sidebar-test.tsx.snap

index 18b359aba5216f762f3f6283f3a60516ad8e1da2..9a3fb12ed75968637f8bcc50a740819c3787ca47 100644 (file)
@@ -21,7 +21,7 @@ import * as React from 'react';
 import { connect } from 'react-redux';
 import { getGlobalSettingValue, Store } from '../../../store/rootReducer';
 import { BranchLike } from '../../../types/branch-like';
-import { ComponentQualifier } from '../../../types/component';
+import { ComponentQualifier, isApplication, isPortfolioLike } from '../../../types/component';
 import {
   Facet,
   ReferencedComponent,
@@ -68,7 +68,9 @@ export interface Props {
 export class Sidebar extends React.PureComponent<Props> {
   renderComponentFacets() {
     const { component, facets, loadingFacets, openFacets, query, branchLike } = this.props;
-    if (!component) {
+    const hasFileOrDirectory =
+      !isApplication(component?.qualifier) && !isPortfolioLike(component?.qualifier);
+    if (!component || !hasFileOrDirectory) {
       return null;
     }
     const commonProps = {
index a4cc3b26ef92dd6f62deb8a7e863217c79ee8028..3a3908958003ab420416e7fec83aa10120024f13 100644 (file)
@@ -36,22 +36,15 @@ it('should render facets for project', () => {
   expect(renderSidebar({ component: mockComponent() })).toMatchSnapshot();
 });
 
-it('should render facets for module', () => {
-  expect(
-    renderSidebar({ component: mockComponent({ qualifier: ComponentQualifier.SubProject }) })
-  ).toMatchSnapshot();
-});
-
-it('should render facets for directory', () => {
-  expect(
-    renderSidebar({ component: mockComponent({ qualifier: ComponentQualifier.Directory }) })
-  ).toMatchSnapshot();
-});
-
-it('should render facets for developer', () => {
-  expect(
-    renderSidebar({ component: mockComponent({ qualifier: ComponentQualifier.Developper }) })
-  ).toMatchSnapshot();
+it.each([
+  [ComponentQualifier.Application],
+  [ComponentQualifier.Portfolio],
+  [ComponentQualifier.SubPortfolio],
+  [ComponentQualifier.SubProject],
+  [ComponentQualifier.Directory],
+  [ComponentQualifier.Developper]
+])('should render facets for %p', qualifier => {
+  expect(renderSidebar({ component: mockComponent({ qualifier }) })).toMatchSnapshot();
 });
 
 it('should render facets when my issues are selected', () => {
index 5168fd8c58efbe9887bbd4615f8857c6e9afd67b..df5f5febae0689161e01d675db9a2877f619bb16 100644 (file)
@@ -16,7 +16,7 @@ Array [
 ]
 `;
 
-exports[`should render facets for developer 1`] = `
+exports[`should render facets for "APP" 1`] = `
 Array [
   "TypeFacet",
   "SeverityFacet",
@@ -29,13 +29,50 @@ Array [
   "RuleFacet",
   "TagFacet",
   "ProjectFacet",
+  "AssigneeFacet",
+  "AuthorFacet",
+]
+`;
+
+exports[`should render facets for "BRC" 1`] = `
+Array [
+  "TypeFacet",
+  "SeverityFacet",
+  "ScopeFacet",
+  "ResolutionFacet",
+  "StatusFacet",
+  "StandardFacet",
+  "InjectIntl(CreationDateFacet)",
+  "Connect(LanguageFacet)",
+  "RuleFacet",
+  "TagFacet",
   "DirectoryFacet",
   "FileFacet",
   "AssigneeFacet",
+  "AuthorFacet",
 ]
 `;
 
-exports[`should render facets for directory 1`] = `
+exports[`should render facets for "DEV" 1`] = `
+Array [
+  "TypeFacet",
+  "SeverityFacet",
+  "ScopeFacet",
+  "ResolutionFacet",
+  "StatusFacet",
+  "StandardFacet",
+  "InjectIntl(CreationDateFacet)",
+  "Connect(LanguageFacet)",
+  "RuleFacet",
+  "TagFacet",
+  "ProjectFacet",
+  "DirectoryFacet",
+  "FileFacet",
+  "AssigneeFacet",
+]
+`;
+
+exports[`should render facets for "DIR" 1`] = `
 Array [
   "TypeFacet",
   "SeverityFacet",
@@ -53,7 +90,7 @@ Array [
 ]
 `;
 
-exports[`should render facets for global page 1`] = `
+exports[`should render facets for "SVW" 1`] = `
 Array [
   "TypeFacet",
   "SeverityFacet",
@@ -71,7 +108,7 @@ Array [
 ]
 `;
 
-exports[`should render facets for module 1`] = `
+exports[`should render facets for "VW" 1`] = `
 Array [
   "TypeFacet",
   "SeverityFacet",
@@ -83,8 +120,25 @@ Array [
   "Connect(LanguageFacet)",
   "RuleFacet",
   "TagFacet",
-  "DirectoryFacet",
-  "FileFacet",
+  "ProjectFacet",
+  "AssigneeFacet",
+  "AuthorFacet",
+]
+`;
+
+exports[`should render facets for global page 1`] = `
+Array [
+  "TypeFacet",
+  "SeverityFacet",
+  "ScopeFacet",
+  "ResolutionFacet",
+  "StatusFacet",
+  "StandardFacet",
+  "InjectIntl(CreationDateFacet)",
+  "Connect(LanguageFacet)",
+  "RuleFacet",
+  "TagFacet",
+  "ProjectFacet",
   "AssigneeFacet",
   "AuthorFacet",
 ]