diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx')
-rw-r--r-- | server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx index b4888017813..00b1ae90115 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx @@ -29,6 +29,7 @@ import { highlightTerm } from '../../../helpers/search'; import { BranchLike } from '../../../types/branch-like'; import { TreeComponentWithPath } from '../../../types/component'; import { Facet } from '../../../types/issues'; +import { MetricKey } from '../../../types/metrics'; import { Query } from '../utils'; interface Props { @@ -42,6 +43,7 @@ interface Props { open: boolean; query: Query; stats: Facet | undefined; + forceShow: boolean; } export default class DirectoryFacet extends React.PureComponent<Props> { @@ -73,7 +75,7 @@ export default class DirectoryFacet extends React.PureComponent<Props> { }; loadSearchResultCount = (directories: TreeComponentWithPath[]) => { - return this.props.loadSearchResultCount('directories', { + return this.props.loadSearchResultCount(MetricKey.directories, { directories: directories.map((directory) => directory.path), }); }; @@ -94,10 +96,16 @@ export default class DirectoryFacet extends React.PureComponent<Props> { }; render() { + const { forceShow, directories, stats, fetching, open, query } = this.props; + + if (directories.length < 1 && !forceShow) { + return null; + } + return ( <ListStyleFacet<TreeComponentWithPath> facetHeader={translate('issues.facet.directories')} - fetching={this.props.fetching} + fetching={fetching} getFacetItemText={this.getFacetItemText} getSearchResultKey={this.getSearchResultKey} getSearchResultText={this.getSearchResultText} @@ -106,14 +114,14 @@ export default class DirectoryFacet extends React.PureComponent<Props> { onChange={this.props.onChange} onSearch={this.handleSearch} onToggle={this.props.onToggle} - open={this.props.open} - property="directories" - query={omit(this.props.query, 'directories')} + open={open} + property={MetricKey.directories} + query={omit(query, MetricKey.directories)} renderFacetItem={this.renderFacetItem} renderSearchResult={this.renderSearchResult} searchPlaceholder={translate('search.search_for_directories')} - stats={this.props.stats} - values={this.props.directories} + stats={stats} + values={directories} /> ); } |