From: Grégoire Aubert Date: Tue, 30 Jan 2018 15:02:17 +0000 (+0100) Subject: Add back missing action to bulk unassign issues X-Git-Tag: 7.0~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1f271fd894cdc74682b801cbc202309b120a3738;p=sonarqube.git Add back missing action to bulk unassign issues --- 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 6ac8ce8b88f..c5d585adcf3 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 @@ -109,44 +109,40 @@ export default class BulkChangeModal extends React.PureComponent { this.mounted = false; } + loadIssues = () => this.props.fetchIssues({ additionalFields: 'actions,transitions', ps: 250 }); + + getDefaultAssignee = () => { + const { currentUser } = this.props; + const { issues } = this.state; + const options = []; + + if (currentUser.isLoggedIn) { + const canBeAssignedToMe = + issues.filter(issue => issue.assignee !== currentUser.login).length > 0; + if (canBeAssignedToMe) { + options.push({ + avatar: currentUser.avatar, + label: currentUser.name, + value: currentUser.login + }); + } + } + + const canBeUnassigned = issues.filter(issue => issue.assignee).length > 0; + if (canBeUnassigned) { + options.push({ label: translate('unassigned'), value: '' }); + } + + return options; + }; + handleCloseClick = (e /*: Event & { target: HTMLElement } */) => { e.preventDefault(); e.target.blur(); this.props.onClose(); }; - loadIssues = () => { - return this.props.fetchIssues({ additionalFields: 'actions,transitions', ps: 250 }); - }; - - handleAssigneeSearch = (query /*: string */) => { - if (query.length > 1) { - return searchAssignees(query, this.state.organization); - } else { - const { currentUser } = this.props; - const { issues } = this.state; - const options = []; - - if (currentUser.isLoggedIn) { - const canBeAssignedToMe = - issues.filter(issue => issue.assignee !== currentUser.login).length > 0; - if (canBeAssignedToMe) { - options.push({ - email: currentUser.email, - label: currentUser.name, - value: currentUser.login - }); - } - } - - const canBeUnassigned = issues.filter(issue => issue.assignee).length > 0; - if (canBeUnassigned) { - options.push({ label: translate('unassigned'), value: '' }); - } - - return Promise.resolve(options); - } - }; + handleAssigneeSearch = (query /*: string */) => searchAssignees(query, this.state.organization); handleAssigneeSelect = (assignee /*: string */) => { this.setState({ assignee }); @@ -270,19 +266,16 @@ export default class BulkChangeModal extends React.PureComponent { ); - renderAssigneeOption = (option /*: { avatar?: string, email?: string, label: string } */) => ( - - {option.avatar != null && ( - - )} - {option.label} - - ); + renderAssigneeOption = (option /*: { avatar?: string, email?: string, label: string } */) => { + return ( + + {option.avatar != null && ( + + )} + {option.label} + + ); + }; renderAssigneeField = () => { const affected /*: number */ = this.state.issues.filter(hasAction('assign')).length; @@ -293,6 +286,7 @@ export default class BulkChangeModal extends React.PureComponent { const input = ( { diff --git a/server/sonar-web/src/main/js/components/controls/SearchSelect.js b/server/sonar-web/src/main/js/components/controls/SearchSelect.js deleted file mode 100644 index bed2a3acd1b..00000000000 --- a/server/sonar-web/src/main/js/components/controls/SearchSelect.js +++ /dev/null @@ -1,135 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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 { debounce } from 'lodash'; -import Select from '../../components/controls/Select'; -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