import { Button } from 'react-bootstrap';
import Icon from '../common/Icon';
+import { mayEditRestream } from '../../helpers/permissions';
+import { useUser } from '../../hooks/user';
-const Channel = ({ channel }) =>
- <div className="episode-channel">
+const Channel = ({ channel, episode, onEditRestream }) => {
+ const { user } = useUser();
+
+ return <div className="episode-channel text-nowrap">
<Button
href={channel.stream_link}
rel="noreferer"
{' '}
{channel.short_name || channel.title}
</Button>
+ {onEditRestream && mayEditRestream(user, episode, channel) ?
+ <Button
+ className="ms-1"
+ onClick={() => onEditRestream(episode, channel)}
+ variant="outline-secondary"
+ >
+ <Icon.SETTINGS />
+ </Button>
+ : null}
</div>;
+};
Channel.propTypes = {
channel: PropTypes.shape({
stream_link: PropTypes.string,
title: PropTypes.string,
}),
+ episode: PropTypes.shape({
+ }),
+ onEditRestream: PropTypes.func,
};
export default Channel;