<commit_before>import React, { Component } from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import { FormattedMessage } from 'react-intl';

import Query from 'src/app/Query';
import EntitySearch from 'src/components/EntitySearch/EntitySearch';

import './FolderViewer.css';

class FolderViewer extends Component {
  render() {
    const { document, query, className, disableOrEnableDelete, setDocuments, setRefreshCallout } = this.props;

    return (
      <React.Fragment>
        <div id="children" className={`FolderViewer ${className}`}>
          {document.status === 'fail' && (
            <div className='warning-folder'>
              <strong>
                <FormattedMessage id="search.warning" defaultMessage="Warning:" />
              </strong>
              &nbsp;
              <p>
                <FormattedMessage id="search.not_properly_imported"
                                  defaultMessage="This folder is not fully imported." />
              </p>
            </div>
          )}
          <EntitySearch
            query={query}
            hideCollection={true}
            documentMode={true}
            writable={document.writeable}
            disableOrEnableDelete={disableOrEnableDelete}
            setDocuments={setDocuments}
            setRefreshCallout={setRefreshCallout}
            path={'/documents/' + document.id}/>
        </div>
      </React.Fragment>
    );
  }
}


const mapStateToProps = (state, ownProps) => {
  const { document, location, queryText } = ownProps;
  // when a query is defined, we switch to recursive folder search - otherwise
  // a flat listing of the immediate children of this directory is shown.
  const q = Query.fromLocation('search', location, {}, 'document').getString('q'),
        hasSearch = (q.length !== 0 || queryText),
        context = {};
    
  if (hasSearch) {
    context['filter:ancestors'] = document.id;
  } else {
    context['filter:parent.id'] = document.id;
    context['sort'] = 'name:asc';
  }

  let query = Query.fromLocation('search', location, context, 'document').limit(50);
  if (queryText) {
    query = query.setString('q', queryText);
  }

  return { query }
};

FolderViewer = connect(mapStateToProps)(FolderViewer);
FolderViewer = withRouter(FolderViewer);
export default FolderViewer;<commit_msg>Make folders writeable again, typo<commit_after>import React, { Component } from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import { FormattedMessage } from 'react-intl';

import Query from 'src/app/Query';
import EntitySearch from 'src/components/EntitySearch/EntitySearch';

import './FolderViewer.css';

class FolderViewer extends Component {
  render() {
    const { document, query, className, disableOrEnableDelete, setDocuments, setRefreshCallout } = this.props;

    return (
      <React.Fragment>
        <div id="children" className={`FolderViewer ${className}`}>
          {document.status === 'fail' && (
            <div className='warning-folder'>
              <strong>
                <FormattedMessage id="search.warning" defaultMessage="Warning:" />
              </strong>
              &nbsp;
              <p>
                <FormattedMessage id="search.not_properly_imported"
                                  defaultMessage="This folder is not fully imported." />
              </p>
            </div>
          )}
          <EntitySearch query={query}
                        hideCollection={true}
                        documentMode={true}
                        writeable={document.writeable}
                        disableOrEnableDelete={disableOrEnableDelete}
                        setDocuments={setDocuments}
                        setRefreshCallout={setRefreshCallout}
                        path={'/documents/' + document.id} />
        </div>
      </React.Fragment>
    );
  }
}


const mapStateToProps = (state, ownProps) => {
  const { document, location, queryText } = ownProps;
  // when a query is defined, we switch to recursive folder search - otherwise
  // a flat listing of the immediate children of this directory is shown.
  const q = Query.fromLocation('search', location, {}, 'document').getString('q'),
        hasSearch = (q.length !== 0 || queryText),
        context = {};
    
  if (hasSearch) {
    context['filter:ancestors'] = document.id;
  } else {
    context['filter:parent.id'] = document.id;
    context['sort'] = 'name:asc';
  }

  let query = Query.fromLocation('search', location, context, 'document').limit(50);
  if (queryText) {
    query = query.setString('q', queryText);
  }

  return { query }
};

FolderViewer = connect(mapStateToProps)(FolderViewer);
FolderViewer = withRouter(FolderViewer);
export default FolderViewer;
{'fraction_non_alphanumeric': 0.1259105098855359, 'fraction_numerical': 0.0012486992715920915, 'mean_word_length': 2.4876632801161103, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5622387', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1270, 'n_words': 305}