diff --git a/opencti-platform/opencti-front/src/private/components/data/feeds/FeedCreation.tsx b/opencti-platform/opencti-front/src/private/components/data/feeds/FeedCreation.tsx index 6ffee6dbe07aa..eabff06c3ee41 100644 --- a/opencti-platform/opencti-front/src/private/components/data/feeds/FeedCreation.tsx +++ b/opencti-platform/opencti-front/src/private/components/data/feeds/FeedCreation.tsx @@ -38,6 +38,7 @@ import { stixCyberObservablesLinesAttributesQuery } from '../../observations/sti import Filters from '../../common/lists/Filters'; import { cleanFilters, + deserializeFilterGroupForFrontend, emptyFilterGroup, serializeFilterGroupForBackend, useAvailableFilterKeysForEntityTypes, @@ -162,7 +163,7 @@ const FeedCreation: FunctionComponent = (props) => { const classes = useStyles(); const { t_i18n } = useFormatter(); const [selectedTypes, setSelectedTypes] = useState(feed?.feed_types ?? []); - const [filters, helpers] = useFiltersState(emptyFilterGroup); + const [filters, helpers] = useFiltersState(deserializeFilterGroupForFrontend(feed?.filters) ?? emptyFilterGroup); const completeFilterKeysMap: Map> = useFetchFilterKeysSchema(); const availableFilterKeys = useAvailableFilterKeysForEntityTypes(selectedTypes).filter((k) => k !== 'entity_type'); @@ -172,17 +173,15 @@ const FeedCreation: FunctionComponent = (props) => { ...n, mappings: R.indexBy(R.prop('type'), n.mappings), })) - : []; + : { 0: {} }; + // TODO: typing this state properly implies deep refactoring // eslint-disable-next-line @typescript-eslint/no-explicit-any - const [feedAttributes, setFeedAttributes] = useState<{ [key: string]: any }>({ 0: {} }); + const [feedAttributes, setFeedAttributes] = useState<{ [key: string]: any }>(feedAttributesInitialState); const { ignoredAttributesInFeeds } = useAttributes(); - const handleClose = () => { - setSelectedTypes([]); - helpers.handleClearAllFilters(); - setFeedAttributes(feedAttributesInitialState); - if (!isDuplicated) { + const onHandleClose = () => { + if (isDuplicated) { onDrawerClose(); } }; @@ -341,13 +340,12 @@ const FeedCreation: FunctionComponent = (props) => { feed_date_attribute: 'created_at', feed_public: false, }; - return ( {({ onClose }) => ( = (props) => { ), ); } - return (