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

Version Path
foreman-tasks-8.1.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.1.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.1.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.0.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.0.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.0.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-7.2.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-7.1.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-7.2.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-7.1.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-6.0.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-7.0.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-6.0.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-4.1.6 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-5.2.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-6.0.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-5.2.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-6.0.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-5.2.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-5.3.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js