<commit_before>import {
  CustomFieldsContainer,
  ReadonlyCustomFields
} from "components/CustomFields"
import LinkTo from "components/LinkTo"
import _isEmpty from "lodash/isEmpty"
import PropTypes from "prop-types"
import React from "react"
import { Table } from "react-bootstrap"

const InstantAssessmentsContainerField = ({
  entityType,
  entities,
  entitiesInstantAssessmentsConfig,
  parentFieldName,
  formikProps,
  readonly
}) => {
  const { values } = formikProps
  return (
    <Table condensed responsive>
      <tbody>
        {entities.map(entity => {
          const entityInstantAssessmentConfig = !_isEmpty(
            entitiesInstantAssessmentsConfig
          )
            ? entitiesInstantAssessmentsConfig[entity.uuid]
            : entity.getInstantAssessmentConfig()
          if (!entityInstantAssessmentConfig) {
            return null
          }
          return (
            <React.Fragment key={`assessment-${values.uuid}-${entity.uuid}`}>
              <tr>
                <td>
                  <LinkTo modelType={entityType.resourceName} model={entity} />
                </td>
              </tr>
              <tr>
                <td>
                  {readonly ? (
                    <ReadonlyCustomFields
                      parentFieldName={`${parentFieldName}.${entity.uuid}`}
                      fieldsConfig={entityInstantAssessmentConfig}
                      values={values}
                    />
                  ) : (
                    <CustomFieldsContainer
                      parentFieldName={`${parentFieldName}.${entity.uuid}`}
                      fieldsConfig={entityInstantAssessmentConfig}
                      formikProps={formikProps}
                    />
                  )}
                </td>
              </tr>
            </React.Fragment>
          )
        })}
      </tbody>
    </Table>
  )
}
InstantAssessmentsContainerField.propTypes = {
  entityType: PropTypes.func.isRequired,
  entities: PropTypes.array,
  entitiesInstantAssessmentsConfig: PropTypes.object,
  parentFieldName: PropTypes.string.isRequired,
  formikProps: PropTypes.shape({
    setFieldTouched: PropTypes.func,
    setFieldValue: PropTypes.func,
    values: PropTypes.object,
    validateForm: PropTypes.func
  }),
  readonly: PropTypes.bool
}
InstantAssessmentsContainerField.defaultProps = {
  readonly: false
}
export default InstantAssessmentsContainerField<commit_msg>NCI-Agency/anet#2954: Improve typechecking for InstantAssessmentsContainerField<commit_after>import {
  CustomFieldsContainer,
  ReadonlyCustomFields
} from "components/CustomFields"
import LinkTo from "components/LinkTo"
import Model from "components/Model"
import _isEmpty from "lodash/isEmpty"
import PropTypes from "prop-types"
import React from "react"
import { Table } from "react-bootstrap"

const InstantAssessmentsContainerField = ({
  entityType,
  entities,
  entitiesInstantAssessmentsConfig,
  parentFieldName,
  formikProps,
  readonly
}) => {
  const { values } = formikProps
  return (
    <Table condensed responsive>
      <tbody>
        {entities.map(entity => {
          const entityInstantAssessmentConfig = !_isEmpty(
            entitiesInstantAssessmentsConfig
          )
            ? entitiesInstantAssessmentsConfig[entity.uuid]
            : entity.getInstantAssessmentConfig()
          if (!entityInstantAssessmentConfig) {
            return null
          }
          return (
            <React.Fragment key={`assessment-${values.uuid}-${entity.uuid}`}>
              <tr>
                <td>
                  <LinkTo modelType={entityType.resourceName} model={entity} />
                </td>
              </tr>
              <tr>
                <td>
                  {readonly ? (
                    <ReadonlyCustomFields
                      parentFieldName={`${parentFieldName}.${entity.uuid}`}
                      fieldsConfig={entityInstantAssessmentConfig}
                      values={values}
                    />
                  ) : (
                    <CustomFieldsContainer
                      parentFieldName={`${parentFieldName}.${entity.uuid}`}
                      fieldsConfig={entityInstantAssessmentConfig}
                      formikProps={formikProps}
                    />
                  )}
                </td>
              </tr>
            </React.Fragment>
          )
        })}
      </tbody>
    </Table>
  )
}
InstantAssessmentsContainerField.propTypes = {
  entityType: PropTypes.func.isRequired,
  entities: PropTypes.arrayOf(PropTypes.instanceOf(Model)),
  entitiesInstantAssessmentsConfig: PropTypes.object,
  parentFieldName: PropTypes.string.isRequired,
  formikProps: PropTypes.shape({
    setFieldTouched: PropTypes.func,
    setFieldValue: PropTypes.func,
    values: PropTypes.object.isRequired,
    validateForm: PropTypes.func
  }),
  readonly: PropTypes.bool
}
InstantAssessmentsContainerField.defaultProps = {
  entities: [],
  readonly: false
}
export default InstantAssessmentsContainerField
{'fraction_non_alphanumeric': 0.0943021639864999, 'fraction_numerical': 0.0007941234862021044, 'mean_word_length': 2.0533333333333332, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 41, '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': '1919301', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1308, 'n_words': 218}