From 4e9feaddc45af56194e90e941d591bc465add571 Mon Sep 17 00:00:00 2001 From: Pascal Mugnier Date: Mon, 9 Jul 2018 13:45:36 +0200 Subject: [PATCH] SONAR-10808 Add the ability fo filter projects by visibility --- .../main/js/apps/projectsManagement/App.tsx | 24 +++++++- .../js/apps/projectsManagement/Search.tsx | 28 ++++++++- .../__tests__/Search-test.tsx | 1 + .../__snapshots__/Search-test.tsx.snap | 58 +++++++++++++++++++ .../resources/org/sonar/l10n/core.properties | 1 + 5 files changed, 108 insertions(+), 4 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx index 978feca7bba..34d6db3ebae 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx @@ -28,7 +28,7 @@ import { PAGE_SIZE, Project } from './utils'; import ListFooter from '../../components/controls/ListFooter'; import Suggestions from '../../app/components/embed-docs-modal/Suggestions'; import { getComponents } from '../../api/components'; -import { Organization } from '../../app/types'; +import { Organization, Visibility } from '../../app/types'; import { toNotSoISOString } from '../../helpers/dates'; import { translate } from '../../helpers/l10n'; @@ -51,6 +51,7 @@ interface State { ready: boolean; selection: string[]; total: number; + visibility?: Visibility; } export default class App extends React.PureComponent { @@ -90,7 +91,8 @@ export default class App extends React.PureComponent { p: this.state.page !== 1 ? this.state.page : undefined, ps: PAGE_SIZE, q: this.state.query || undefined, - qualifiers: this.state.qualifiers + qualifiers: this.state.qualifiers, + visibility: this.state.visibility }; getComponents(parameters).then(r => { if (this.mounted) { @@ -132,6 +134,20 @@ export default class App extends React.PureComponent { ); }; + onVisibilityChanged = (newVisibility: Visibility | 'all') => { + this.setState( + { + ready: false, + page: 1, + provisioned: false, + query: '', + visibility: newVisibility === 'all' ? undefined : newVisibility, + selection: [] + }, + this.requestProjects + ); + }; + handleDateChanged = (analyzedBefore: Date | undefined) => this.setState({ ready: false, page: 1, analyzedBefore }, this.requestProjects); @@ -177,13 +193,14 @@ export default class App extends React.PureComponent { { selection={this.state.selection} topLevelQualifiers={this.props.topLevelQualifiers} total={this.state.total} + visibility={this.state.visibility} /> void; onProvisionedChanged: (provisioned: boolean) => void; onQualifierChanged: (qualifier: string) => void; + onVisibilityChanged: (qualifier: string) => void; onSearch: (query: string) => void; organization: Organization; projects: Project[]; @@ -50,6 +51,7 @@ export interface Props { selection: any[]; topLevelQualifiers: string[]; total: number; + visibility?: Visibility; } interface State { @@ -100,6 +102,8 @@ export default class Search extends React.PureComponent { handleQualifierChange = ({ value }: { value: string }) => this.props.onQualifierChanged(value); + handleVisibilityChange = ({ value }: { value: string }) => this.props.onVisibilityChanged(value); + renderCheckbox = () => { const isAllChecked = this.props.projects.length > 0 && this.props.selection.length === this.props.projects.length; @@ -148,6 +152,27 @@ export default class Search extends React.PureComponent { ); }; + renderVisibilityFilter = () => { + return ( + + + @@ -174,6 +203,35 @@ exports[`renders 1`] = ` placeholder="last_analysis_before" /> + +