<commit_before>import React, { Component } from 'react'
import PropTypes from 'prop-types'
import selectn from 'selectn'

import classNames from 'classnames'

import Pagination from 'views/components/Navigation/Pagination'

import { MenuItem, Select, TextField } from '@material-ui/core'

import UIHelpers from 'common/UIHelpers'
import IntlService from 'views/services/intl'

const intl = IntlService.instance
/**
 * HOC: Adds pagination to a grid list
 */
const { any, bool, func, object } = PropTypes
export default function withPagination(ComposedFilter, pageSize = 10, pageRange = 10) {
  class PaginatedGridList extends Component {
    static propTypes = {
      appendControls: any, // TODO: set appropriate propType
      disablePageSize: bool,
      fetcher: func.isRequired,
      fetcherParams: object.isRequired,
      metadata: object,
    }
    static defaultProps = {
      disablePageSize: false,
      fetcher: () => {},
      fetcherParams: {},
      metadata: {
        resultsCount: 0,
        pageCount: 0,
      },
    }

    constructor(props, context) {
      super(props, context)

      this.state = {
        pageRange: pageRange,
        initialPageSize: selectn('fetcherParams.pageSize', props) || pageSize,
        currentPageSize: selectn('fetcherParams.pageSize', props) || pageSize,
        currentPageIndex: 1,
      }
      ;['_onPageChange', '_onPageSizeChange', '_onGoToPage', '_getPageSizeControls'].forEach(
        (method) => (this[method] = this[method].bind(this))
      )
    }

    _onPageSizeChange(event) {
      const currentPageSize = event.target.value

      this.props.fetcher(
        Object.assign({}, this.props.fetcherParams, {
          currentPageIndex: this.state.currentPageIndex,
          pageSize: currentPageSize,
        })
      )

      this.setState({ currentPageSize: currentPageSize })
    }

    // TODO: Is `return false` intended?
    shouldComponentUpdate() {
      return false
    }

    _changePage(newPageIndex) {
      this.props.fetcher(
        Object.assign({}, this.props.fetcherParams, {
          currentPageIndex: newPageIndex,
          pageSize: this.state.currentPageSize,
        })
      )
<commit_msg>FW-697 kids story paging (#142)<commit_after>import React, { Component } from 'react'
import PropTypes from 'prop-types'
import selectn from 'selectn'

import classNames from 'classnames'

import Pagination from 'views/components/Navigation/Pagination'

import { MenuItem, Select, TextField } from '@material-ui/core'

import UIHelpers from 'common/UIHelpers'
import IntlService from 'views/services/intl'

const intl = IntlService.instance
/**
 * HOC: Adds pagination to a grid list
 */
const { any, bool, func, object } = PropTypes
export default function withPagination(ComposedFilter, pageSize = 10, pageRange = 10) {
  class PaginatedGridList extends Component {
    static propTypes = {
      appendControls: any, // TODO: set appropriate propType
      disablePageSize: bool,
      fetcher: func.isRequired,
      fetcherParams: object.isRequired,
      metadata: object,
    }
    static defaultProps = {
      disablePageSize: false,
      fetcher: () => {},
      fetcherParams: {},
      metadata: {
        resultsCount: 0,
        pageCount: 0,
      },
    }

    constructor(props, context) {
      super(props, context)

      this.state = {
        pageRange: pageRange,
        initialPageSize: selectn('fetcherParams.pageSize', props) || pageSize,
        currentPageSize: selectn('fetcherParams.pageSize', props) || pageSize,
        currentPageIndex: 1,
      }
      ;['_onPageChange', '_onPageSizeChange', '_onGoToPage', '_getPageSizeControls'].forEach(
        (method) => (this[method] = this[method].bind(this))
      )
    }

    _onPageSizeChange(event) {
      const currentPageSize = event.target.value

      this.props.fetcher(
        Object.assign({}, this.props.fetcherParams, {
          currentPageIndex: this.state.currentPageIndex,
          pageSize: currentPageSize,
        })
      )

      this.setState({ currentPageSize: currentPageSize })
    }

    _changePage(newPageIndex) {
      this.props.fetcher(
        Object.assign({}, this.props.fetcherParams, {
          currentPageIndex: newPageIndex,
          pageSize: this.state.currentPageSize,
        })
      )

{'fraction_non_alphanumeric': 0.1086603204086371, 'fraction_numerical': 0.0046436034362665425, 'mean_word_length': 2.9378427787934185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5045263', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1244, 'n_words': 284}