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-10.0.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-10.0.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-9.2.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-9.2.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-9.2.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-9.2.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-9.1.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-9.0.4 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-9.1.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-9.0.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-9.0.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.3.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-9.0.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.2.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.1.4 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.3.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.3.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.1.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.3.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
foreman-tasks-8.2.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js