+++ /dev/null
-/*
- * 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 { getCurrentUser } from '../../store/rootReducer';
-
-// TODO remove my usages
-const getCurrentUserFromStore = () => {
- const getStore = require('./getStore').default;
- const store = getStore();
- return getCurrentUser(store.getState());
-};
-
-export default getCurrentUserFromStore;
// @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'; */
/*::
/*::
type Props = {
+ currentUser: User,
issue: Issue,
onFail: Error => void,
onSelect: string => void,
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 = {
});
} else {
this.setState({ query });
- if (this.organizationEnabled) {
+ if (this.context.organizationsEnabled) {
this.searchMembers(query);
} else {
this.searchUsers(query);
);
}
}
+
+const mapStateToProps = state => ({
+ currentUser: getCurrentUser(state)
+});
+
+export default connect(mapStateToProps)(SetAssigneePopup);