From f8431dca2a818b1b992a5c1179c893fbe86be7be Mon Sep 17 00:00:00 2001 From: FrancoisGrunert Date: Mon, 30 Sep 2024 10:39:41 +0200 Subject: [PATCH] [frontend] fix lint (#4333) --- .../src/components/ItemAssignees.tsx | 4 +- .../src/components/ItemParticipants.tsx | 4 +- .../common/form/ObjectAssigneeField.jsx | 97 +++++++++---------- ...xCoreObjectOrCoreRelationshipLabelsView.js | 1 - 4 files changed, 52 insertions(+), 54 deletions(-) diff --git a/opencti-platform/opencti-front/src/components/ItemAssignees.tsx b/opencti-platform/opencti-front/src/components/ItemAssignees.tsx index 072e0c62597e..c7d9cebf1195 100644 --- a/opencti-platform/opencti-front/src/components/ItemAssignees.tsx +++ b/opencti-platform/opencti-front/src/components/ItemAssignees.tsx @@ -3,12 +3,12 @@ import Chip from '@mui/material/Chip'; import { CancelOutlined, PersonOutline } from '@mui/icons-material'; import { useTheme } from '@mui/styles'; import { stixDomainObjectMutation } from '@components/common/stix_domain_objects/StixDomainObjectHeader'; +import Tooltip from '@mui/material/Tooltip'; import { truncate } from '../utils/String'; import useGranted, { KNOWLEDGE_KNUPDATE } from '../utils/hooks/useGranted'; import type { Theme } from './Theme'; import FieldOrEmpty from './FieldOrEmpty'; import { commitMutation, defaultCommitMutation } from '../relay/environment'; -import Tooltip from '@mui/material/Tooltip'; type Node = { readonly entity_type: string; @@ -42,7 +42,7 @@ const ItemAssignees: FunctionComponent = ({ assignees, stixDomainObjectId return ( {assignees.map((assignee) => ( - + = ({ participan return ( {participants.map((participant) => ( - + timer(1500))); @@ -56,35 +56,20 @@ const useStyles = makeStyles((theme) => ({ }, })); -const ObjectAssigneeField = (props) => { - const { defaultObjectAssignee, name, style, label, onChange, helpertext, disabled } = props; +const ObjectAssigneeField = ({ defaultObjectAssignee, name, style, label, onChange, helpertext, disabled }) => { const classes = useStyles(); const { t_i18n } = useFormatter(); const [keyword, setKeyword] = useState(''); const [assignees, setAssignee] = useState(defaultObjectAssignee ? [ - { - label: defaultObjectAssignee.name, - value: defaultObjectAssignee.id, - type: defaultObjectAssignee.entity_type, - entity: defaultObjectAssignee, - }, - ] + { + label: defaultObjectAssignee.name, + value: defaultObjectAssignee.id, + type: defaultObjectAssignee.entity_type, + entity: defaultObjectAssignee, + }, + ] : []); - useEffect(() => { - const subscription = SEARCH$.subscribe({ - next: () => searchAssignees(), - }); - return subscription.unsubscribe(); - }); - - const handleSearch = (event) => { - if (event && event.target && event.target.value) { - setKeyword(event.target.value); - SEARCH$.next({ action: 'Search' }); - } - } - const searchAssignees = () => { fetchQuery(objectAssigneeFieldMembersSearchQuery, { search: keyword, @@ -104,35 +89,49 @@ const ObjectAssigneeField = (props) => { )(data); setAssignee(union(assignees, newAssignees)); }); - } + }; + + useEffect(() => { + const subscription = SEARCH$.subscribe({ + next: () => searchAssignees(), + }); + return subscription.unsubscribe(); + }); + + const handleSearch = (event) => { + if (event && event.target && event.target.value) { + setKeyword(event.target.value); + SEARCH$.next({ action: 'Search' }); + } + }; return ( a.label.localeCompare(b.label))} - onInputChange={handleSearch} - onChange={typeof onChange === 'function' ? onChange : null} - renderOption={(props, option) => ( -
  • -
    - -
    -
    {option.label}
    -
  • - )} - classes={{ clearIndicator: classes.autoCompleteIndicator }} + style={style} + name={name} + disabled={disabled} + multiple={true} + textfieldprops={{ + variant: 'standard', + label: label ?? t_i18n('Assignee(s)'), + helperText: helpertext, + onFocus: searchAssignees, + }} + noOptionsText={t_i18n('No available options')} + options={assignees.sort((a, b) => a.label.localeCompare(b.label))} + onInputChange={handleSearch} + onChange={typeof onChange === 'function' ? onChange : null} + renderOption={(props, option) => ( +
  • +
    + +
    +
    {option.label}
    +
  • + )} + classes={{ clearIndicator: classes.autoCompleteIndicator }} /> ); -} +}; export default ObjectAssigneeField; diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects_or_stix_relationships/StixCoreObjectOrCoreRelationshipLabelsView.js b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects_or_stix_relationships/StixCoreObjectOrCoreRelationshipLabelsView.js index 8c19ab709e78..950f25bffc4e 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects_or_stix_relationships/StixCoreObjectOrCoreRelationshipLabelsView.js +++ b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects_or_stix_relationships/StixCoreObjectOrCoreRelationshipLabelsView.js @@ -54,7 +54,6 @@ const StixCoreObjectOrCoreRelationshipLabelsView = (props) => { const { t_i18n } = useFormatter(); const { labels, - marginTop, mutationRelationsAdd, mutationRelationDelete, enableReferences = false,