import * as React from 'react' ; import PropTypes from 'prop-types' ; import BulkUpdateWithConfirmButton , { BulkUpdateWithConfirmButtonProps , } from './BulkUpdateWithConfirmButton' ; import BulkUpdateWithUndoButton , { BulkUpdateWithUndoButtonProps , } from './BulkUpdateWithUndoButton' ; import { MutationMode } from 'ra-core' ; example const BulkUpdateButton = ( props ) => { const { mutationMode , ... rest } = props ; return mutationMode === 'undoable' ? ( < BulkUpdateWithUndoButton { ... rest } / > ) : ( < BulkUpdateWithConfirmButton mutationMode = { mutationMode } { ... rest } />); } ; interface Props { mutationMode ? : MutationMode ; } export type BulkUpdateButtonProps = Props & ( BulkUpdateWithUndoButtonProps | BulkUpdateWithConfirmButtonProps ) ; BulkUpdateButton . propTypes = { basePath : PropTypes . string , label : PropTypes . string , resource : PropTypes . string , selectedIds : PropTypes . arrayOf ( PropTypes . any ) , mutationMode : PropTypes . oneOf ( [ 'pessimistic' , 'optimistic' , 'undoable' ] ) , icon : PropTypes . element , } ; BulkUpdateButton . defaultProps = { mutationMode : 'undoable' , data : [ ] , } ; export default BulkUpdateButton ;