Sha256: 654d0d7f79caf18daec6d34cc251754d16176dd6437879f8edc702070b96033a
Contents?: true
Size: 1.32 KB
Versions: 91
Compression:
Stored size: 1.32 KB
Contents
import React from 'react'; import PropTypes from 'prop-types'; import { DropdownButton, MenuItem } from 'patternfly-react'; import { noop } from 'foremanReact/common/helpers'; import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../../../TasksDashboardConstants'; import { getQueryValueText } from '../../../../TasksDashboardHelper'; const TimeDropDown = ({ id, className, selectedTime, onChange, ...props }) => { const availableTimes = Object.keys(TASKS_DASHBOARD_AVAILABLE_TIMES).map( key => ({ key, text: getQueryValueText(key), active: key === selectedTime, }) ); return ( <DropdownButton id={id} className={className} title={getQueryValueText(selectedTime)} {...props} > {availableTimes.map(({ key, text, active }) => ( <MenuItem key={key} active={active} onClick={() => active || onChange(key)} > {text} </MenuItem> ))} </DropdownButton> ); }; TimeDropDown.propTypes = { id: PropTypes.string.isRequired, className: PropTypes.string, selectedTime: PropTypes.oneOf(Object.keys(TASKS_DASHBOARD_AVAILABLE_TIMES)), onChange: PropTypes.func, }; TimeDropDown.defaultProps = { className: '', selectedTime: TASKS_DASHBOARD_AVAILABLE_TIMES.H24, onChange: noop, }; export default TimeDropDown;
Version data entries
91 entries across 91 versions & 1 rubygems