<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import {Admin, Loading, TranslationProvider, Query} from 'react-admin';
import {createMuiTheme} from '@material-ui/core/styles';
import ResourceGuesser from './ResourceGuesser';

const theme = createMuiTheme({
  palette: {
    primary: {
      main: '#38a9b4',
      contrastText: '#fff',
    },
    secondary: {
      main: '#288690',
    },
  },
});

const AdminBuilder = ({children, blacklist, ...props}) => {
  const defined = new Set(
    React.Children.map(children, child => child.props.name),
  );
  const blacklisted = new Set(blacklist);

  return (
    <Query type="INTROSPECT">
      {({data, loading, error}) => {
        if (loading) {
          return (
            <TranslationProvider>
              <Loading />
            </TranslationProvider>
          );
        }
        if (error) {
          console.error(error);
          return <div>Error while reading the API schema</div>;
        }
        return (
          <Admin theme={theme} {...props}>
            {children || <></>}
            {data.resources
              .filter(
                resource =>
                  !blacklisted.has(resource.name) &&
                  !defined.has(resource.name),
              )
              .map(resource => (
                <ResourceGuesser name={resource.name} key={resource.name} />
              ))}
          </Admin>
        );
      }}
    </Query>
  );
};

export default AdminBuilder;

AdminBuilder.propTypes = {
  fieldFactory: PropTypes.func,
  inputFactory: PropTypes.func,
  parameterFactory: PropTypes.func,
  resourceFactory: PropTypes.func,
  dataProvider: PropTypes.func.isRequired,
  resources: PropTypes.array,
  blacklist: PropTypes.array,
  children: PropTypes.object,
};
<commit_msg>Hide deprecated resources by default<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import {Admin, Loading, TranslationProvider, Query} from 'react-admin';
import {createMuiTheme} from '@material-ui/core/styles';
import ResourceGuesser from './ResourceGuesser';

const theme = createMuiTheme({
  palette: {
    primary: {
      main: '#38a9b4',
      contrastText: '#fff',
    },
    secondary: {
      main: '#288690',
    },
  },
});

const AdminBuilder = ({children, blacklist, ...props}) => {
  const defined = new Set(
    React.Children.map(children, child => child.props.name),
  );
  const blacklisted = new Set(blacklist);

  return (
    <Query type="INTROSPECT">
      {({data, loading, error}) => {
        if (loading) {
          return (
            <TranslationProvider>
              <Loading />
            </TranslationProvider>
          );
        }
        if (error) {
          console.error(error);
          return <div>Error while reading the API schema</div>;
        }
        return (
          <Admin theme={theme} {...props}>
            {children || <></>}
            {data.resources
              .filter(
                resource =>
                  !resource.deprecated &&
                  !blacklisted.has(resource.name) &&
                  !defined.has(resource.name),
              )
              .map(resource => (
                <ResourceGuesser name={resource.name} key={resource.name} />
              ))}
          </Admin>
        );
      }}
    </Query>
  );
};

export default AdminBuilder;

AdminBuilder.propTypes = {
  fieldFactory: PropTypes.func,
  inputFactory: PropTypes.func,
  parameterFactory: PropTypes.func,
  resourceFactory: PropTypes.func,
  dataProvider: PropTypes.func.isRequired,
  resources: PropTypes.array,
  blacklist: PropTypes.array,
  children: PropTypes.object,
};

{'fraction_non_alphanumeric': 0.13474599293670197, 'fraction_numerical': 0.0054333061668024995, 'mean_word_length': 2.0941176470588236, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 37, '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': '3582133', 'n_tokens_mistral': 1032, 'n_tokens_neox': 1030, 'n_words': 223}