Commit 9e24c094 by Dominik Prokop Committed by GitHub

Transformations: Make transform dropdowns not cropped (#24615)

parent ab12c908
...@@ -14,6 +14,7 @@ interface Props { ...@@ -14,6 +14,7 @@ interface Props {
allowMultiple?: boolean; allowMultiple?: boolean;
defaultStat?: string; defaultStat?: string;
className?: string; className?: string;
menuPlacement?: 'auto' | 'bottom' | 'top';
} }
export class StatsPicker extends PureComponent<Props> { export class StatsPicker extends PureComponent<Props> {
...@@ -62,7 +63,7 @@ export class StatsPicker extends PureComponent<Props> { ...@@ -62,7 +63,7 @@ export class StatsPicker extends PureComponent<Props> {
}; };
render() { render() {
const { stats, allowMultiple, defaultStat, placeholder, className } = this.props; const { stats, allowMultiple, defaultStat, placeholder, className, menuPlacement } = this.props;
const select = fieldReducers.selectOptions(stats); const select = fieldReducers.selectOptions(stats);
return ( return (
...@@ -75,6 +76,7 @@ export class StatsPicker extends PureComponent<Props> { ...@@ -75,6 +76,7 @@ export class StatsPicker extends PureComponent<Props> {
options={select.options} options={select.options}
placeholder={placeholder} placeholder={placeholder}
onChange={this.onSelectionChange} onChange={this.onSelectionChange}
menuPlacement={menuPlacement}
/> />
); );
} }
......
...@@ -17,6 +17,7 @@ interface ValuePickerProps<T> { ...@@ -17,6 +17,7 @@ interface ValuePickerProps<T> {
variant?: ButtonVariant; variant?: ButtonVariant;
size?: ComponentSize; size?: ComponentSize;
isFullWidth?: boolean; isFullWidth?: boolean;
menuPlacement?: 'auto' | 'bottom' | 'top';
} }
export function ValuePicker<T>({ export function ValuePicker<T>({
...@@ -27,6 +28,7 @@ export function ValuePicker<T>({ ...@@ -27,6 +28,7 @@ export function ValuePicker<T>({
variant, variant,
size = 'sm', size = 'sm',
isFullWidth = true, isFullWidth = true,
menuPlacement,
}: ValuePickerProps<T>) { }: ValuePickerProps<T>) {
const [isPicking, setIsPicking] = useState(false); const [isPicking, setIsPicking] = useState(false);
...@@ -50,6 +52,7 @@ export function ValuePicker<T>({ ...@@ -50,6 +52,7 @@ export function ValuePicker<T>({
setIsPicking(false); setIsPicking(false);
onChange(value); onChange(value);
}} }}
menuPlacement={menuPlacement}
/> />
)} )}
</> </>
......
...@@ -201,6 +201,7 @@ export class CalculateFieldTransformerEditor extends React.PureComponent< ...@@ -201,6 +201,7 @@ export class CalculateFieldTransformerEditor extends React.PureComponent<
stats={[options.reducer]} stats={[options.reducer]}
onChange={this.onStatsChange} onChange={this.onStatsChange}
defaultStat={ReducerID.sum} defaultStat={ReducerID.sum}
menuPlacement="bottom"
/> />
</div> </div>
</div> </div>
...@@ -279,12 +280,14 @@ export class CalculateFieldTransformerEditor extends React.PureComponent< ...@@ -279,12 +280,14 @@ export class CalculateFieldTransformerEditor extends React.PureComponent<
className="min-width-18 gf-form-spacing" className="min-width-18 gf-form-spacing"
value={options?.left} value={options?.left}
onChange={this.onBinaryLeftChanged} onChange={this.onBinaryLeftChanged}
menuPlacement="bottom"
/> />
<Select <Select
className="width-8 gf-form-spacing" className="width-8 gf-form-spacing"
options={ops} options={ops}
value={options.operator ?? ops[0].value} value={options.operator ?? ops[0].value}
onChange={this.onBinaryOperationChanged} onChange={this.onBinaryOperationChanged}
menuPlacement="bottom"
/> />
<Select <Select
allowCustomValue allowCustomValue
...@@ -293,6 +296,7 @@ export class CalculateFieldTransformerEditor extends React.PureComponent< ...@@ -293,6 +296,7 @@ export class CalculateFieldTransformerEditor extends React.PureComponent<
options={rightNames} options={rightNames}
value={options?.right} value={options?.right}
onChange={this.onBinaryRightChanged} onChange={this.onBinaryRightChanged}
menuPlacement="bottom"
/> />
</div> </div>
</div> </div>
...@@ -318,6 +322,7 @@ export class CalculateFieldTransformerEditor extends React.PureComponent< ...@@ -318,6 +322,7 @@ export class CalculateFieldTransformerEditor extends React.PureComponent<
options={calculationModes} options={calculationModes}
value={calculationModes.find(v => v.value === mode)} value={calculationModes.find(v => v.value === mode)}
onChange={this.onModeChanged} onChange={this.onModeChanged}
menuPlacement="bottom"
/> />
</div> </div>
</div> </div>
......
...@@ -30,6 +30,7 @@ export const ReduceTransformerEditor: React.FC<TransformerUIProps<ReduceTransfor ...@@ -30,6 +30,7 @@ export const ReduceTransformerEditor: React.FC<TransformerUIProps<ReduceTransfor
reducers: stats as ReducerID[], reducers: stats as ReducerID[],
}); });
}} }}
menuPlacement="bottom"
/> />
</div> </div>
</div> </div>
......
...@@ -33,7 +33,13 @@ export const SeriesToFieldsTransformerEditor: React.FC<TransformerUIProps<Series ...@@ -33,7 +33,13 @@ export const SeriesToFieldsTransformerEditor: React.FC<TransformerUIProps<Series
<div className="gf-form-inline"> <div className="gf-form-inline">
<div className="gf-form gf-form--grow"> <div className="gf-form gf-form--grow">
<div className="gf-form-label width-8">Field name</div> <div className="gf-form-label width-8">Field name</div>
<Select options={fieldNameOptions} value={options.byField} onChange={onSelectField} isClearable /> <Select
options={fieldNameOptions}
value={options.byField}
onChange={onSelectField}
isClearable
menuPlacement="bottom"
/>
</div> </div>
</div> </div>
); );
......
...@@ -65,14 +65,21 @@ export class TransformationsEditor extends React.PureComponent<Props> { ...@@ -65,14 +65,21 @@ export class TransformationsEditor extends React.PureComponent<Props> {
}); });
return ( return (
<ValuePicker <div
size="md" className={css`
variant="secondary" max-width: 66%;
label="Add transformation" `}
options={availableTransformers} >
onChange={this.onTransformationAdd} <ValuePicker
isFullWidth={false} size="md"
/> variant="secondary"
label="Add transformation"
options={availableTransformers}
onChange={this.onTransformationAdd}
isFullWidth={false}
menuPlacement="bottom"
/>
</div>
); );
}; };
......
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