diff --git a/frontend/js/components/buttons/download.js b/frontend/js/components/buttons/download.js index 295278d..bf1581f 100644 --- a/frontend/js/components/buttons/download.js +++ b/frontend/js/components/buttons/download.js @@ -1,95 +1,81 @@ -import React from "react" +import React, { useState } from "react" +import PropTypes from "prop-types" +import { List } from "immutable" import { Button, Dropdown, MenuItem, Modal } from "react-bootstrap" -export default class DownloadButton extends React.PureComponent { - constructor(props) { - super(props); - this.showModal = this.showModal.bind(this); - this.hideModal = this.hideModal.bind(this); - this.state = { showModal: false }; - } - showModal() { - this.setState({ showModal: true }); - } - hideModal() { - this.setState({ showModal: false }); - } - render() { - if (this.props.url === "") { - return null; - } +const DownloadButton = (props) => { + if (props.url === "") { return null; } - let btnSize = "btn-sm"; - if (this.props.xs) { - btnSize = "btn-xs"; - } + const [showModal, setShowModal] = useState(false); - const infuse = `infuse://x-callback-url/play?url=${this.props.url}`; - return ( - - + + + setShowModal(true)}> - Download + Stream in browser - - - - - - Stream with infuse - - - - - Stream in browser - - - + + - - - - -  Browser streaming - - - - - - - - ); - } + setShowModal(false)} dialogClassName="player-modal"> + + + +  Browser streaming + + + + + + + + ); } +DownloadButton.propTypes = { + customClassName: PropTypes.string, + xs: PropTypes.bool, + url: PropTypes.string.isRequired, + subtitles: PropTypes.instanceOf(List), +}; +export default DownloadButton; -class Player extends React.PureComponent { - constructor(props) { - super(props); - } - render() { - const subtitles = this.props.subtitles; - const hasSubtitles = !(subtitles === undefined || subtitles === null || subtitles.size === 0); - return ( -
- -
- ); - } +const Player = (props) => { + const subtitles = props.subtitles; + const hasSubtitles = !(subtitles === undefined || subtitles === null || subtitles.size === 0); + return ( +
+ +
+ ); } +Player.propTypes = { + subtitles: PropTypes.instanceOf(List), + url: PropTypes.string.isRequired, +};