All files / nexshop-web-contents/src/component/playlist/playlist-editor playlist-editor.js

100% Statements 18/18
100% Branches 0/0
100% Functions 5/5
100% Lines 18/18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 701x 1x 1x 1x 1x 1x       5x 5x       1x       5x                                   1x 5x   5x     1x 5x 5x                   5x                         1x    
import React, {Component} from 'react';
import {connect} from "react-redux";
import PropTypes from 'prop-types';
import {bindActionCreators} from "redux";
import {previewActions, playlistActions} from "nexshop-web-store";
import PlaylistEditorView from "./playlist-editor-view";
 
class PlaylistEditor extends Component {
    constructor(props) {
        super(props);
        this.onSelectPreviewItem = this.onSelectPreviewItem.bind(this);
    }
 
    onSelectPreviewItem(index) {
        this.props.moveToPreview(index);
    }
 
    render() {
        return (
            <PlaylistEditorView resolution={this.props.resolution}
                                contentItems={this.props.contentItems}
                                blankIndex={this.props.blankIndex}
                                onDropDragContentsItem={this.props.actions.dropDragContentsItem}
                                onDeleteItem={this.props.actions.deleteContentItem}
                                onOrderChangeStart={this.props.actions.changeContentItemsOrderStart}
                                onOrderChangeProcess={this.props.actions.changeContentItemsOrderProcess}
                                onOrderChangeEnd={this.props.actions.changeContentItemsOrderEnd}
                                onSelectPreviewItem={this.onSelectPreviewItem}
                                onUpdateContentItemTransition={this.props.actions.updateContentItemTransition}
                                onUpdateContentItemDuration={this.props.actions.updateContentItemDuration}
                                onUpdateContentItemFitMode={this.props.actions.updateContentItemFitMode}
            />
        );
    }
}
 
const mapStateToProps = (state) => {
    let {playlist: {resolution, contentItems, blankIndex}} = state;
 
    return {resolution, contentItems, blankIndex};
};
 
const mapDispatchToProps = (dispatch) => {
    const {selectPreviewItem} = previewActions;
    const {
        changeContentItemsOrderEnd,
        changeContentItemsOrderProcess,
        changeContentItemsOrderStart,
        deleteContentItem,
        dropDragContentsItem,
        updateContentItemDuration,
        updateContentItemTransition,
        updateContentItemFitMode,
    } = playlistActions;
    return {
        actions: bindActionCreators({
            dropDragContentsItem, deleteContentItem,
            changeContentItemsOrderStart, changeContentItemsOrderProcess,
            changeContentItemsOrderEnd, selectPreviewItem,
            updateContentItemTransition, updateContentItemDuration,
            updateContentItemFitMode
        }, dispatch)
    }
};
 
export default connect(mapStateToProps, mapDispatchToProps)(PlaylistEditor);
 
PlaylistEditor.propTypes = {
    moveToPreview: PropTypes.func.isRequired
};