<commit_before>import PropTypes from 'prop-types';
import React from 'react';
import {NavLink} from 'fluxible-router';
import {connectToStores} from 'fluxible-addons-react';
import ActivityFeedStore from '../../../stores/ActivityFeedStore';
import ContentStore from '../../../stores/ContentStore';
import {isLocalStorageOn} from '../../../common.js';
import ReactList from 'react-list';

class PresentationsPanel extends React.Component {
    getPresentationHref(){
        let presLocation = '/presentation/' + this.props.ContentStore.selector.id + '/';
        if(!this.props.ContentStore.selector.subdeck){

            presLocation += this.props.ContentStore.selector.id + '/';
        }
        else{
            presLocation += this.props.ContentStore.selector.subdeck + '/';
        }
        if(this.props.ContentStore.selector.stype === 'slide'){
            // presLocation += this.props.ContentStore.selector.sid + '/';
            presLocation += this.props.ContentStore.selector.sid;// + '/';
        }
        return presLocation;
    }
    handlePresentationRoomClick(e){
        if(process.env.BROWSER){
            e.preventDefault();
            swal({
                title: 'Please enter a room name',
                input: 'text',
                showCancelButton: true,
                confirmButtonText: 'Next',
                allowOutsideClick: false
            }).then((roomName) => {
                window.open('/presentationbroadcast?room=' + roomName + '&presentation=' + this.getPresentationHref().replace('#', '%23'));
            }).catch();
        }
    }

    componentWillMount() {

    }

    renderItem(index, key) {
        let url = '/presentationbroadcast?room='+this.props.ActivityFeedStore.presentations[index].roomName+'&presentation=/Presentation/'+this.props.ActivityFeedStore.selector.sid;
        return (
            <div className="ui item" key={key} style={{ margin: '1em 0'}}>
                <div className="ui feed">
                    <div className="event">
                        <div className="activity-icon">
                            <i className="ui large record icon"></i>
                        </div>
                        <div className="content" style={{marginLeft: '1em'}}>
                            <div className="summary">
                                <a target="_blank" href={url} rel="nofollow">{this.props.ActivityFeedStore.presentations[index].roomName} (opened at {new Date(this.props.ActivityFeedStore.presentations[index].openingTime).toLocaleTimeString()})</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        );
    }

    render() {
        const panelDIVStyles = {
            maxHeight: 280,
            overflowY: 'auto'
        };

        return (
            <div ref="presentationPanel">
                <h5 className="ui small header" tabIndex="0">Beta features
                    <i className="yellow warning sign icon"></i>
                </h5>
                <div className="ui basic segment" style={panelDIVStyles}>
                    <h5 className="ui small header" tabIndex="0">Presentations Room
                    </h5>
                    <div className="two column grid">
                        <div className="column">
                            <button style={{marginLeft: '4em'}} onClick={this.handlePresentationRoomClick.bind(this)} className="ui button" type="button" aria-label="Presentation Room Mode, Beta" data-tooltip="Start Presentation Room (beta_)">
                                <i className="record large icon"></i>
                            </button>
                        </div>
                        <div className="column">Create a presentation room to broadcast your slideshow and invite participants</div>
                    </div>
                    <div className="ui divider"></div>
                    <div ref="presentationList">
                        {(this.props.ActivityFeedStore.presentations.length < 1)
                            ?
                            <div>There are currently no live presentations for this deck.</div>
                            :
                            <ReactList ref="infiniteList" className="ui list"
                                itemRenderer={this.renderItem.bind(this)}
                                length={this.props.ActivityFeedStore.presentations.length}
                                type={'simple'}>
                        </ReactList>
                        }
                    </div>
                </div>
            </div>
        );
    }
}

PresentationsPanel.contextTypes = {
    executeAction: PropTypes.func.isRequired
};
PresentationsPanel = connectToStores(PresentationsPanel, [ActivityFeedStore, ContentStore], (context, props) => {
    return {
        ActivityFeedStore: context.getStore(ActivityFeedStore).getState(),
        ContentStore: context.getStore(ContentStore).getState()
    };
});
export default PresentationsPanel;<commit_msg>Reused util presentation mode url creation for presentation rooms, fixes SWIK-2367<commit_after>import React from 'react';
import ReactList from 'react-list';
import { isEmpty } from '../../../common';
import { makeNodeURL } from '../../common/Util';
import { connectToStores } from 'fluxible-addons-react';
import ContentStore from '../../../stores/ContentStore';
import ActivityFeedStore from '../../../stores/ActivityFeedStore';

