<commit_before>import React, { useEffect } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { msg } from '_/intl'
import { getByPage } from '_/actions'
import { filterVms, sortFunction } from '_/utils'

import useInfiniteScroll from '@closeio/use-infinite-scroll'
import Vm from './Vm'
import Pool from './Pool'

import style from './style.css'

/**
 * Use Patternfly 'Single Select Card View' pattern to show every VM and Pool
 * available to the current user.
 */
const VmCardList = ({ vms, alwaysShowPoolCard, fetchMoreVmsAndPools }) => {
  const sort = vms.get('sort').toJS()
  const filters = vms.get('filters').toJS()

  // Filter the VMs (1. apply the filter bar criteria, 2. only show Pool VMs if the Pool exists)
  const filteredVms = vms.get('vms')
    .filter(vm => filterVms(vm, filters))
    .filter(vm => vm.getIn(['pool', 'id'], false) ? !!vms.getIn(['pools', vm.getIn(['pool', 'id'])], false) : true)
    .toList()
    .map(vm => vm.set('isVm', true))

  // Filter the Pools (only show a Pool card if the user can currently 'Take' a VM from it)
  const filteredPools = vms.get('pools')
    .filter(pool => alwaysShowPoolCard || (pool.get('vmsCount') < pool.get('maxUserVms') && pool.get('size') > 0 && filterVms(pool, filters)))
    .toList()

  // Display the VMs and Pools together, sorted nicely
  const vmsAndPools = [ ...filteredVms, ...filteredPools ].sort(sortFunction(sort))

  // Handle the infinite scroll and pagination
  const hasMore = vms.get('vmsExpectMorePages') || vms.get('poolsExpectMorePages')
  const [ page, sentinelRef, scrollerRef ] = useInfiniteScroll({ hasMore, distance: 0 })

  useEffect(() => { // `refreshListPage` handles loading the first page of data
    if (page > 0) {<commit_msg>Display Pool entities containing search term when filtering<commit_after>import React, { useEffect } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { msg } from '_/intl'
import { getByPage } from '_/actions'
import { filterVms, sortFunction } from '_/utils'

import useInfiniteScroll from '@closeio/use-infinite-scroll'
import Vm from './Vm'
import Pool from './Pool'

import style from './style.css'

/**
 * Use Patternfly 'Single Select Card View' pattern to show every VM and Pool
 * available to the current user.
 */
const VmCardList = ({ vms, alwaysShowPoolCard, fetchMoreVmsAndPools }) => {
  const sort = vms.get('sort').toJS()
  const filters = vms.get('filters').toJS()

  // Filter the VMs (1. apply the filter bar criteria, 2. only show Pool VMs if the Pool exists)
  const filteredVms = vms.get('vms')
    .filter(vm => filterVms(vm, filters))
    .filter(vm => vm.getIn(['pool', 'id'], false) ? !!vms.getIn(['pools', vm.getIn(['pool', 'id'])], false) : true)
    .toList()
    .map(vm => vm.set('isVm', true))

  // Filter the Pools (only show a Pool card if the user can currently 'Take' a VM from it)
  const filteredPools = vms.get('pools')
    .filter(pool =>
      (alwaysShowPoolCard || (pool.get('vmsCount') < pool.get('maxUserVms') && pool.get('size') > 0)) &&
      filterVms(pool, filters)
    )
    .toList()

  // Display the VMs and Pools together, sorted nicely
  const vmsAndPools = [ ...filteredVms, ...filteredPools ].sort(sortFunction(sort))

  // Handle the infinite scroll and pagination
  const hasMore = vms.get('vmsExpectMorePages') || vms.get('poolsExpectMorePages')
  const [ page, sentinelRef, scrollerRef ] = useInfiniteScroll({ hasMore, distance: 0 })

  useEffect(() => { // `refreshListPage` handles loading the first page of data
    if (page > 0) {
{'fraction_non_alphanumeric': 0.14937759336099585, 'fraction_numerical': 0.0027662517289073307, 'mean_word_length': 3.960219478737997, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5378864', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1158, 'n_words': 369}