Sha256: f3fbd9763ca81bcfd51535a073ddb9fe840e0a1e10f4eacbe5bc1ecb69e458ac

Contents?: true

Size: 1.56 KB

Versions: 19

Compression:

Stored size: 1.56 KB

Contents

import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import {
  FormGroup,
  Select,
  SelectOption,
  SelectVariant,
} from '@patternfly/react-core';
import { range } from 'lodash';
import { translate as __ } from 'foremanReact/common/I18n';

export const RepeatHour = ({ repeatData, setRepeatData, setValid }) => {
  const { minute } = repeatData;
  useEffect(() => {
    if (minute) {
      setValid(true);
    } else {
      setValid(false);
    }
    return () => setValid(true);
  }, [setValid, minute]);
  const [minuteOpen, setMinuteOpen] = useState(false);
  return (
    <FormGroup label={__('At minute')} isRequired>
      <Select
        id="repeat-on-hourly"
        variant={SelectVariant.typeahead}
        typeAheadAriaLabel="repeat-at-minute-typeahead"
        onSelect={(event, selection) => {
          setRepeatData({ minute: selection });
          setMinuteOpen(false);
        }}
        selections={minute || ''}
        onToggle={toggle => {
          setMinuteOpen(toggle);
        }}
        isOpen={minuteOpen}
        width={85}
        menuAppendTo={() => document.querySelector('.pf-c-form.schedule-tab')}
        toggleAriaLabel="select minute toggle"
        validated={minute ? 'success' : 'error'}
      >
        {range(60).map(minuteNumber => (
          <SelectOption key={minuteNumber} value={`${minuteNumber}`} />
        ))}
      </Select>
    </FormGroup>
  );
};
RepeatHour.propTypes = {
  repeatData: PropTypes.object.isRequired,
  setRepeatData: PropTypes.func.isRequired,
  setValid: PropTypes.func.isRequired,
};

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
foreman_remote_execution-7.2.2 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-7.2.1 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-7.2.0 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-5.0.8 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-7.1.1 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-7.1.0 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-7.0.0 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-5.0.7 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-5.0.6 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-6.2.0 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-5.0.5 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-6.1.0 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-5.0.4 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-5.0.3 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-6.0.0 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-5.0.2 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-5.1.0 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-5.0.1 webpack/JobWizard/steps/Schedule/RepeatHour.js
foreman_remote_execution-5.0.0 webpack/JobWizard/steps/Schedule/RepeatHour.js