diff options
author | stanislavh <stanislav.honcharov@sonarsource.com> | 2023-04-21 14:56:17 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-04-25 20:03:00 +0000 |
commit | 3aa961cd6a7d63edb7ac011c27ec695dfb94c253 (patch) | |
tree | 43a1cae5fd31224a76457ed81e0c5bacfaf1fa1d /server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx | |
parent | fc5bd48d213b39a83a3828eaec1a9e89b5b88fbd (diff) | |
download | sonarqube-3aa961cd6a7d63edb7ac011c27ec695dfb94c253.tar.gz sonarqube-3aa961cd6a7d63edb7ac011c27ec695dfb94c253.zip |
SONAR-19069 Add Show more filters button
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx')
-rw-r--r-- | server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx index e315f8e0454..e27b23a5104 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx @@ -30,6 +30,7 @@ import { isDefined } from '../../../helpers/types'; 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 { @@ -43,6 +44,7 @@ interface Props { open: boolean; query: Query; stats: Facet | undefined; + forceShow: boolean; } const MAX_PATH_LENGTH = 15; @@ -75,7 +77,7 @@ export default class FileFacet extends React.PureComponent<Props> { }; loadSearchResultCount = (files: TreeComponentWithPath[]) => { - return this.props.loadSearchResultCount('files', { + return this.props.loadSearchResultCount(MetricKey.files, { files: files .map((file) => { return file.path; @@ -106,10 +108,16 @@ export default class FileFacet extends React.PureComponent<Props> { }; render() { + const { forceShow, files, fetching, open, query, stats } = this.props; + + if (files.length < 1 && !forceShow) { + return null; + } + return ( <ListStyleFacet<TreeComponentWithPath> facetHeader={translate('issues.facet.files')} - fetching={this.props.fetching} + fetching={fetching} getFacetItemText={this.getFacetItemText} getSearchResultKey={this.getSearchResultKey} getSearchResultText={this.getSearchResultText} @@ -118,14 +126,14 @@ export default class FileFacet extends React.PureComponent<Props> { onChange={this.props.onChange} onSearch={this.handleSearch} onToggle={this.props.onToggle} - open={this.props.open} - property="files" - query={omit(this.props.query, 'files')} + open={open} + property={MetricKey.files} + query={omit(query, MetricKey.files)} renderFacetItem={this.renderFacetItem} renderSearchResult={this.renderSearchResult} searchPlaceholder={translate('search.search_for_files')} - stats={this.props.stats} - values={this.props.files} + stats={stats} + values={files} /> ); } |