bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx

70 lines
1.9 KiB
React
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
2016-08-03 06:55:20 +08:00
import { createContainer } from 'meteor/react-meteor-data';
import PresentationToolbarService from './service';
import PresentationToolbar from './component';
2016-08-03 06:55:20 +08:00
const PresentationToolbarContainer = ({ ...props }) => {
const {
currentSlideNum,
userIsPresenter,
numberOfSlides,
actions,
} = props;
2016-08-03 06:55:20 +08:00
if (userIsPresenter) {
// Only show controls if user is presenter
return (
<PresentationToolbar
currentSlideNum={currentSlideNum}
numberOfSlides={numberOfSlides}
actions={actions}
/>
);
2016-08-03 06:55:20 +08:00
}
return null;
};
2016-08-03 06:55:20 +08:00
export default createContainer((params) => {
const data = PresentationToolbarService.getSlideData(params);
2016-08-06 02:39:24 +08:00
const {
userIsPresenter,
numberOfSlides,
} = data;
return {
userIsPresenter,
numberOfSlides,
actions: {
nextSlideHandler: () =>
PresentationToolbarService.nextSlide(params.currentSlideNum, numberOfSlides),
2016-08-06 02:39:24 +08:00
previousSlideHandler: () =>
PresentationToolbarService.previousSlide(params.currentSlideNum, numberOfSlides),
2017-06-03 03:25:02 +08:00
skipToSlideHandler: event =>
PresentationToolbarService.skipToSlide(event),
2016-08-06 02:39:24 +08:00
},
};
}, PresentationToolbarContainer);
2016-08-03 06:55:20 +08:00
PresentationToolbarContainer.propTypes = {
// Number of current slide being displayed
currentSlideNum: PropTypes.number.isRequired,
// PresentationId of the current presentation
presentationId: PropTypes.string.isRequired,
// Is the user a presenter
userIsPresenter: PropTypes.bool.isRequired,
// Total number of slides in this presentation
numberOfSlides: PropTypes.number.isRequired,
// Actions required for the presenter toolbar
actions: PropTypes.shape({
nextSlideHandler: PropTypes.func.isRequired,
previousSlideHandler: PropTypes.func.isRequired,
skipToSlideHandler: PropTypes.func.isRequired,
}).isRequired,
};