From e7f94d26ac27277aede3311afada6325cb1ce692 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Wed, 14 Apr 2021 10:29:45 +0200 Subject: [PATCH] SONAR-13713 Remove file and directory facet for App&Portfolio --- .../main/js/apps/issues/sidebar/Sidebar.tsx | 6 +- .../issues/sidebar/__tests__/Sidebar-test.tsx | 25 +++---- .../__snapshots__/Sidebar-test.tsx.snap | 66 +++++++++++++++++-- 3 files changed, 73 insertions(+), 24 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx index 18b359aba52..9a3fb12ed75 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx @@ -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 { 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 = { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx index a4cc3b26ef9..3a390895800 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx @@ -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', () => { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/Sidebar-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/Sidebar-test.tsx.snap index 5168fd8c58e..df5f5febae0 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/Sidebar-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/Sidebar-test.tsx.snap @@ -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", ] -- 2.39.5