]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/episodes/Item.js
basic channel crew
[alttp.git] / resources / js / components / episodes / Item.js
index 5c6982972a6dbd57ca176bdfe0b296abb889d7ba..71fe49ed5c6875eb00d34848143160a75576fc02 100644 (file)
@@ -1,12 +1,16 @@
 import moment from 'moment';
 import PropTypes from 'prop-types';
 import React from 'react';
+import { Button } from 'react-bootstrap';
 import { useTranslation } from 'react-i18next';
 
 import Channels from './Channels';
 import Crew from './Crew';
 import MultiLink from './MultiLink';
 import Players from './Players';
+import Icon from '../common/Icon';
+import { canRestreamEpisode } from '../../helpers/permissions';
+import { withUser } from '../../helpers/UserContext';
 
 const isActive = episode => {
        if (!episode.start) return false;
@@ -16,7 +20,7 @@ const isActive = episode => {
        return start.isBefore(now) && end.isAfter(now);
 };
 
-const Item = ({ episode }) => {
+const Item = ({ episode, onAddRestream, onEditRestream, user }) => {
        const { t } = useTranslation();
 
        const classNames = [
@@ -53,13 +57,29 @@ const Item = ({ episode }) => {
                                                </div>
                                        : null}
                                </div>
-                               <div>
+                               <div className="episode-channel-links text-end">
                                        {hasChannels ?
-                                               <Channels channels={episode.channels} />
+                                               <Channels
+                                                       channels={episode.channels}
+                                                       episode={episode}
+                                                       onEditRestream={onEditRestream}
+                                               />
                                        : null}
                                        {!hasChannels && hasPlayers ?
                                                <MultiLink players={episode.players} />
                                        : null}
+                                       {onAddRestream && canRestreamEpisode(user, episode) ?
+                                               <div>
+                                                       <Button
+                                                               onClick={() => onAddRestream(episode)}
+                                                               variant="outline-secondary"
+                                                       >
+                                                               <Icon.ADD title="" />
+                                                               {' '}
+                                                               {t('episodes.addRestream')}
+                                                       </Button>
+                                               </div>
+                                       : null}
                                </div>
                        </div>
                        {hasPlayers ?
@@ -86,6 +106,10 @@ Item.propTypes = {
                start: PropTypes.string,
                title: PropTypes.string,
        }),
+       onAddRestream: PropTypes.func,
+       onEditRestream: PropTypes.func,
+       user: PropTypes.shape({
+       }),
 };
 
-export default Item;
+export default withUser(Item);