Sha256: bf6aacbf37ba84494b01b833c82430e9448a8cbf22014a20e3db590f2f9220cd

Contents?: true

Size: 978 Bytes

Versions: 44

Compression:

Stored size: 978 Bytes

Contents

import React from 'react';
import { Switch } from '@patternfly/react-core';
import { noop } from 'foremanReact/common/helpers';
import PropTypes from 'prop-types';

const EditableSwitch = ({
  value, attribute, onEdit, disabled, setCurrentAttribute,
}) => {
  const identifier = `${attribute} switch`;
  const onSwitch = (val) => {
    if (setCurrentAttribute) setCurrentAttribute(attribute);
    onEdit(val, attribute);
  };

  return (
    <Switch
      id={identifier}
      aria-label={identifier}
      ouiaId={`switch-${identifier}`}
      isChecked={value}
      onChange={onSwitch}
      disabled={disabled}
    />
  );
};

EditableSwitch.propTypes = {
  value: PropTypes.bool.isRequired,
  attribute: PropTypes.string,
  onEdit: PropTypes.func,
  disabled: PropTypes.bool,
  setCurrentAttribute: PropTypes.func,
};

EditableSwitch.defaultProps = {
  attribute: '',
  onEdit: noop,
  disabled: false,
  setCurrentAttribute: undefined,
};

export default EditableSwitch;

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
katello-4.15.0.rc2 webpack/components/EditableSwitch.js
katello-4.15.0.rc1 webpack/components/EditableSwitch.js
katello-4.14.1 webpack/components/EditableSwitch.js
katello-4.14.0 webpack/components/EditableSwitch.js
katello-4.14.0.rc3 webpack/components/EditableSwitch.js
katello-4.14.0.rc2 webpack/components/EditableSwitch.js
katello-4.14.0.rc1.1 webpack/components/EditableSwitch.js
katello-4.14.0.rc1 webpack/components/EditableSwitch.js
katello-4.13.1 webpack/components/EditableSwitch.js
katello-4.13.0 webpack/components/EditableSwitch.js
katello-4.12.1 webpack/components/EditableSwitch.js
katello-4.13.0.rc1 webpack/components/EditableSwitch.js
katello-4.12.0 webpack/components/EditableSwitch.js
katello-4.12.0.rc3 webpack/components/EditableSwitch.js
katello-4.12.0.rc2 webpack/components/EditableSwitch.js
katello-4.12.0.rc1 webpack/components/EditableSwitch.js
katello-4.11.1 webpack/components/EditableSwitch.js
katello-4.11.0 webpack/components/EditableSwitch.js
katello-4.11.0.rc2 webpack/components/EditableSwitch.js
katello-4.11.0.rc1 webpack/components/EditableSwitch.js