Skip to content

Commit

Permalink
[frontend] Fix potential duplicate warning messages (#8180)
Browse files Browse the repository at this point in the history
  • Loading branch information
CelineSebe authored Oct 25, 2024
1 parent a736589 commit 0d1bf99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions opencti-platform/opencti-front/src/components/TextField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ const TextField = (props) => {
error={!isNil(meta.error)}
helperText={
// eslint-disable-next-line no-nested-ternary
(detectDuplicate && meta.value?.length > 2) && (isNil(meta.error) || !meta.touched) ? (
<StixDomainObjectDetectDuplicate
types={detectDuplicate}
value={meta.value}
/>
) : meta.error ? (
meta.error
) : (
props.helperText
)
detectDuplicate && (isNil(meta.error) || !meta.touched) ? (
<StixDomainObjectDetectDuplicate
types={detectDuplicate}
value={meta.value}
/>
) : meta.error ? (
meta.error
) : (
props.helperText
)
}
onChange={internalOnChange}
onFocus={internalOnFocus}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class StixDomainObjectDetectDuplicate extends Component {

componentDidUpdate(prevProps) {
if (this.props.value !== prevProps.value) {
if (this.props.value.length > 2) {
if (this.props.value.length >= 2) {
fetchQuery(stixDomainObjectsLinesSearchQuery, {
types: this.props.types,
search: `"${this.props.value}"`,
Expand Down Expand Up @@ -82,7 +82,7 @@ class StixDomainObjectDetectDuplicate extends Component {

render() {
const { potentialDuplicates } = this.state;
const { t, classes } = this.props;
const { t, classes, value } = this.props;
return (
<span
className={
Expand All @@ -91,7 +91,7 @@ class StixDomainObjectDetectDuplicate extends Component {
: classes.noDuplicate
}
>
{potentialDuplicates.length === 0
{value && potentialDuplicates.length === 0
? t('No potential duplicate entities has been found.')
: ''}
{potentialDuplicates.length === 1 ? (
Expand Down

0 comments on commit 0d1bf99

Please sign in to comment.