<commit_before>import cx from 'classnames';
import React from 'react';
import AddIcon from 'material-ui/lib/svg-icons/content/add';
import EditIcon from 'material-ui/lib/svg-icons/editor/mode-edit';
import MoveToFirstIcon from 'material-ui/lib/svg-icons/hardware/keyboard-arrow-up';
import DeleteIcon from 'material-ui/lib/svg-icons/action/delete';
import { addMedia, moveMedia, removeMedia } from '../../actions/PlaylistActionCreators';
import AddingMenu from '../PlaylistManager/AddingMenu/Container';
import PlaylistStore from '../../stores/PlaylistStore';

export default class Actions extends React.Component {
  static propTypes = {
    className: React.PropTypes.string,
    media: React.PropTypes.object,
    selection: React.PropTypes.array
  };

  state = { adding: false };

  onAdd() {
    this.setState({ adding: true });
  }

  onAddTo(playlist) {
    this.setState({ adding: false });
    addMedia(playlist, [ this.props.media ]);
  }

  onEdit() {
  }

  onFirst() {
    // TODO use current selection instead
    // (and also do this in a much more high level component)
    moveMedia(PlaylistStore.getSelectedPlaylist()._id, this.props.selection, -1);
  }

  onDelete() {
    removeMedia(PlaylistStore.getSelectedPlaylist()._id, this.props.media._id);
  }

  render() {
    const { adding } = this.state;
    return (
      <div className={cx('MediaActions', this.props.className)}>
        <div
          className="MediaActions-action"
          onClick={::this.onAdd}
        >
          <AddIcon color="#fff" />
        </div>
        {adding && <AddingMenu onSelect={::this.onAddTo} />}
        <div<commit_msg>playlists: disable media actions, remove PlaylistStore dependency<commit_after>import cx from 'classnames';
import React from 'react';
import AddIcon from 'material-ui/lib/svg-icons/content/add';
import EditIcon from 'material-ui/lib/svg-icons/editor/mode-edit';
import MoveToFirstIcon from 'material-ui/lib/svg-icons/hardware/keyboard-arrow-up';
import DeleteIcon from 'material-ui/lib/svg-icons/action/delete';
import { addMedia } from '../../actions/PlaylistActionCreators';
import AddingMenu from '../PlaylistManager/AddingMenu/Container';

export default class Actions extends React.Component {
  static propTypes = {
    className: React.PropTypes.string,
    media: React.PropTypes.object,
    selection: React.PropTypes.array
  };

  state = { adding: false };

  onAdd() {
    // TODO add an action child component for adding media to playlists
    this.setState({ adding: true });
  }

  onAddTo(playlist) {
    this.setState({ adding: false });
    // FIXME dispatch this
    addMedia(playlist, [ this.props.media ]);
  }

  onEdit() {
    // TODO add an action child component for editing playlist items
  }

  onFirst() {
    // TODO add an Action child component for moving playlist items
  }

  onDelete() {
    // TODO add an Action child component for deleting playlist items
  }

  render() {
    const { adding } = this.state;
    return (
      <div className={cx('MediaActions', this.props.className)}>
        <div
          className="MediaActions-action"
          onClick={::this.onAdd}
        >
          <AddIcon color="#fff" />
        </div>
        {adding && <AddingMenu onSelect={::this.onAddTo} />}
        <div
{'fraction_non_alphanumeric': 0.13148261134838315, 'fraction_numerical': 0.0003050640634533252, 'mean_word_length': 3.203846153846154, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '230545', 'n_tokens_mistral': 979, 'n_tokens_neox': 965, 'n_words': 236}