From 5bafba36f7cfadcfe035153d33b3fdf495d62811 Mon Sep 17 00:00:00 2001 From: Pascal Mugnier Date: Thu, 8 Mar 2018 11:14:02 +0100 Subject: [PATCH] SONAR-10476 Add a checkbox on top of issues list to allow global selection/unselection (#3131) --- .../src/main/js/apps/issues/components/App.js | 24 ++++++++++++++-- .../issues/components/__tests__/App-test.js | 28 +++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.js b/server/sonar-web/src/main/js/apps/issues/components/App.js index 02c1a0e1e47..2c7181ff027 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.js +++ b/server/sonar-web/src/main/js/apps/issues/components/App.js @@ -62,6 +62,7 @@ import ScreenPositionHelper from '../../../components/common/ScreenPositionHelpe import { getBranchName, isShortLivingBranch } from '../../../helpers/branches'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { scrollToElement } from '../../../helpers/scrolling'; +import Checkbox from '../../../components/controls/Checkbox'; /*:: import type { Issue } from '../../../components/issue/types'; */ /*:: import type { RawQuery } from '../../../helpers/query'; */ import '../styles.css'; @@ -741,9 +742,21 @@ export default class App extends React.PureComponent { selectNextFlow = () => this.setState(actions.selectNextFlow); selectPreviousFlow = () => this.setState(actions.selectPreviousFlow); + onCheckAll = (checked /*: boolean */) => { + if (checked) { + this.setState(state => ({ checked: state.issues.map(issue => issue.key) })); + } else { + this.setState(state => ({ checked: [] })); + } + }; + renderBulkChange(openIssue /*: ?Issue */) { const { component, currentUser } = this.props; - const { bulkChange, checked, paging } = this.state; + const { bulkChange, checked, paging, issues } = this.state; + + const isAllChecked = checked.length > 0 && issues.length === checked.length; + const thirdState = checked.length > 0 && !isAllChecked; + const isChecked = isAllChecked || thirdState; if (!currentUser.isLoggedIn || openIssue != null) { return null; @@ -751,8 +764,15 @@ export default class App extends React.PureComponent { return (
+ {checked.length > 0 ? ( -
+