import React, { FunctionComponent } from 'react'; import PropTypes from 'prop-types'; import { StylingFunction } from 'react-base16-styling'; import RightSlider from './RightSlider'; const getActiveButtons = (hasSkippedActions: boolean): ('Sweep' | 'Commit')[] => [hasSkippedActions && 'Sweep', 'Commit'].filter( (a): a is 'Sweep' | 'Commit' => !!a ); interface Props { styling: StylingFunction; onSearch: (value: string) => void; onCommit: () => void; onSweep: () => void; hideMainButtons: boolean | undefined; hasSkippedActions: boolean; hasStagedActions: boolean; } const ActionListHeader: FunctionComponent = ({ styling, onSearch, hasSkippedActions, hasStagedActions, onCommit, onSweep, hideMainButtons, }) => (
onSearch(e.target.value)} placeholder="filter..." /> {!hideMainButtons && (
{getActiveButtons(hasSkippedActions).map((btn) => (
({ Commit: onCommit, Sweep: onSweep, }[btn]()) } {...styling( ['selectorButton', 'selectorButtonSmall'], false, true )} > {btn}
))}
)}
); ActionListHeader.propTypes = { styling: PropTypes.func.isRequired, onSearch: PropTypes.func.isRequired, onCommit: PropTypes.func.isRequired, onSweep: PropTypes.func.isRequired, hideMainButtons: PropTypes.bool, hasSkippedActions: PropTypes.bool.isRequired, hasStagedActions: PropTypes.bool.isRequired, }; export default ActionListHeader;