<commit_before>import React from 'react'
import PropTypes from 'prop-types'
import {Button, Typography, SignalBox} from 'tocco-ui'
import {navigationStrategy} from 'tocco-util'
import {FormattedMessage} from 'react-intl'

import {deleteInfoPropType} from '../../utils/deleteRequestParser'
import InfoPart from '../InfoPart'
import {StyledSectionWrapper, StyledButtonsWrapper} from './StyledComponents'

const Dialog = ({
  dialogInfo: {
    rootEntitiesDeletable,
    rootEntitiesNotDeletable,
    relatedDeletable,
    relatedNotDeletable,
    hasUnreadableEntities
  }, doDelete, onCancel, navigationStrategy
}) => <>
    <Typography.P><FormattedMessage id="client.delete.confirmText"/></Typography.P>
    <InfoPart
      key="infopart-deletable"
      rootEntities={rootEntitiesDeletable}
      relatedEntities={relatedDeletable}
      maxCountLink={100}
      navigationStrategy={navigationStrategy}
    />
    {Object.keys(rootEntitiesNotDeletable).length > 0
    && <StyledSectionWrapper>
      <Typography.P><FormattedMessage id="client.delete.textNotDeletable"/></Typography.P>
      <InfoPart
        key="infopart-notdeletable"
        rootEntities={rootEntitiesNotDeletable}
        relatedEntities={relatedNotDeletable}
        maxCountLink={100}
        navigationStrategy={navigationStrategy}
      />
    </StyledSectionWrapper>
    }
    {hasUnreadableEntities
    && <StyledSectionWrapper>
      <SignalBox
        condition="warning">
        <Typography.Span><FormattedMessage id="client.delete.unreadableEntities"/></Typography.Span>
      </SignalBox>
    </StyledSectionWrapper>
    }
    <StyledSectionWrapper>
      <StyledButtonsWrapper>
        <Button
          onClick={doDelete}
          disabled={Object.keys(rootEntitiesDeletable).length === 0}
        >
          <FormattedMessage id="client.delete.deleteButton"/>
        </Button>
        <Button
          ink="primary"
          onClick={onCancel}
        >
          <FormattedMessage id="client.delete.cancelButton"/>
        </Button>
      </StyledButtonsWrapper>
    </StyledSectionWrapper>
</>

Dialog.propTypes = {
  onCancel: PropTypes.func.isRequired,
  doDelete: PropTypes.func.isRequired,
  dialogInfo: deleteInfoPropType.isRequired,
  navigationStrategy: navigationStrategy.propTypes
}

export default Dialog
<commit_msg>fix(delete): handle no entities deletable<commit_after>import React from 'react'
import PropTypes from 'prop-types'
import {Button, Typography, SignalBox} from 'tocco-ui'
import {navigationStrategy} from 'tocco-util'
import {FormattedMessage} from 'react-intl'

import {deleteInfoPropType} from '../../utils/deleteRequestParser'
import InfoPart from '../InfoPart'
import {StyledSectionWrapper, StyledButtonsWrapper} from './StyledComponents'

const Dialog = ({
  dialogInfo: {
    rootEntitiesDeletable,
    rootEntitiesNotDeletable,
    relatedDeletable,
    relatedNotDeletable,
    hasUnreadableEntities
  }, doDelete, onCancel, navigationStrategy
}) => <>
    <Typography.P><FormattedMessage id="client.delete.confirmText"/></Typography.P>
  {Object.keys(rootEntitiesDeletable).length > 0
    ? <InfoPart
    key="infopart-deletable"
    rootEntities={rootEntitiesDeletable}
    relatedEntities={relatedDeletable}
    maxCountLink={100}
    navigationStrategy={navigationStrategy}
    />
    : '-'
  }
    {Object.keys(rootEntitiesNotDeletable).length > 0
    && <StyledSectionWrapper>
      <Typography.P><FormattedMessage id="client.delete.textNotDeletable"/></Typography.P>
      <InfoPart
        key="infopart-notdeletable"
        rootEntities={rootEntitiesNotDeletable}
        relatedEntities={relatedNotDeletable}
        maxCountLink={100}
        navigationStrategy={navigationStrategy}
      />
    </StyledSectionWrapper>
    }
    {hasUnreadableEntities
    && <StyledSectionWrapper>
      <SignalBox
        condition="warning">
        <Typography.Span><FormattedMessage id="client.delete.unreadableEntities"/></Typography.Span>
      </SignalBox>
    </StyledSectionWrapper>
    }
    <StyledSectionWrapper>
      <StyledButtonsWrapper>
        <Button
          onClick={doDelete}
          disabled={Object.keys(rootEntitiesDeletable).length === 0}
        >
          <FormattedMessage id="client.delete.deleteButton"/>
        </Button>
        <Button
          ink="primary"
          onClick={onCancel}
        >
          <FormattedMessage id="client.delete.cancelButton"/>
        </Button>
      </StyledButtonsWrapper>
    </StyledSectionWrapper>
</>

Dialog.propTypes = {
  onCancel: PropTypes.func.isRequired,
  doDelete: PropTypes.func.isRequired,
  dialogInfo: deleteInfoPropType.isRequired,
  navigationStrategy: navigationStrategy.propTypes
}

export default Dialog

{'fraction_non_alphanumeric': 0.11153439153439153, 'fraction_numerical': 0.0035978835978835977, 'mean_word_length': 3.566183574879227, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 66, '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': '4324879', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1372, 'n_words': 212}