<commit_before>import React from 'react';
import PageButton from './PageButton.js';
import Const from '../Const';

class PaginationList extends React.Component {

  changePage(page) {
    if (page == this.props.prePage) {
      page = this.props.currPage - 1 < 1 ? 1 : this.props.currPage - 1;
    } else if (page == this.props.nextPage) {
      page = this.props.currPage + 1 > this.totalPages ? this.totalPages : this.props.currPage + 1;
    } else if (page == this.props.lastPage) {
      page = this.totalPages;
    } else if (page == this.props.firstPage) {
      page = 1;
    } else {
      page = parseInt(page);
    }

    if (page != this.props.currPage) {
      this.props.changePage(page, this.props.sizePerPage);
    }
  }

  changeSizePerPage(e) {
    e.preventDefault();

    const selectSize = parseInt(e.currentTarget.text);
    let { currPage } = this.props;
    if (selectSize != this.props.sizePerPage) {
      this.totalPages = Math.ceil(this.props.dataSize / selectSize);
      if (currPage > this.totalPages)
        currPage = this.totalPages;

      this.props.changePage(currPage, selectSize);
      if(this.props.onSizePerPageList){
        this.props.onSizePerPageList(selectSize);
      }
    }
  }

  render() {
    this.totalPages = Math.ceil(this.props.dataSize / this.props.sizePerPage);
    var pageBtns = this.makePage();
    var pageListStyle = {
      float: "right",
      marginTop: "0px"  //override the margin-top defined in .pagination class in bootstrap.
    }

    var sizePerPageList = this.props.sizePerPageList.map((sizePerPage) => {
      return (
        <li key={sizePerPage} role="presentation">
          <a role="menuitem" tabIndex="-1" href="#" onClick={this.changeSizePerPage.bind(this)}>{sizePerPage}</a>
        </li>
      );
    });

    return (
      <div className="row" style={{ marginTop: 15 }}>
        {
          this.props.sizePerPageList.length > 1
          ? <div className="col-md-6">
              <div className="dropdown">
                <button className="btn btn-default dropdown-toggle" type="button" id="pageDropDown" data-toggle="dropdown"
                        aria-expanded="true">
                  {this.props.sizePerPage}
                  <span>
                    {" "}
                    <span className="caret"/>
                  </span>
                </button>
                <ul className="dropdown-menu" role="menu" aria-labelledby="pageDropDown">
                  {sizePerPageList}
                </ul>
              </div>
              <div className="col-md-6">
                <ul className="pagination" style={pageListStyle}>
                  {pageBtns}
                </ul>
              </div>
            </div>
          : <div className="col-md-12">
              <ul className="pagination" style={pageListStyle}>
                {pageBtns}
              </ul>
            </div>
        }
      </div>
    )
  }

  makePage() {<commit_msg>Fixed the ternary syntax to produce expected behavior<commit_after>import React from 'react';
import PageButton from './PageButton.js';
import Const from '../Const';

class PaginationList extends React.Component {

  changePage(page) {
    if (page == this.props.prePage) {
      page = this.props.currPage - 1 < 1 ? 1 : this.props.currPage - 1;
    } else if (page == this.props.nextPage) {
      page = this.props.currPage + 1 > this.totalPages ? this.totalPages : this.props.currPage + 1;
    } else if (page == this.props.lastPage) {
      page = this.totalPages;
    } else if (page == this.props.firstPage) {
      page = 1;
    } else {
      page = parseInt(page);
    }

    if (page != this.props.currPage) {
      this.props.changePage(page, this.props.sizePerPage);
    }
  }

  changeSizePerPage(e) {
    e.preventDefault();

    const selectSize = parseInt(e.currentTarget.text);
    let { currPage } = this.props;
    if (selectSize != this.props.sizePerPage) {
      this.totalPages = Math.ceil(this.props.dataSize / selectSize);
      if (currPage > this.totalPages)
        currPage = this.totalPages;

      this.props.changePage(currPage, selectSize);
      if(this.props.onSizePerPageList){
        this.props.onSizePerPageList(selectSize);
      }
    }
  }

  render() {
    this.totalPages = Math.ceil(this.props.dataSize / this.props.sizePerPage);
    var pageBtns = this.makePage();
    var pageListStyle = {
      float: "right",
      marginTop: "0px"  //override the margin-top defined in .pagination class in bootstrap.
    }

    var sizePerPageList = this.props.sizePerPageList.map((sizePerPage) => {
      return (
        <li key={sizePerPage} role="presentation">
          <a role="menuitem" tabIndex="-1" href="#" onClick={this.changeSizePerPage.bind(this)}>{sizePerPage}</a>
        </li>
      );
    });

    return (
      <div className="row" style={{ marginTop: 15 }}>
        {
          this.props.sizePerPageList.length > 1
          ? <div>
              <div className="col-md-6">
                  <div className="dropdown">
                    <button className="btn btn-default dropdown-toggle" type="button" id="pageDropDown" data-toggle="dropdown"
                            aria-expanded="true">
                      {this.props.sizePerPage}
                      <span>
                        {" "}
                        <span className="caret"/>
                      </span>
                    </button>
                    <ul className="dropdown-menu" role="menu" aria-labelledby="pageDropDown">
                      {sizePerPageList}
                    </ul>
                  </div>
                </div>
                <div className="col-md-6">
                  <ul className="pagination" style={pageListStyle}>
                    {pageBtns}
                  </ul>
                </div>
              </div>
          : <div className="col-md-12">
              <ul className="pagination" style={pageListStyle}>
                {pageBtns}
              </ul>
            </div>
        }
      </div>
    )
  }

  makePage() {
{'fraction_non_alphanumeric': 0.13484073279419045, 'fraction_numerical': 0.005281399570886285, 'mean_word_length': 1.8357510528778662, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 63, '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': '5607603', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1767, 'n_words': 345}