<commit_before>import React, { PureComponent, PropTypes } from 'react';
import FlatButton from 'material-ui/FlatButton';
import Popover from 'material-ui/Popover';
import Menu from 'material-ui/Menu';
import MenuItem from 'material-ui/MenuItem';
import Divider from 'material-ui/Divider';
import AVPlayCircleOutline from 'material-ui/svg-icons/av/play-circle-outline';
import NavigationRefresh from 'material-ui/svg-icons/navigation/refresh';
import { fade } from 'material-ui/utils/colorManipulator';


export default class PlayMenu extends PureComponent {

  static propTypes = {
    getFiles: PropTypes.func.isRequired,
    setLocation: PropTypes.func.isRequired,
    href: PropTypes.string.isRequired,
    localization: PropTypes.object.isRequired,
  };

  static contextTypes = {
    muiTheme: PropTypes.object.isRequired,
  };

  state = {
    open: false,
    anchorEl: null,
    // [...{ title, href(name) }]
    entries: [],
  };

  handlePlay = (event) => {
    const files = this.props.getFiles()
      .filter((file) => file.is('html'));

    if (files.length === 0) {
      this.props.setLocation({
        href: '',
      });
      return;
    }
    if (files.length === 1) {
      this.props.setLocation({
        href: files[0].name,
      });
      return;
    }

    const parser = new DOMParser();
    const entries = files
      .map((file) => {
        const doc = parser.parseFromString(file.text, 'text/html');
        const titleNode = doc.querySelector('title');
        const title = titleNode && titleNode.textContent;
        return {
          title: title || file.name,
          href: file.name,
        };
      })
      .sort((a, b) => a.title > b.title ? 1 : -1);

    this.setState({
      open: true,
      anchorEl: event.currentTarget,
      entries,
    });
  };

  handleItemTouchTap = (event, menuItem, index) => {
    this.props.setLocation({
      href: this.state.entries[index].href,
    });
    this.setState({
      open: false,
    });
  };

  handleRequestClose = () => {
    this.setState({
      open: false,
    });
  };

  renderMenu = (entry) => {<commit_msg>Fix ref<commit_after>import React, { PureComponent, PropTypes } from 'react';
import FlatButton from 'material-ui/FlatButton';
import Popover from 'material-ui/Popover';
import Menu from 'material-ui/Menu';
import MenuItem from 'material-ui/MenuItem';
import Divider from 'material-ui/Divider';
import AVPlayCircleOutline from 'material-ui/svg-icons/av/play-circle-outline';
import NavigationRefresh from 'material-ui/svg-icons/navigation/refresh';
import { fade } from 'material-ui/utils/colorManipulator';


export default class PlayMenu extends PureComponent {

  static propTypes = {
    getFiles: PropTypes.func.isRequired,
    setLocation: PropTypes.func.isRequired,
    href: PropTypes.string.isRequired,
    localization: PropTypes.object.isRequired,
  };

  static contextTypes = {
    muiTheme: PropTypes.object.isRequired,
  };

  state = {
    open: false,
    anchorEl: null,
    // [...{ title, href(name) }]
    entries: [],
  };

  handlePlay = (event) => {
    const files = this.props.getFiles()
      .filter((file) => file.is('html'));

    if (files.length === 0) {
      this.props.setLocation({
        href: '',
      });
      return;
    }
    if (files.length === 1) {
      this.props.setLocation({
        href: files[0].name,
      });
      return;
    }

    const parser = new DOMParser();
    const entries = files
      .map((file) => {
        const doc = parser.parseFromString(file.text, 'text/html');
        const titleNode = doc.querySelector('title');
        const title = titleNode && titleNode.textContent;
        return {
          title: title || file.name,
          href: file.name,
        };
      })
      .sort((a, b) => a.title > b.title ? 1 : -1);

    this.setState({
      open: true,
      anchorEl: event.currentTarget,
      entries,
    });
  };

  handleItemTouchTap = (event, menuItem) => {
    this.props.setLocation({
      href: menuItem.props.value,
    });
    this.setState({
      open: false,
    });
  };

  handleRequestClose = () => {
    this.setState({
      open: false,
    });
  };

  renderMenu = (entry) => {
{'fraction_non_alphanumeric': 0.14608612895550796, 'fraction_numerical': 0.0023792529145848203, 'mean_word_length': 2.6179001721170394, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '6931065', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1296, 'n_words': 278}