text: import React from 'react';
  import PropTypes from 'prop-types';
  import { flowRight } from 'lodash';
  
  import { stripesConnect } from '@folio/stripes/core';
  
  import withLocation from '../withLocation';
  import { InstancesView } from '../views';
  import {
    getFilterConfig,
  } from '../filterConfig';
  import { buildManifestObject } from './buildManifestObject';
  import { DataContext } from '../contexts';
  
  class InstancesRoute extends React.Component {
    static propTypes = {
      resources: PropTypes.object.isRequired,
      mutator: PropTypes.object.isRequired,
      showSingleResult: PropTypes.bool,
      browseOnly: PropTypes.bool,
      disableRecordCreation: PropTypes.bool,
      onSelectRow: PropTypes.func,
      getParams: PropTypes.func,
    };
  
    static defaultProps = {
      showSingleResult: false,
      browseOnly: false,
      disableRecordCreation: false,
    };
  
    static manifest = Object.freeze(buildManifestObject());
  
    render() {
      const {
        showSingleResult,
        browseOnly,
        onSelectRow,
        disableRecordCreation,
        resources,
        mutator,
        getParams,
      } = this.props;
      const { segment } = getParams(this.props);
      const { indexes, renderer } = getFilterConfig(segment);
      const { query } = resources;
  
      return (
        <DataContext.Consumer>
          {data => (
            <InstancesView
              parentResources={resources}
              parentMutator={mutator}
              data={{ ...data, query }}
              browseOnly={browseOnly}
              showSingleResult={showSingleResult}
              onSelectRow={onSelectRow}
              disableRecordCreation={disableRecordCreation}
              renderFilters={renderer({ ...data, query })}
              segment={segment}
              searchableIndexes={indexes}
            />
          )}
        </DataContext.Consumer>
      );
    }
  }
  
  export default flowRight(
    stripesConnect,
    withLocation,
  )(InstancesRoute);
  