Merge pull request #4420 from Gcampes/fix-breakout-logout

[HTML5] Fix breakout logout
This commit is contained in:
Anton Georgiev 2017-09-22 10:58:48 -04:00 committed by GitHub
commit a356ef907c
3 changed files with 54 additions and 50 deletions

View File

@ -1,9 +1,17 @@
import React, { Component } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router';
import { defineMessages, injectIntl } from 'react-intl';
import { defineMessages, injectIntl, intlShape } from 'react-intl';
import Button from '/imports/ui/components/button/component';
import Modal from '/imports/ui/components/modal/fullscreen/component';
import styles from './styles.scss';
import styles from './styles';
const propTypes = {
handleEndMeeting: PropTypes.func.isRequired,
intl: PropTypes.shape(intlShape).isRequired,
router: PropTypes.object.isRequired,
showEndMeeting: PropTypes.bool.isRequired,
};
const intlMessages = defineMessages({
title: {
@ -40,12 +48,12 @@ const intlMessages = defineMessages({
},
});
class LeaveConfirmation extends Component {
render() {
const { intl, router, endMeeting, isModerator } = this.props;
return (
const LeaveConfirmation = ({
intl,
router,
handleEndMeeting,
showEndMeeting,
}) => (
<Modal
title={intl.formatMessage(intlMessages.title)}
confirm={{
@ -60,18 +68,18 @@ class LeaveConfirmation extends Component {
}}
>
{intl.formatMessage(intlMessages.message)}
{isModerator ?
{showEndMeeting ?
<Button
className={styles.endMeeting}
label={intl.formatMessage(intlMessages.endMeetingLabel)}
onClick={endMeeting}
onClick={handleEndMeeting}
aria-describedby={'modalEndMeetingDesc'}
/> : null
}
<div id="modalEndMeetingDesc" hidden>{intl.formatMessage(intlMessages.endMeetingDesc)}</div>
</Modal>
);
}
}
);
LeaveConfirmation.propTypes = propTypes;
export default withRouter(injectIntl(LeaveConfirmation));

View File

@ -1,22 +1,14 @@
import React, { Component } from 'react';
import React from 'react';
import { createContainer } from 'meteor/react-meteor-data';
import LogoutConfirmation from './component';
import LogoutConfirmationService from './service';
class LogoutConfirmationContainer extends Component {
constructor(props) {
super(props);
}
render() {
return (
const LogoutConfirmationContainer = () => (
<LogoutConfirmation {...this.props} />
);
}
}
);
export default createContainer(() => ({
isModerator: LogoutConfirmationService.isModerator(),
showEndMeeting: !LogoutConfirmationService.isBreakout() &&
LogoutConfirmationService.isModerator(),
endMeeting: LogoutConfirmationService.endMeeting,
}), LogoutConfirmationContainer);

View File

@ -1,5 +1,6 @@
import { makeCall } from '/imports/ui/services/api/index.js';
import { makeCall } from '/imports/ui/services/api/index';
import Users from '/imports/api/2.0/users';
import Breakouts from '/imports/api/2.0/breakouts';
import mapUser from '/imports/ui/services/user/mapUser';
import Auth from '/imports/ui/services/auth';
@ -14,7 +15,10 @@ const isModerator = () => {
return (currentUser) ? mapUser(currentUser).isModerator : null;
};
const isBreakout = () => Breakouts.findOne({ breakoutId: Auth.meetingID });
export default {
endMeeting,
isModerator,
isBreakout,
};