import {Component, Fragment} from 'react';
import styled from '@emotion/styled';
import SelectControl from 'sentry/components/forms/controls/selectControl';
import FieldGroup from 'sentry/components/forms/fieldGroup';
import {
AlertRuleSensitivity,
AlertRuleThresholdType,
type UnsavedMetricRule,
} from 'sentry/views/alerts/rules/metric/types';
type Props = {
disabled: boolean;
onSensitivityChange: (sensitivity: AlertRuleSensitivity) => void;
onThresholdTypeChange: (thresholdType: AlertRuleThresholdType) => void;
sensitivity: UnsavedMetricRule['sensitivity'];
thresholdType: UnsavedMetricRule['thresholdType'];
/**
* Map of fieldName -> errorMessage
*/
error?: {[fieldName: string]: string};
hideControl?: boolean;
};
type SensitivityFormItemProps = {
onSensitivityChange: (sensitivity: AlertRuleSensitivity) => void;
sensitivity: UnsavedMetricRule['sensitivity'];
};
type DirectionFormItemProps = {
onThresholdTypeChange: (thresholdType: AlertRuleThresholdType) => void;
thresholdType: UnsavedMetricRule['thresholdType'];
};
function SensitivityFormItem({
sensitivity,
onSensitivityChange,
}: SensitivityFormItemProps) {
return (
{
onSensitivityChange(value);
}}
/>
);
}
function DirectionFormItem({
thresholdType,
onThresholdTypeChange,
}: DirectionFormItemProps) {
return (
{
onThresholdTypeChange(value);
}}
/>
);
}
class AnomalyDetectionFormField extends Component {
render() {
const {sensitivity, onSensitivityChange, thresholdType, onThresholdTypeChange} =
this.props;
return (
);
}
}
const StyledField = styled(FieldGroup)`
& > label > div:first-child > span {
display: flex;
flex-direction: row;
}
`;
const SelectContainer = styled('div')`
flex: 1;
`;
export default AnomalyDetectionFormField;