Files
mattermost/webapp/components/user_list.jsx
Christopher Speller 2bbedd9def Updating client dependencies. Switching to yarn. (#6433)
* Updating client dependancies. Switching to using yarn.

* Updating React

* Moving pure components to using function syntax (performance gains with newer react version)

* Updating client dependancies.

* Ignore .yarninstall

* Enabling pre-lockfile because it's the entire point of using yarn.

* Removing old webpack config

* Moving to new prop-types

* Fixing ESLint Errors

* Updating jest snapshots.

* Cleaning up package.json
2017-05-18 09:28:18 -04:00

85 lines
2.3 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import UserListRow from './user_list_row.jsx';
import LoadingScreen from 'components/loading_screen.jsx';
import PropTypes from 'prop-types';
import React from 'react';
import {FormattedMessage} from 'react-intl';
import Constants from 'utils/constants.jsx';
export default class UserList extends React.Component {
constructor(props) {
super(props);
this.scrollToTop = this.scrollToTop.bind(this);
}
scrollToTop() {
if (this.refs.container) {
this.refs.container.scrollTop = 0;
}
}
render() {
const users = this.props.users;
let content;
if (users == null) {
return <LoadingScreen/>;
} else if (users.length > 0) {
content = users.map((user, index) => {
return (
<UserListRow
key={user.id}
user={user}
extraInfo={this.props.extraInfo[user.id]}
actions={this.props.actions}
actionProps={this.props.actionProps}
actionUserProps={this.props.actionUserProps[user.id]}
userCount={(index >= 0 && index < Constants.TEST_ID_COUNT) ? index : -1}
/>
);
});
} else {
content = (
<div
key='no-users-found'
className='more-modal__placeholder-row'
>
<p>
<FormattedMessage
id='user_list.notFound'
defaultMessage='No users found'
/>
</p>
</div>
);
}
return (
<div ref='container'>
{content}
</div>
);
}
}
UserList.defaultProps = {
users: [],
extraInfo: {},
actions: [],
actionProps: {}
};
UserList.propTypes = {
users: PropTypes.arrayOf(PropTypes.object),
extraInfo: PropTypes.object,
actions: PropTypes.arrayOf(PropTypes.func),
actionProps: PropTypes.object,
actionUserProps: PropTypes.object
};