From a0ea568244db7b77b165c7ecf7dca83620f8edbd Mon Sep 17 00:00:00 2001 From: Grégoire Aubert Date: Thu, 27 Jul 2017 12:18:59 +0200 Subject: Generalize facet components for both issues and measures --- .../apps/component-measures/sidebar/DomainFacet.js | 12 +- .../js/apps/component-measures/sidebar/FacetBox.js | 33 ---- .../apps/component-measures/sidebar/FacetHeader.js | 86 --------- .../apps/component-measures/sidebar/FacetItem.js | 71 -------- .../sidebar/FacetItemMeasureValue.js | 42 ----- .../component-measures/sidebar/FacetItemsList.js | 33 ---- .../sidebar/FacetMeasureValue.js | 42 +++++ .../js/apps/component-measures/sidebar/Sidebar.js | 17 +- .../sidebar/__tests__/FacetHeader-test.js | 55 ------ .../sidebar/__tests__/FacetItem-test.js | 60 ------- .../__tests__/FacetItemMeasureValue-test.js | 53 ------ .../sidebar/__tests__/FacetMeasureValue-test.js | 53 ++++++ .../__snapshots__/DomainFacet-test.js.snap | 8 +- .../__snapshots__/FacetHeader-test.js.snap | 148 ---------------- .../__tests__/__snapshots__/FacetItem-test.js.snap | 105 ----------- .../FacetItemMeasureValue-test.js.snap | 56 ------ .../__snapshots__/FacetMeasureValue-test.js.snap | 56 ++++++ .../js/apps/issues/components/BulkChangeModal.js | 2 +- .../main/js/apps/issues/components/SearchSelect.js | 124 ------------- .../components/__tests__/SearchSelect-test.js | 49 ------ .../__snapshots__/SearchSelect-test.js.snap | 52 ------ .../main/js/apps/issues/sidebar/AssigneeFacet.js | 17 +- .../src/main/js/apps/issues/sidebar/AuthorFacet.js | 14 +- .../js/apps/issues/sidebar/CreationDateFacet.js | 18 +- .../main/js/apps/issues/sidebar/DirectoryFacet.js | 16 +- .../src/main/js/apps/issues/sidebar/FacetMode.js | 12 +- .../src/main/js/apps/issues/sidebar/FileFacet.js | 16 +- .../main/js/apps/issues/sidebar/LanguageFacet.js | 16 +- .../src/main/js/apps/issues/sidebar/ModuleFacet.js | 16 +- .../main/js/apps/issues/sidebar/ProjectFacet.js | 18 +- .../main/js/apps/issues/sidebar/ResolutionFacet.js | 14 +- .../src/main/js/apps/issues/sidebar/RuleFacet.js | 16 +- .../main/js/apps/issues/sidebar/SeverityFacet.js | 14 +- .../src/main/js/apps/issues/sidebar/StatusFacet.js | 14 +- .../src/main/js/apps/issues/sidebar/TagFacet.js | 16 +- .../src/main/js/apps/issues/sidebar/TypeFacet.js | 14 +- .../__snapshots__/AssigneeFacet-test.js.snap | 43 ++--- .../js/apps/issues/sidebar/components/FacetBox.js | 34 ---- .../apps/issues/sidebar/components/FacetFooter.js | 43 ----- .../apps/issues/sidebar/components/FacetHeader.js | 105 ----------- .../js/apps/issues/sidebar/components/FacetItem.js | 82 --------- .../issues/sidebar/components/FacetItemsList.js | 33 ---- .../sidebar/components/__tests__/FacetBox-test.js | 33 ---- .../components/__tests__/FacetFooter-test.js | 27 --- .../components/__tests__/FacetHeader-test.js | 65 ------- .../sidebar/components/__tests__/FacetItem-test.js | 68 -------- .../components/__tests__/FacetItemsList-test.js | 33 ---- .../__tests__/__snapshots__/FacetBox-test.js.snap | 10 -- .../__snapshots__/FacetFooter-test.js.snap | 15 -- .../__snapshots__/FacetHeader-test.js.snap | 192 --------------------- .../__tests__/__snapshots__/FacetItem-test.js.snap | 98 ----------- .../__snapshots__/FacetItemsList-test.js.snap | 9 - server/sonar-web/src/main/js/apps/issues/utils.js | 7 + .../main/js/components/controls/SearchSelect.js | 124 +++++++++++++ .../controls/__tests__/SearchSelect-test.js | 49 ++++++ .../__snapshots__/SearchSelect-test.js.snap | 52 ++++++ .../src/main/js/components/facet/FacetBox.js | 33 ++++ .../src/main/js/components/facet/FacetFooter.js | 43 +++++ .../src/main/js/components/facet/FacetHeader.js | 105 +++++++++++ .../src/main/js/components/facet/FacetItem.js | 73 ++++++++ .../src/main/js/components/facet/FacetItemsList.js | 33 ++++ .../js/components/facet/__tests__/FacetBox-test.js | 33 ++++ .../components/facet/__tests__/FacetFooter-test.js | 27 +++ .../components/facet/__tests__/FacetHeader-test.js | 65 +++++++ .../components/facet/__tests__/FacetItem-test.js | 60 +++++++ .../facet/__tests__/FacetItemsList-test.js | 33 ++++ .../__tests__/__snapshots__/FacetBox-test.js.snap | 9 + .../__snapshots__/FacetFooter-test.js.snap | 15 ++ .../__snapshots__/FacetHeader-test.js.snap | 192 +++++++++++++++++++++ .../__tests__/__snapshots__/FacetItem-test.js.snap | 93 ++++++++++ .../__snapshots__/FacetItemsList-test.js.snap | 9 + 71 files changed, 1342 insertions(+), 1991 deletions(-) delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetBox.js delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetHeader.js delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItem.js delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItemMeasureValue.js delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItemsList.js create mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.js delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetHeader-test.js delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetItem-test.js delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetItemMeasureValue-test.js create mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetMeasureValue-test.js delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetHeader-test.js.snap delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetItem-test.js.snap delete mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetItemMeasureValue-test.js.snap create mode 100644 server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetMeasureValue-test.js.snap delete mode 100644 server/sonar-web/src/main/js/apps/issues/components/SearchSelect.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/components/__tests__/SearchSelect-test.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/SearchSelect-test.js.snap delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetBox.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetFooter.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetHeader.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItem.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItemsList.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetBox-test.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetFooter-test.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetHeader-test.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetItem-test.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetItemsList-test.js delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetBox-test.js.snap delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetFooter-test.js.snap delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetHeader-test.js.snap delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetItem-test.js.snap delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetItemsList-test.js.snap create mode 100644 server/sonar-web/src/main/js/components/controls/SearchSelect.js create mode 100644 server/sonar-web/src/main/js/components/controls/__tests__/SearchSelect-test.js create mode 100644 server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/SearchSelect-test.js.snap create mode 100644 server/sonar-web/src/main/js/components/facet/FacetBox.js create mode 100644 server/sonar-web/src/main/js/components/facet/FacetFooter.js create mode 100644 server/sonar-web/src/main/js/components/facet/FacetHeader.js create mode 100644 server/sonar-web/src/main/js/components/facet/FacetItem.js create mode 100644 server/sonar-web/src/main/js/components/facet/FacetItemsList.js create mode 100644 server/sonar-web/src/main/js/components/facet/__tests__/FacetBox-test.js create mode 100644 server/sonar-web/src/main/js/components/facet/__tests__/FacetFooter-test.js create mode 100644 server/sonar-web/src/main/js/components/facet/__tests__/FacetHeader-test.js create mode 100644 server/sonar-web/src/main/js/components/facet/__tests__/FacetItem-test.js create mode 100644 server/sonar-web/src/main/js/components/facet/__tests__/FacetItemsList-test.js create mode 100644 server/sonar-web/src/main/js/components/facet/__tests__/__snapshots__/FacetBox-test.js.snap create mode 100644 server/sonar-web/src/main/js/components/facet/__tests__/__snapshots__/FacetFooter-test.js.snap create mode 100644 server/sonar-web/src/main/js/components/facet/__tests__/__snapshots__/FacetHeader-test.js.snap create mode 100644 server/sonar-web/src/main/js/components/facet/__tests__/__snapshots__/FacetItem-test.js.snap create mode 100644 server/sonar-web/src/main/js/components/facet/__tests__/__snapshots__/FacetItemsList-test.js.snap (limited to 'server/sonar-web') diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js index ac2083422d1..c7e8dd68b21 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js @@ -19,11 +19,11 @@ */ // @flow import React from 'react'; -import FacetBox from './FacetBox'; -import FacetHeader from './FacetHeader'; -import FacetItem from './FacetItem'; -import FacetItemsList from './FacetItemsList'; -import FacetItemMeasureValue from './FacetItemMeasureValue'; +import FacetBox from '../../../components/facet/FacetBox'; +import FacetHeader from '../../../components/facet/FacetHeader'; +import FacetItem from '../../../components/facet/FacetItem'; +import FacetItemsList from '../../../components/facet/FacetItemsList'; +import FacetMeasureValue from './FacetMeasureValue'; import IssueTypeIcon from '../../../components/ui/IssueTypeIcon'; import Tooltip from '../../../components/controls/Tooltip'; import { filterMeasures, sortMeasures } from '../utils'; @@ -71,7 +71,7 @@ export default class DomainFacet extends React.PureComponent { } onClick={this.props.onChange} - stat={} + stat={} value={measure.metric.key} /> )} diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetBox.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetBox.js deleted file mode 100644 index 92b7afb58db..00000000000 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetBox.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; - -type Props = {| - children?: React.Element<*> -|}; - -export default function FacetBox(props: Props) { - return ( -
- {props.children} -
- ); -} diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetHeader.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetHeader.js deleted file mode 100644 index 2cc9d19f98b..00000000000 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetHeader.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -/* eslint-disable max-len */ -import React from 'react'; - -type Props = {| - name: string, - onClick?: () => void, - open: boolean, - values?: number -|}; - -export default class FacetHeader extends React.PureComponent { - props: Props; - - static defaultProps = { - open: true - }; - - handleClick = (event: Event & { currentTarget: HTMLElement }) => { - event.preventDefault(); - event.currentTarget.blur(); - if (this.props.onClick) { - this.props.onClick(); - } - }; - - renderCheckbox() { - return ( - - {this.props.open - ? - : } - - ); - } - - renderValueIndicator() { - if (this.props.open || !this.props.values) { - return null; - } - return ( - - {this.props.values} - - ); - } - - render() { - return ( -
- {this.props.onClick - ? - {this.renderCheckbox()} {this.props.name} {this.renderValueIndicator()} - - : - {this.props.name} - } -
- ); - } -} diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItem.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItem.js deleted file mode 100644 index e84480b1317..00000000000 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItem.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import classNames from 'classnames'; - -type Props = {| - active: boolean, - disabled: boolean, - halfWidth: boolean, - name: string | React.Element<*>, - onClick: string => void, - stat: string | React.Element<*>, - value: string -|}; - -export default class FacetItem extends React.PureComponent { - props: Props; - - static defaultProps = { - disabled: false, - halfWidth: false - }; - - handleClick = (event: Event & { currentTarget: HTMLElement }) => { - event.preventDefault(); - this.props.onClick(this.props.value); - }; - - render() { - const className = classNames('facet', 'search-navigator-facet', { - active: this.props.active, - 'search-navigator-facet-half': this.props.halfWidth - }); - - return this.props.disabled - ? - - {this.props.name} - - - {this.props.stat} - - - : - - {this.props.name} - - - {this.props.stat} - - ; - } -} diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItemMeasureValue.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItemMeasureValue.js deleted file mode 100644 index ede45d98793..00000000000 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItemMeasureValue.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import Measure from '../../../components/measure/Measure'; -import { isDiffMetric } from '../../../helpers/measures'; -import type { MeasureEnhanced } from '../../../components/measure/types'; - -export default function FacetItemMeasureValue({ measure }: { measure: MeasureEnhanced }) { - if (isDiffMetric(measure.metric.key)) { - return ( -
- -
- ); - } - - return ( -
- -
- ); -} diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItemsList.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItemsList.js deleted file mode 100644 index 5d36d9934e3..00000000000 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetItemsList.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; - -type Props = {| - children?: Array> -|}; - -export default function FacetItemsList(props: Props) { - return ( -
- {props.children} -
- ); -} diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.js new file mode 100644 index 00000000000..eae569c72e0 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.js @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +// @flow +import React from 'react'; +import Measure from '../../../components/measure/Measure'; +import { isDiffMetric } from '../../../helpers/measures'; +import type { MeasureEnhanced } from '../../../components/measure/types'; + +export default function FacetMeasureValue({ measure }: { measure: MeasureEnhanced }) { + if (isDiffMetric(measure.metric.key)) { + return ( +
+ +
+ ); + } + + return ( +
+ +
+ ); +} diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.js index f707eb462a5..58c0326c9dc 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.js +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.js @@ -31,8 +31,7 @@ type Props = {| |}; type State = {| - closedFacets: { [string]: boolean }, - measuresByDomains: Array<{ name: string, measures: Array }> + closedFacets: { [string]: boolean } |}; export default class Sidebar extends React.PureComponent { @@ -41,16 +40,7 @@ export default class Sidebar extends React.PureComponent { constructor(props: Props) { super(props); - this.state = { - closedFacets: {}, - measuresByDomains: groupByDomains(props.measures) - }; - } - - componentWillReceiveProps(nextProps: Props) { - if (nextProps.measures !== this.props.measures) { - this.setState({ measuresByDomains: groupByDomains(nextProps.measures) }); - } + this.state = { closedFacets: {} }; } toggleFacet = (name: string) => { @@ -62,10 +52,9 @@ export default class Sidebar extends React.PureComponent { changeMetric = (metric: string) => this.props.updateQuery({ metric }); render() { - const { measuresByDomains } = this.state; return (
- {measuresByDomains.map(domain => + {groupByDomains(this.props.measures).map(domain => { - expect( - shallow() - ).toMatchSnapshot(); -}); - -it('should render open facet without value', () => { - expect(shallow()).toMatchSnapshot(); -}); - -it('should render closed facet with value', () => { - expect( - shallow() - ).toMatchSnapshot(); -}); - -it('should render closed facet without value', () => { - expect(shallow()).toMatchSnapshot(); -}); - -it('should render without link', () => { - expect(shallow()).toMatchSnapshot(); -}); - -it('should call onClick', () => { - const onClick = jest.fn(); - const wrapper = shallow(); - click(wrapper.find('a')); - expect(onClick).toHaveBeenCalled(); -}); diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetItem-test.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetItem-test.js deleted file mode 100644 index e8c8bfe4d54..00000000000 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetItem-test.js +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import { shallow } from 'enzyme'; -import { click } from '../../../../helpers/testUtils'; -import FacetItem from '../FacetItem'; - -const renderFacetItem = (props: {}) => - shallow( - - ); - -it('should render active', () => { - expect(renderFacetItem({ active: true })).toMatchSnapshot(); -}); - -it('should render inactive', () => { - expect(renderFacetItem({ active: false })).toMatchSnapshot(); -}); - -it('should render stat', () => { - expect(renderFacetItem({ stat: 13 })).toMatchSnapshot(); -}); - -it('should render disabled', () => { - expect(renderFacetItem({ disabled: true })).toMatchSnapshot(); -}); - -it('should render half width', () => { - expect(renderFacetItem({ halfWidth: true })).toMatchSnapshot(); -}); - -it('should render effort stat', () => { - expect(renderFacetItem({ facetMode: 'effort', stat: 1234 })).toMatchSnapshot(); -}); - -it('should call onClick', () => { - const onClick = jest.fn(); - const wrapper = renderFacetItem({ onClick }); - click(wrapper, { currentTarget: { dataset: { value: 'bar' } } }); - expect(onClick).toHaveBeenCalled(); -}); diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetItemMeasureValue-test.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetItemMeasureValue-test.js deleted file mode 100644 index d2a6ec5769a..00000000000 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetItemMeasureValue-test.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import { shallow } from 'enzyme'; -import FacetItemMeasureValue from '../FacetItemMeasureValue'; - -const MEASURE = { - metric: { - key: 'bugs', - type: 'INT', - name: 'Bugs', - domain: 'Reliability' - }, - value: '5', - periods: [{ index: 1, value: '5' }], - leak: '5' -}; -const LEAK_MEASURE = { - metric: { - key: 'new_bugs', - type: 'INT', - name: 'New Bugs', - domain: 'Reliability' - }, - periods: [{ index: 1, value: '5' }], - leak: '5' -}; - -it('should display measure value', () => { - expect(shallow()).toMatchSnapshot(); -}); - -it('should display leak measure value', () => { - expect(shallow()).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetMeasureValue-test.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetMeasureValue-test.js new file mode 100644 index 00000000000..b92096c3e40 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/FacetMeasureValue-test.js @@ -0,0 +1,53 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +// @flow +import React from 'react'; +import { shallow } from 'enzyme'; +import FacetMeasureValue from '../FacetMeasureValue'; + +const MEASURE = { + metric: { + key: 'bugs', + type: 'INT', + name: 'Bugs', + domain: 'Reliability' + }, + value: '5', + periods: [{ index: 1, value: '5' }], + leak: '5' +}; +const LEAK_MEASURE = { + metric: { + key: 'new_bugs', + type: 'INT', + name: 'New Bugs', + domain: 'Reliability' + }, + periods: [{ index: 1, value: '5' }], + leak: '5' +}; + +it('should display measure value', () => { + expect(shallow()).toMatchSnapshot(); +}); + +it('should display leak measure value', () => { + expect(shallow()).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/DomainFacet-test.js.snap b/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/DomainFacet-test.js.snap index 6ca87d36a3f..a55b82c48d7 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/DomainFacet-test.js.snap +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/DomainFacet-test.js.snap @@ -32,7 +32,7 @@ exports[`should display facet item list 1`] = ` } onClick={[Function]} stat={ - - - - - - - foo - - - 1 - - -
-`; - -exports[`should render closed facet without value 1`] = ` - -`; - -exports[`should render open facet with value 1`] = ` - -`; - -exports[`should render open facet without value 1`] = ` - -`; - -exports[`should render without link 1`] = ` -
- - foo - -
-`; diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetItem-test.js.snap b/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetItem-test.js.snap deleted file mode 100644 index 82e72d3b0af..00000000000 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetItem-test.js.snap +++ /dev/null @@ -1,105 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render active 1`] = ` - - - foo - - - -`; - -exports[`should render disabled 1`] = ` - - - foo - - - -`; - -exports[`should render effort stat 1`] = ` - - - foo - - - 1234 - - -`; - -exports[`should render half width 1`] = ` - - - foo - - - -`; - -exports[`should render inactive 1`] = ` - - - foo - - - -`; - -exports[`should render stat 1`] = ` - - - foo - - - 13 - - -`; diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetItemMeasureValue-test.js.snap b/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetItemMeasureValue-test.js.snap deleted file mode 100644 index 9bd6a3e7e00..00000000000 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetItemMeasureValue-test.js.snap +++ /dev/null @@ -1,56 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should display leak measure value 1`] = ` -
- -
-`; - -exports[`should display measure value 1`] = ` -
- -
-`; diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetMeasureValue-test.js.snap b/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetMeasureValue-test.js.snap new file mode 100644 index 00000000000..9bd6a3e7e00 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/__tests__/__snapshots__/FacetMeasureValue-test.js.snap @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should display leak measure value 1`] = ` +
+ +
+`; + +exports[`should display measure value 1`] = ` +
+ +
+`; diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js index 4340f1670bf..250c8ed2a6d 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js @@ -22,7 +22,7 @@ import React from 'react'; import Modal from 'react-modal'; import Select from 'react-select'; import { pickBy, sortBy } from 'lodash'; -import SearchSelect from './SearchSelect'; +import SearchSelect from '../../../components/controls/SearchSelect'; import Checkbox from '../../../components/controls/Checkbox'; import Tooltip from '../../../components/controls/Tooltip'; import MarkdownTips from '../../../components/common/MarkdownTips'; diff --git a/server/sonar-web/src/main/js/apps/issues/components/SearchSelect.js b/server/sonar-web/src/main/js/apps/issues/components/SearchSelect.js deleted file mode 100644 index 7d95fdde139..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/components/SearchSelect.js +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import Select from 'react-select'; -import { debounce } from 'lodash'; -import { translate, translateWithParameters } from '../../../helpers/l10n'; - -type Option = { label: string, value: string }; - -type Props = {| - autofocus: boolean, - minimumQueryLength: number, - onSearch: (query: string) => Promise>, - onSelect: (value: string) => void, - renderOption?: (option: Object) => React.Element<*>, - resetOnBlur: boolean, - value?: string -|}; - -type State = { - loading: boolean, - options: Array
} onClick={this.handleItemClick} - stat={stat} + stat={formatFacetStat(stat, this.props.facetMode)} value={type} /> ); @@ -92,7 +92,7 @@ export default class TypeFacet extends React.PureComponent { const types = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; return ( - + + @@ -39,17 +35,16 @@ exports[`should render 1`] = ` } onClick={[Function]} - stat={13} + stat="13" value="foo" /> @@ -74,9 +69,7 @@ exports[`should render footer select option 1`] = ` `; exports[`should render without stats 1`] = ` - + + @@ -126,17 +115,16 @@ exports[`should select unassigned 1`] = ` } onClick={[Function]} - stat={13} + stat="13" value="foo" /> @@ -149,9 +137,7 @@ exports[`should select unassigned 1`] = ` `; exports[`should select user 1`] = ` - + @@ -187,17 +171,16 @@ exports[`should select user 1`] = ` } onClick={[Function]} - stat={13} + stat="13" value="foo" /> diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetBox.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetBox.js deleted file mode 100644 index 9f0c6cf98ee..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetBox.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; - -type Props = {| - children?: React.Element<*>, - property: string -|}; - -export default function FacetBox(props: Props) { - return ( -
- {props.children} -
- ); -} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetFooter.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetFooter.js deleted file mode 100644 index cc7d381b3e7..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetFooter.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import SearchSelect from '../../components/SearchSelect'; - -type Option = { label: string, value: string }; - -type Props = {| - minimumQueryLength?: number, - onSearch: (query: string) => Promise>, - onSelect: (value: string) => void, - renderOption?: (option: Object) => React.Element<*> -|}; - -export default class FacetFooter extends React.PureComponent { - props: Props; - - render() { - return ( -
- -
- ); - } -} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetHeader.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetHeader.js deleted file mode 100644 index eb084d38f65..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetHeader.js +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -/* eslint-disable max-len */ -import React from 'react'; -import { translate } from '../../../../helpers/l10n'; - -type Props = {| - name: string, - onClear?: () => void, - onClick?: () => void, - open: boolean, - values?: number -|}; - -export default class FacetHeader extends React.PureComponent { - props: Props; - - static defaultProps = { - open: true - }; - - handleClearClick = (event: Event & { currentTarget: HTMLElement }) => { - event.preventDefault(); - event.currentTarget.blur(); - if (this.props.onClear) { - this.props.onClear(); - } - }; - - handleClick = (event: Event & { currentTarget: HTMLElement }) => { - event.preventDefault(); - event.currentTarget.blur(); - if (this.props.onClick) { - this.props.onClick(); - } - }; - - renderCheckbox() { - return ( - - {this.props.open - ? - : } - - ); - } - - renderValueIndicator() { - if (this.props.open || !this.props.values) { - return null; - } - return ( - - {this.props.values} - - ); - } - - render() { - const showClearButton: boolean = !!this.props.values && this.props.onClear != null; - - return ( -
- {showClearButton && - } - - {this.props.onClick - ? - {this.renderCheckbox()} {this.props.name} {this.renderValueIndicator()} - - : - {this.props.name} - } -
- ); - } -} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItem.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItem.js deleted file mode 100644 index 88c5a0e7c77..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItem.js +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import classNames from 'classnames'; -import { formatMeasure } from '../../../../helpers/measures'; - -type Props = {| - active: boolean, - disabled: boolean, - facetMode: string, - halfWidth: boolean, - name: string | React.Element<*>, - onClick: string => void, - stat: ?number, - value: string -|}; - -export default class FacetItem extends React.PureComponent { - props: Props; - - static defaultProps = { - disabled: false, - halfWidth: false - }; - - handleClick = (event: Event & { currentTarget: HTMLElement }) => { - event.preventDefault(); - const value = event.currentTarget.dataset.value; - this.props.onClick(value); - }; - - render() { - const { stat } = this.props; - - const className = classNames('facet', 'search-navigator-facet', { - active: this.props.active, - 'search-navigator-facet-half': this.props.halfWidth - }); - - const formattedStat = - stat && - formatMeasure(stat, this.props.facetMode === 'effort' ? 'SHORT_WORK_DUR' : 'SHORT_INT'); - - return this.props.disabled - ? - - {this.props.name} - - {formattedStat != null && - - {formattedStat} - } - - : - - {this.props.name} - - {formattedStat != null && - - {formattedStat} - } - ; - } -} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItemsList.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItemsList.js deleted file mode 100644 index 5d36d9934e3..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItemsList.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; - -type Props = {| - children?: Array> -|}; - -export default function FacetItemsList(props: Props) { - return ( -
- {props.children} -
- ); -} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetBox-test.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetBox-test.js deleted file mode 100644 index 2ebd4b3feaa..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetBox-test.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import { shallow } from 'enzyme'; -import FacetBox from '../FacetBox'; - -it('should render', () => { - expect( - shallow( - -
- - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetFooter-test.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetFooter-test.js deleted file mode 100644 index 4dbf1cc3ece..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetFooter-test.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import { shallow } from 'enzyme'; -import FacetFooter from '../FacetFooter'; - -it('should render', () => { - expect(shallow()).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetHeader-test.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetHeader-test.js deleted file mode 100644 index ed3f143eedc..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetHeader-test.js +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import { shallow } from 'enzyme'; -import { click } from '../../../../../helpers/testUtils'; -import FacetHeader from '../FacetHeader'; - -it('should render open facet with value', () => { - expect( - shallow() - ).toMatchSnapshot(); -}); - -it('should render open facet without value', () => { - expect(shallow()).toMatchSnapshot(); -}); - -it('should render closed facet with value', () => { - expect( - shallow() - ).toMatchSnapshot(); -}); - -it('should render closed facet without value', () => { - expect(shallow()).toMatchSnapshot(); -}); - -it('should render without link', () => { - expect(shallow()).toMatchSnapshot(); -}); - -it('should call onClick', () => { - const onClick = jest.fn(); - const wrapper = shallow(); - click(wrapper.find('a')); - expect(onClick).toHaveBeenCalled(); -}); - -it('should clear', () => { - const onClear = jest.fn(); - const wrapper = shallow( - - ); - expect(wrapper).toMatchSnapshot(); - click(wrapper.find('.button-red')); - expect(onClear).toHaveBeenCalled(); -}); diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetItem-test.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetItem-test.js deleted file mode 100644 index ddc84eca458..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetItem-test.js +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import { shallow } from 'enzyme'; -import { click } from '../../../../../helpers/testUtils'; -import FacetItem from '../FacetItem'; - -const renderFacetItem = (props: {}) => - shallow( - - ); - -it('should render active', () => { - expect(renderFacetItem({ active: true })).toMatchSnapshot(); -}); - -it('should render inactive', () => { - expect(renderFacetItem({ active: false })).toMatchSnapshot(); -}); - -it('should render stat', () => { - expect(renderFacetItem({ stat: 13 })).toMatchSnapshot(); -}); - -it('should render disabled', () => { - expect(renderFacetItem({ disabled: true })).toMatchSnapshot(); -}); - -it('should render half width', () => { - expect(renderFacetItem({ halfWidth: true })).toMatchSnapshot(); -}); - -it('should render effort stat', () => { - expect(renderFacetItem({ facetMode: 'effort', stat: 1234 })).toMatchSnapshot(); -}); - -it('should call onClick', () => { - const onClick = jest.fn(); - const wrapper = renderFacetItem({ onClick }); - click(wrapper, { currentTarget: { dataset: { value: 'bar' } } }); - expect(onClick).toHaveBeenCalled(); -}); diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetItemsList-test.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetItemsList-test.js deleted file mode 100644 index 39fc1fb4eef..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/FacetItemsList-test.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import { shallow } from 'enzyme'; -import FacetItemsList from '../FacetItemsList'; - -it('should render', () => { - expect( - shallow( - -
- - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetBox-test.js.snap b/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetBox-test.js.snap deleted file mode 100644 index 317329065b1..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetBox-test.js.snap +++ /dev/null @@ -1,10 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render 1`] = ` -
-
-
-`; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetFooter-test.js.snap b/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetFooter-test.js.snap deleted file mode 100644 index e2475bdc5dd..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetFooter-test.js.snap +++ /dev/null @@ -1,15 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render 1`] = ` -
- -
-`; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetHeader-test.js.snap b/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetHeader-test.js.snap deleted file mode 100644 index 8c92ac2d4ba..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetHeader-test.js.snap +++ /dev/null @@ -1,192 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should clear 1`] = ` - -`; - -exports[`should render closed facet with value 1`] = ` - -`; - -exports[`should render closed facet without value 1`] = ` - -`; - -exports[`should render open facet with value 1`] = ` - -`; - -exports[`should render open facet without value 1`] = ` - -`; - -exports[`should render without link 1`] = ` -
- - foo - -
-`; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetItem-test.js.snap b/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetItem-test.js.snap deleted file mode 100644 index b8db949fded..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetItem-test.js.snap +++ /dev/null @@ -1,98 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render active 1`] = ` - - - foo - - -`; - -exports[`should render disabled 1`] = ` - - - foo - - -`; - -exports[`should render effort stat 1`] = ` - - - foo - - - work_duration.x_days.3 - - -`; - -exports[`should render half width 1`] = ` - - - foo - - -`; - -exports[`should render inactive 1`] = ` - - - foo - - -`; - -exports[`should render stat 1`] = ` - - - foo - - - 13 - - -`; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetItemsList-test.js.snap b/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetItemsList-test.js.snap deleted file mode 100644 index 9962cfc364e..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/__tests__/__snapshots__/FacetItemsList-test.js.snap +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render 1`] = ` -
-
-
-`; diff --git a/server/sonar-web/src/main/js/apps/issues/utils.js b/server/sonar-web/src/main/js/apps/issues/utils.js index c3be4a5207b..adf2d8aba6e 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.js +++ b/server/sonar-web/src/main/js/apps/issues/utils.js @@ -20,6 +20,7 @@ // @flow import { searchMembers } from '../../api/organizations'; import { searchUsers } from '../../api/users'; +import { formatMeasure } from '../../helpers/measures'; import { queriesEqual, cleanQuery, @@ -165,6 +166,12 @@ export const parseFacets = (facets: Array): { [string]: Facet } => { return result; }; +export const formatFacetStat = (stat: ?number, mode: string): ?string => { + if (stat != null) { + return formatMeasure(stat, mode === 'effort' ? 'SHORT_WORK_DUR' : 'SHORT_INT'); + } +}; + export type ReferencedComponent = { key: string, name: string, diff --git a/server/sonar-web/src/main/js/components/controls/SearchSelect.js b/server/sonar-web/src/main/js/components/controls/SearchSelect.js new file mode 100644 index 00000000000..38515273b6c --- /dev/null +++ b/server/sonar-web/src/main/js/components/controls/SearchSelect.js @@ -0,0 +1,124 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +// @flow +import React from 'react'; +import Select from 'react-select'; +import { debounce } from 'lodash'; +import { translate, translateWithParameters } from '../../helpers/l10n'; + +type Option = { label: string, value: string }; + +type Props = {| + autofocus: boolean, + minimumQueryLength: number, + onSearch: (query: string) => Promise>, + onSelect: (value: string) => void, + renderOption?: (option: Object) => React.Element<*>, + resetOnBlur: boolean, + value?: string +|}; + +type State = { + loading: boolean, + options: Array