Commit a8cf2dc5 by Peter Holmberg

some touch ups on unit

parent 57227734
......@@ -14,6 +14,15 @@ export default class UnitGroup extends PureComponent<ExtendedGroupProps, State>
expanded: false,
};
componentDidMount() {
const value = this.props.selectProps.value[this.props.selectProps.value.length - 1].value;
console.log(value);
if (value && this.props.options.some(option => option.value === value)) {
this.setState({ expanded: true });
}
}
componentDidUpdate(nextProps) {
if (nextProps.selectProps.inputValue !== '') {
this.setState({ expanded: true });
......
......@@ -8,11 +8,16 @@ import kbn from '../../../utils/kbn';
interface Props {
onSelected: (item: any) => {} | void;
defaultValue?: string;
width?: number;
}
export default class UnitPicker extends PureComponent<Props> {
static defaultProps = {
width: 12,
};
render() {
const { defaultValue, onSelected } = this.props;
const { defaultValue, onSelected, width } = this.props;
const unitGroups = kbn.getUnitFormats();
......@@ -42,6 +47,13 @@ export default class UnitPicker extends PureComponent<Props> {
overflowY: 'auto',
position: 'relative',
} as React.CSSProperties),
valueContainer: () =>
({
overflow: 'hidden',
textOverflow: 'ellipsis',
maxWidth: '90px',
whiteSpace: 'nowrap',
} as React.CSSProperties),
};
const value = groupOptions.map(group => {
......@@ -51,7 +63,7 @@ export default class UnitPicker extends PureComponent<Props> {
return (
<Select
classNamePrefix="gf-form-select-box"
className="width-20 gf-form-input--form-dropdown"
className={`width-${width} gf-form-input--form-dropdown`}
defaultValue={value}
isSearchable={true}
options={groupOptions}
......
......@@ -58,7 +58,7 @@ class GaugeOptions extends PureComponent<PanelOptionsProps<Options>> {
<Label width={5}>Stat</Label>
<SimplePicker
defaultValue={statOptions.find(option => option.value === this.props.options.stat.value)}
width={11}
width={12}
options={statOptions}
getOptionLabel={i => i.text}
getOptionValue={i => i.value}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment