<commit_before>import React, { Component } from 'react';
import CSSModules from 'react-css-modules';
import { inject } from 'mobx-react';
import autobind from 'autobind-decorator';

import ContextMenu from 'components/ContextMenu';

import styles from './styles/index.css';

@inject('view_store', 'torrents_store')
@CSSModules(styles)
class TorrentContextMenu extends Component {
  @autobind onToggleSortByContextMenu() {
    this.props.view_store.toggleSortByContextMenu();
  }

  @autobind onToggleContextMenu() {
    // TODO: Move it to ContextMenu component
    this.props.view_store.toggleContextMenus();
  }

  @autobind onSetSortCriteria(sortCriteria) {
    this.props.torrents_store.setSortCriteria(sortCriteria)
  }

  render() {
    const { sortCriteria, sortDirection } = this.props.torrents_store;

    return (
      <ContextMenu
        show={this.props.show}
        container={this.props.container}
        target={this.props.target}
        onHide={this.props.onHide}
      >
        <ul
          styleName='torrentMenu'
          onClick={this.onToggleContextMenu}
          onMouseEnter={this.onToggleSortByContextMenu}
          onMouseLeave={this.onToggleSortByContextMenu}
        >
          <li styleName={sortCriteria === 'queue_order' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'queue_order')}>Queue Order</li>
          <li styleName={sortCriteria === 'activity' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'activity')}>Activity</li>
          <li styleName={sortCriteria === 'age' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'age')}>Age</li>
          <li styleName={sortCriteria === 'name' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'name')}>Name</li>
          <li styleName={sortCriteria === 'percent_completed' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'percent_completed')}>Progress</li>
          <li styleName={sortCriteria === 'ratio' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'ratio')}>Ratio</li>
          <li styleName={sortCriteria === 'size' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'size')}>Size</li>
          <li styleName={sortCriteria === 'state' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'state')}>State</li>
          <li styleName='torrentMenuSeparator' />
          <li styleName={sortDirection === 'ascending' ? 'torrentMenuSelected' : 'torrentMenuItem'}>Reverse Sort Order</li>
        </ul>
      </ContextMenu>
    );
  }
}

export default TorrentContextMenu;<commit_msg>Rename context menu<commit_after>import React, { Component } from 'react';
import CSSModules from 'react-css-modules';
import { inject } from 'mobx-react';
import autobind from 'autobind-decorator';

import ContextMenu from 'components/ContextMenu';

import styles from './styles/index.css';

@inject('view_store', 'torrents_store')
@CSSModules(styles)
class SortByContextMenu extends Component {
  @autobind onToggleSortByContextMenu() {
    this.props.view_store.toggleSortByContextMenu();
  }

  @autobind onToggleContextMenu() {
    // TODO: Move it to ContextMenu component
    this.props.view_store.toggleContextMenus();
  }

  @autobind onSetSortCriteria(sortCriteria) {
    this.props.torrents_store.setSortCriteria(sortCriteria)
  }

  render() {
    const { sortCriteria, sortDirection } = this.props.torrents_store;

    return (
      <ContextMenu
        show={this.props.show}
        container={this.props.container}
        target={this.props.target}
        onHide={this.props.onHide}
      >
        <ul
          styleName='torrentMenu'
          onClick={this.onToggleContextMenu}
          onMouseEnter={this.onToggleSortByContextMenu}
          onMouseLeave={this.onToggleSortByContextMenu}
        >
          <li styleName={sortCriteria === 'queue_order' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'queue_order')}>Queue Order</li>
          <li styleName={sortCriteria === 'activity' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'activity')}>Activity</li>
          <li styleName={sortCriteria === 'age' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'age')}>Age</li>
          <li styleName={sortCriteria === 'name' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'name')}>Name</li>
          <li styleName={sortCriteria === 'percent_completed' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'percent_completed')}>Progress</li>
          <li styleName={sortCriteria === 'ratio' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'ratio')}>Ratio</li>
          <li styleName={sortCriteria === 'size' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'size')}>Size</li>
          <li styleName={sortCriteria === 'state' ? 'torrentMenuSelected' : 'torrentMenuItem'} onClick={this.onSetSortCriteria.bind(this, 'state')}>State</li>
          <li styleName='torrentMenuSeparator' />
          <li styleName={sortDirection === 'ascending' ? 'torrentMenuSelected' : 'torrentMenuItem'}>Reverse Sort Order</li>
        </ul>
      </ContextMenu>
    );
  }
}

export default SortByContextMenu;
{'fraction_non_alphanumeric': 0.14331780723754928, 'fraction_numerical': 0.0, 'mean_word_length': 4.457478005865102, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, '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': '4030211', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1668, 'n_words': 269}