mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* Only send changed user attributes to the server * Improve flash message styles * Do not allow admins to demote or disable their own account * Disable admin actions against self
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
import React, { Component, PropTypes } from 'react';
|
|
import radium from 'radium';
|
|
import { noop } from 'lodash';
|
|
import componentStyles from './styles';
|
|
|
|
class Dropdown extends Component {
|
|
static propTypes = {
|
|
containerStyles: PropTypes.object,
|
|
options: PropTypes.arrayOf(PropTypes.shape({
|
|
text: PropTypes.string,
|
|
value: PropTypes.string,
|
|
})),
|
|
onSelect: PropTypes.func,
|
|
};
|
|
|
|
static defaultProps = {
|
|
onSelect: noop,
|
|
};
|
|
|
|
onOptionClick = (evt) => {
|
|
evt.preventDefault();
|
|
|
|
const { onSelect } = this.props;
|
|
|
|
onSelect(evt);
|
|
|
|
return false;
|
|
}
|
|
|
|
renderOption = (option) => {
|
|
const { disabled = false, value, text } = option;
|
|
const { optionWrapperStyles } = componentStyles;
|
|
|
|
return (
|
|
<option key={value} style={optionWrapperStyles} value={value} disabled={disabled}>
|
|
{text}
|
|
</option>
|
|
);
|
|
}
|
|
|
|
render () {
|
|
const { containerStyles, options } = this.props;
|
|
const { onOptionClick, renderOption } = this;
|
|
const { selectWrapperStyles } = componentStyles;
|
|
|
|
return (
|
|
<div className="kolide-dropdown-wrapper">
|
|
<select className="kolide-dropdown" style={[selectWrapperStyles, containerStyles]} onChange={onOptionClick}>
|
|
{options.map(option => {
|
|
return renderOption(option);
|
|
})}
|
|
</select>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default radium(Dropdown);
|