import React from 'react'; import { useField } from 'formik'; import { useAllComponents } from '../../../../../hooks/useComponents'; import DropdownField from '../../../../../shared/components/formik-fields/DropdownField'; import { useNamespace } from '../../../../../shared/providers/Namespace'; import { TargetDropdownDefaults } from '../../../../../types'; type CVEComponentDropDownProps = Omit< React.ComponentProps, 'items' | 'label' >; export const CVEComponentDropDown: React.FC> = ({ name, }) => { const namespace = useNamespace(); const [, , { setValue, setTouched }] = useField(name); const [components, componentsLoaded, componentsError] = useAllComponents(namespace); const dropdownItems = React.useMemo( () => components.map((a) => ({ key: a.metadata.name, value: a.metadata.name })), [components], ); return ( { void setValue(component, true); void setTouched(true); }} items={dropdownItems} /> ); };