import React , { useCallback , useMemo } from 'react' ; import { DataFrameAnalyticsListAction , DataFrameAnalyticsListRow } from '../analytics_list/common' ; import { cloneActionNameText , useNavigateToWizardWithClonedJob , CloneActionName , } from './clone_action_name' ; export type CloneAction = ReturnType < typeof useCloneAction > ; export const useCloneAction = ( canCreateDataFrameAnalytics ) => { const navigateToWizardWithClonedJob = useNavigateToWizardWithClonedJob ( ) ; const clickHandler = useCallback ( ( item ) => { navigateToWizardWithClonedJob ( item ) ; } , [ ] ) ; const action = useMemo ( ( ) => ( { name : ( ) => < CloneActionName isDisabled = { ! canCreateDataFrameAnalytics } />, enabled : ( ) => canCreateDataFrameAnalytics , description : cloneActionNameText , icon : 'copy' , type : 'icon' , onClick : clickHandler , 'data-test-subj' : 'mlAnalyticsJobCloneButton' , } ) , [ ] ) ; return { action } ; } ;