mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 17:28:54 +00:00
87c4aba10d
* added teams to add host modal dropdown * bulk and transfer host on host page * started transferhost API call * hook up client side of api * hook up client side of api call for enrol secrets * added selection number and clear all selections button * remove log and document * fix ManageHostPage tests * fix linting errors * add indeterminate styles to checkbox * added clearable handler for dropdown component * fix up no team for add modal * Add active selection styles and move specific host table styles into ManageHostsPage styles * changed add host team dropdown to include no team option * add no team option to bulk transfer host options * change enroll spelling Co-authored-by: Noah Talerman <noahtal@umich.edu>
80 lines
2.0 KiB
JavaScript
80 lines
2.0 KiB
JavaScript
import React, { Component } from "react";
|
|
import PropTypes from "prop-types";
|
|
import classnames from "classnames";
|
|
import { noop, pick } from "lodash";
|
|
|
|
import FormField from "components/forms/FormField";
|
|
|
|
const baseClass = "kolide-checkbox";
|
|
|
|
class Checkbox extends Component {
|
|
static propTypes = {
|
|
children: PropTypes.node,
|
|
className: PropTypes.string,
|
|
disabled: PropTypes.bool,
|
|
name: PropTypes.string,
|
|
onChange: PropTypes.func,
|
|
value: PropTypes.bool,
|
|
wrapperClassName: PropTypes.string,
|
|
indeterminate: PropTypes.bool,
|
|
};
|
|
|
|
static defaultProps = {
|
|
disabled: false,
|
|
onChange: noop,
|
|
};
|
|
|
|
handleChange = () => {
|
|
const { onChange, value } = this.props;
|
|
|
|
return onChange(!value);
|
|
};
|
|
|
|
render() {
|
|
const { handleChange } = this;
|
|
const {
|
|
children,
|
|
className,
|
|
disabled,
|
|
name,
|
|
value,
|
|
wrapperClassName,
|
|
indeterminate,
|
|
} = this.props;
|
|
const checkBoxClass = classnames(baseClass, className);
|
|
const formFieldProps = pick(this.props, ["hint", "label", "error", "name"]);
|
|
|
|
const checkBoxTickClass = classnames(`${checkBoxClass}__tick`, {
|
|
[`${checkBoxClass}__tick--disabled`]: disabled,
|
|
[`${checkBoxClass}__tick--indeterminate`]: indeterminate,
|
|
});
|
|
|
|
return (
|
|
<FormField
|
|
{...formFieldProps}
|
|
className={wrapperClassName}
|
|
type="checkbox"
|
|
>
|
|
<label htmlFor={name} className={checkBoxClass}>
|
|
<input
|
|
checked={value}
|
|
className={`${checkBoxClass}__input`}
|
|
disabled={disabled}
|
|
id={name}
|
|
name={name}
|
|
onChange={handleChange}
|
|
type="checkbox"
|
|
ref={(element) => {
|
|
element && (element.indeterminate = indeterminate);
|
|
}}
|
|
/>
|
|
<span className={checkBoxTickClass} />
|
|
<span className={`${checkBoxClass}__label`}>{children}</span>
|
|
</label>
|
|
</FormField>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Checkbox;
|