class PresentationsPanel extends React.Component {

    handlePresentationRoomClick(e){
        if(process.env.BROWSER){
            e.preventDefault();
            swal({
                title: 'Please enter a room name',
                input: 'text',
                showCancelButton: true,
                confirmButtonText: 'Next',
                allowOutsideClick: false
            }).then((result) => {
                if( !isEmpty(result.dismiss) ) {
                    return;
                } else if ( !isEmpty(result.value) ) {
                    let presentationURL = makeNodeURL(this.props.ContentStore.selector, 'presentation', undefined, undefined, undefined);
                    window.open('/presentationbroadcast?room=' + result.value + '&presentation=' + presentationURL.replace('#', '%23'));
                } else
                    swal({title: 'Please enter a valid room name', showConfirmButton: false, timer: 2000});
            }).catch((e) => {return true;});
        }
    }

    renderItem(index, key) {
        let url = '/presentationbroadcast?room='+this.props.ActivityFeedStore.presentations[index].roomName+'&presentation=/Presentation/'+this.props.ActivityFeedStore.selector.sid;
        return (
            <div className="ui item" key={key} style={{ margin: '1em 0'}}>
                <div className="ui feed">
                    <div className="event">
                        <div className="activity-icon">
                            <i className="ui large record icon"></i>
                        </div>
                        <div className="content" style={{marginLeft: '1em'}}>
                            <div className="summary">
                                <a target="_blank" href={url} rel="nofollow">{this.props.ActivityFeedStore.presentations[index].roomName} (opened at {new Date(this.props.ActivityFeedStore.presentations[index].openingTime).toLocaleTimeString()})</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        );
    }

    render() {
        const panelDIVStyles = {
            maxHeight: 280,
            overflowY: 'auto'
        };

        return (
            <div ref="presentationPanel">
                <h5 className="ui small header" tabIndex="0">Beta features
                    <i className="yellow warning sign icon"></i>
                </h5>
                <div className="ui basic segment" style={panelDIVStyles}>
                    <h5 className="ui small header" tabIndex="0">Presentations Room
                    </h5>
                    <div className="two column grid">
                        <div className="column">
                            <button style={{marginLeft: '4em'}} onClick={this.handlePresentationRoomClick.bind(this)} className="ui button" type="button" aria-label="Presentation Room Mode, Beta" data-tooltip="Start Presentation Room (beta_)">
                                <i className="record large icon"></i>
                            </button>
                        </div>
                        <div className="column">Create a presentation room to broadcast your slideshow and invite participants</div>
                    </div>
                    <div className="ui divider"></div>
                    <div ref="presentationList">
                        {(this.props.ActivityFeedStore.presentations.length < 1)
                            ?
                            <div>There are currently no live presentations for this deck.</div>
                            :
                            <ReactList ref="infiniteList" className="ui list"
                                itemRenderer={this.renderItem.bind(this)}
                                length={this.props.ActivityFeedStore.presentations.length}
                                type={'simple'}>
                        </ReactList>
                        }
                    </div>
                </div>
            </div>
        );
    }
}

PresentationsPanel = connectToStores(PresentationsPanel, [ActivityFeedStore, ContentStore], (context, props) => {
    return {
        ActivityFeedStore: context.getStore(ActivityFeedStore).getState(),
        ContentStore: context.getStore(ContentStore).getState(),
    };
});

export default PresentationsPanel;
{'fraction_non_alphanumeric': 0.12231237322515214, 'fraction_numerical': 0.004056795131845842, 'mean_word_length': 1.6680194805194806, 'pattern_counts': {'":': 0, '<': 93, '<?xml version=': 0, '>': 96, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1207940', 'n_tokens_mistral': 2444, 'n_tokens_neox': 2317, 'n_words': 499}