Merge remote-tracking branch 'origin/x.0.2-fix-invalid-prop' into x.0.3-fix-console-warnings

This commit is contained in:
KDSBrowne 2017-12-15 07:13:09 -08:00
commit c5b96ed4c8
6 changed files with 48 additions and 38 deletions

View File

@ -1,6 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl, intlShape } from 'react-intl';
import _ from 'lodash';
import Button from '/imports/ui/components/button/component';
import Dropdown from '/imports/ui/components/dropdown/component';
@ -72,12 +73,17 @@ class ActionsDropdown extends Component {
</DropdownTrigger>
<DropdownContent placement="top left">
<DropdownList>
<DropdownListItem
icon="presentation"
label={intl.formatMessage(intlMessages.presentationLabel)}
description={intl.formatMessage(intlMessages.presentationDesc)}
onClick={this.handlePresentationClick}
/>
{
[
(<DropdownListItem
key={_.uniqueId('actions-list-item-')}
icon="presentation"
label={intl.formatMessage(intlMessages.presentationLabel)}
description={intl.formatMessage(intlMessages.presentationDesc)}
onClick={this.handlePresentationClick}
/>)
]
}
</DropdownList>
</DropdownContent>
</Dropdown>

View File

@ -2,11 +2,14 @@ import React, { Component, Children, cloneElement } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import KEY_CODES from '/imports/utils/keyCodes';
import styles from './styles';
import ListItem from './item/component';
import ListSeparator from './separator/component';
import ListTitle from './title/component';
import UserActions from '../../user-list/user-list-content/user-participants/user-list-item/user-action/component';
const propTypes = {
/* We should recheck this proptype, sometimes we need to create an container and send to dropdown,
but with this */
@ -14,11 +17,10 @@ const propTypes = {
children: PropTypes.arrayOf((propValue, key, componentName, location, propFullName) => {
if (propValue[key].type !== ListItem &&
propValue[key].type !== ListSeparator &&
propValue[key].type !== ListTitle) {
return new Error(
`Invalid prop \`${propFullName}\` supplied to` +
` \`${componentName}\`. Validation failed.`,
);
propValue[key].type !== ListTitle &&
propValue[key].type !== UserActions) {
return new Error(`Invalid prop \`${propFullName}\` supplied to` +
` \`${componentName}\`. Validation failed.`);
}
return true;
}).isRequired,

View File

@ -1,14 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router';
import { defineMessages, injectIntl, intlShape } from 'react-intl';
import { defineMessages, injectIntl } from 'react-intl';
import Button from '/imports/ui/components/button/component';
import Modal from '/imports/ui/components/modal/fullscreen/component';
import styles from './styles';
const propTypes = {
handleEndMeeting: PropTypes.func.isRequired,
intl: PropTypes.shape(intlShape).isRequired,
intl: PropTypes.shape({
formatMessage: PropTypes.func.isRequired,
}).isRequired,
router: PropTypes.object.isRequired,
showEndMeeting: PropTypes.bool.isRequired,
};

View File

@ -8,7 +8,6 @@ import UserList from './component';
const propTypes = {
openChats: PropTypes.arrayOf(String).isRequired,
openChat: PropTypes.string.isRequired,
users: PropTypes.arrayOf(Object).isRequired,
currentUser: PropTypes.shape({}).isRequired,
meeting: PropTypes.shape({}).isRequired,
@ -23,12 +22,6 @@ const propTypes = {
toggleVoice: PropTypes.func.isRequired,
changeRole: PropTypes.func.isRequired,
roving: PropTypes.func.isRequired,
userActions: PropTypes.func.isRequired,
children: PropTypes.Object,
};
const defaultProps = {
children: {},
};
const UserListContainer = (props) => {
@ -36,10 +29,7 @@ const UserListContainer = (props) => {
users,
currentUser,
openChats,
openChat,
userActions,
isBreakoutRoom,
children,
meeting,
getAvailableActions,
normalizeEmojiName,
@ -59,35 +49,28 @@ const UserListContainer = (props) => {
meeting={meeting}
currentUser={currentUser}
openChats={openChats}
openChat={openChat}
isBreakoutRoom={isBreakoutRoom}
setEmojiStatus={setEmojiStatus}
assignPresenter={assignPresenter}
kickUser={kickUser}
toggleVoice={toggleVoice}
changeRole={changeRole}
userActions={userActions}
getAvailableActions={getAvailableActions}
normalizeEmojiName={normalizeEmojiName}
isMeetingLocked={isMeetingLocked}
isPublicChat={isPublicChat}
roving={roving}
>
{children}
</UserList>
/>
);
};
UserListContainer.propTypes = propTypes;
UserListContainer.defaultProps = defaultProps;
export default createContainer(({ params }) => ({
users: Service.getUsers(),
meeting: Meetings.findOne({}),
currentUser: Service.getCurrentUser(),
openChats: Service.getOpenChats(params.chatID),
openChat: params.chatID,
userActions: Service.userActions,
isBreakoutRoom: meetingIsBreakout(),
getAvailableActions: Service.getAvailableActions,
normalizeEmojiName: Service.normalizeEmojiName,

View File

@ -9,6 +9,22 @@ const propTypes = {
options: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
};
export default class UserActions extends React.PureComponent {
render() {
const { key, icon, label, handler, options } = this.props;
return (
<DropdownListItem
key={key}
icon={icon}
label={label}
defaultMessage={label}
onClick={() => handler.call(this, ...options)}
/>
);
}
}
/*
const UserActions = (props) => {
const { key, icon, label, handler, options } = props;
@ -23,7 +39,7 @@ const UserActions = (props) => {
);
return userAction;
};
};*/
UserActions.propTypes = propTypes;
export default UserActions;
//export default UserActions;

View File

@ -283,11 +283,12 @@ class UserListContent extends Component {
>
{
[
(<DropdownListTitle
description={intl.formatMessage(messages.menuTitleContext)}
key={_.uniqueId('dropdown-list-title')}
>
{user.name}
(
<DropdownListTitle
description={intl.formatMessage(messages.menuTitleContext)}
key={_.uniqueId('dropdown-list-title')}
>
{user.name}
</DropdownListTitle>),
(<DropdownListSeparator key={_.uniqueId('action-separator')} />),
].concat(actions)