diff options
author | Kevin Silva <kevin.silva@sonarsource.com> | 2023-06-02 10:28:13 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-06-09 20:03:09 +0000 |
commit | 5e2d38f17ef22ea4e983938532bb05108c598036 (patch) | |
tree | 3116feed7e88bf0cc5848917ddaa898ed026f218 /server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx | |
parent | a74f4d9475ab3548821fe9f6380c204d56f886d6 (diff) | |
download | sonarqube-5e2d38f17ef22ea4e983938532bb05108c598036.tar.gz sonarqube-5e2d38f17ef22ea4e983938532bb05108c598036.zip |
SONAR-19345 Update box contents for each issue
Diffstat (limited to 'server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx')
-rw-r--r-- | server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx deleted file mode 100644 index 181dc2989e8..00000000000 --- a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx +++ /dev/null @@ -1,129 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 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. - */ -import { map } from 'lodash'; -import * as React from 'react'; -import { searchUsers } from '../../../api/users'; -import withCurrentUserContext from '../../../app/components/current-user/withCurrentUserContext'; -import { DropdownOverlay } from '../../../components/controls/Dropdown'; -import SearchBox from '../../../components/controls/SearchBox'; -import { translate } from '../../../helpers/l10n'; -import { CurrentUser, isLoggedIn, isUserActive, UserActive, UserBase } from '../../../types/users'; -import SelectList from '../../common/SelectList'; -import SelectListItem from '../../common/SelectListItem'; -import LegacyAvatar from '../../ui/LegacyAvatar'; - -interface Props { - currentUser: CurrentUser; - onSelect: (login: string) => void; -} - -interface State { - currentUser: string; - query: string; - users: UserActive[]; -} - -const LIST_SIZE = 10; - -export class SetAssigneePopup extends React.PureComponent<Props, State> { - defaultUsersArray: UserActive[]; - - constructor(props: Props) { - super(props); - this.defaultUsersArray = [{ login: '', name: translate('unassigned') }]; - - if (isLoggedIn(props.currentUser)) { - this.defaultUsersArray = [props.currentUser, ...this.defaultUsersArray]; - } - - this.state = { - query: '', - users: this.defaultUsersArray, - currentUser: this.defaultUsersArray.length > 0 ? this.defaultUsersArray[0].login : '', - }; - } - - searchUsers = (query: string) => { - searchUsers({ q: query, ps: LIST_SIZE }).then(this.handleSearchResult, () => {}); - }; - - handleSearchResult = ({ users }: { users: UserBase[] }) => { - const activeUsers = users.filter(isUserActive); - this.setState({ - users: activeUsers, - currentUser: activeUsers.length > 0 ? activeUsers[0].login : '', - }); - }; - - handleSearchChange = (query: string) => { - if (query.length === 0) { - this.setState({ - query, - users: this.defaultUsersArray, - currentUser: this.defaultUsersArray[0].login, - }); - } else { - this.setState({ query }); - this.searchUsers(query); - } - }; - - render() { - return ( - <DropdownOverlay noPadding> - <div className="multi-select"> - <div className="menu-search"> - <SearchBox - autoFocus - className="little-spacer-top" - minLength={2} - onChange={this.handleSearchChange} - placeholder={translate('search.search_for_users')} - value={this.state.query} - /> - </div> - <SelectList - currentItem={this.state.currentUser} - items={map(this.state.users, 'login')} - onSelect={this.props.onSelect} - > - {this.state.users.map((user) => ( - <SelectListItem item={user.login} key={user.login}> - {!!user.login && ( - <LegacyAvatar - className="spacer-right" - hash={user.avatar} - name={user.name} - size={16} - /> - )} - <span className="text-middle" style={{ marginLeft: user.login ? 24 : undefined }}> - {user.name} - </span> - </SelectListItem> - ))} - </SelectList> - </div> - </DropdownOverlay> - ); - } -} - -export default withCurrentUserContext(SetAssigneePopup); |