diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-01-29 20:09:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 20:09:10 +0100 |
commit | 816bc9d992d181abeb1929c3935b4e7592f865a1 (patch) | |
tree | dd62f427d102675ce4f38fe75c6dafef10f17daf /server/sonar-web/src/main/js/components/issue | |
parent | e201135e00b1ab5b473117bf6736f0836b275e5a (diff) | |
download | sonarqube-816bc9d992d181abeb1929c3935b4e7592f865a1.tar.gz sonarqube-816bc9d992d181abeb1929c3935b4e7592f865a1.zip |
drop getCurrentUserFromStore (#2993)
Diffstat (limited to 'server/sonar-web/src/main/js/components/issue')
2 files changed, 20 insertions, 11 deletions
diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueAssign-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueAssign-test.js.snap index a95bb5a84c5..d4ff90579c6 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueAssign-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueAssign-test.js.snap @@ -22,7 +22,7 @@ exports[`should open the popup when the button is clicked 2`] = ` <BubblePopupHelper isOpen={true} popup={ - <SetAssigneePopup + <Connect(SetAssigneePopup) issue={ Object { "assignee": "john", @@ -69,7 +69,7 @@ exports[`should render with the action 1`] = ` <BubblePopupHelper isOpen={false} popup={ - <SetAssigneePopup + <Connect(SetAssigneePopup) issue={ Object { "assignee": "john", diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.js b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.js index a5c2530f862..75013a4c6ef 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.js @@ -20,16 +20,17 @@ // @flow import React from 'react'; import { map } from 'lodash'; +import { connect } from 'react-redux'; +import * as PropTypes from 'prop-types'; import Avatar from '../../../components/ui/Avatar'; import BubblePopup from '../../../components/common/BubblePopup'; import SelectList from '../../../components/common/SelectList'; import SelectListItem from '../../../components/common/SelectListItem'; import SearchBox from '../../../components/controls/SearchBox'; -import getCurrentUserFromStore from '../../../app/utils/getCurrentUserFromStore'; -import { areThereCustomOrganizations } from '../../../store/organizations/utils'; import { searchMembers } from '../../../api/organizations'; import { searchUsers } from '../../../api/users'; import { translate } from '../../../helpers/l10n'; +import { getCurrentUser } from '../../../store/rootReducer'; /*:: import type { Issue } from '../types'; */ /*:: @@ -43,6 +44,7 @@ type User = { /*:: type Props = { + currentUser: User, issue: Issue, onFail: Error => void, onSelect: string => void, @@ -60,20 +62,21 @@ type State = { const LIST_SIZE = 10; -export default class SetAssigneePopup extends React.PureComponent { +class SetAssigneePopup extends React.PureComponent { /*:: defaultUsersArray: Array<User>; */ - /*:: organizationEnabled: boolean; */ /*:: props: Props; */ /*:: state: State; */ + static contextTypes = { + organizationsEnabled: PropTypes.bool + }; + constructor(props /*: Props */) { super(props); - this.organizationEnabled = areThereCustomOrganizations(); this.defaultUsersArray = [{ login: '', name: translate('unassigned') }]; - const currentUser = getCurrentUserFromStore(); - if (currentUser.isLoggedIn) { - this.defaultUsersArray = [currentUser, ...this.defaultUsersArray]; + if (props.currentUser.isLoggedIn) { + this.defaultUsersArray = [props.currentUser, ...this.defaultUsersArray]; } this.state = { @@ -110,7 +113,7 @@ export default class SetAssigneePopup extends React.PureComponent { }); } else { this.setState({ query }); - if (this.organizationEnabled) { + if (this.context.organizationsEnabled) { this.searchMembers(query); } else { this.searchUsers(query); @@ -155,3 +158,9 @@ export default class SetAssigneePopup extends React.PureComponent { ); } } + +const mapStateToProps = state => ({ + currentUser: getCurrentUser(state) +}); + +export default connect(mapStateToProps)(SetAssigneePopup); |