import React from 'react'; import PropTypes from 'prop-types'; import { injectIntl, FormattedMessage } from 'react-intl'; import Column from 'mastodon/components/column'; import Button from 'mastodon/components/button'; import { Helmet } from 'react-helmet'; import { Link } from 'react-router-dom'; import classNames from 'classnames'; import { autoPlayGif } from 'mastodon/initial_state'; class GIF extends React.PureComponent { static propTypes = { src: PropTypes.string.isRequired, staticSrc: PropTypes.string.isRequired, className: PropTypes.string, animate: PropTypes.bool, }; static defaultProps = { animate: autoPlayGif, }; state = { hovering: false, }; handleMouseEnter = () => { const { animate } = this.props; if (!animate) { this.setState({ hovering: true }); } } handleMouseLeave = () => { const { animate } = this.props; if (!animate) { this.setState({ hovering: false }); } } render () { const { src, staticSrc, className, animate } = this.props; const { hovering } = this.state; return ( ); } } class CopyButton extends React.PureComponent { static propTypes = { children: PropTypes.node.isRequired, value: PropTypes.string.isRequired, }; state = { copied: false, }; handleClick = () => { const { value } = this.props; navigator.clipboard.writeText(value); this.setState({ copied: true }); this.timeout = setTimeout(() => this.setState({ copied: false }), 700); } componentWillUnmount () { if (this.timeout) clearTimeout(this.timeout); } render () { const { children } = this.props; const { copied } = this.state; return ( ); } } export default @injectIntl class BundleColumnError extends React.PureComponent { static propTypes = { errorType: PropTypes.oneOf(['routing', 'network', 'error']), onRetry: PropTypes.func, intl: PropTypes.object.isRequired, multiColumn: PropTypes.bool, stacktrace: PropTypes.string, }; static defaultProps = { errorType: 'routing', }; handleRetry = () => { const { onRetry } = this.props; if (onRetry) { onRetry(); } } render () { const { errorType, multiColumn, stacktrace } = this.props; let title, body; switch(errorType) { case 'routing': title = ; body = ; break; case 'network': title = ; body = ; break; case 'error': title = ; body = ; break; } return (

{title}

{body}

{errorType === 'network' && } {errorType === 'error' && }
); } }