mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-17 15:36:48 +00:00
* chore: added jsx-runtime plugin in eslint tsconfig Signed-off-by: GermaVinsmoke <vaibhav1180@gmail.com> * chore: updated react imports Signed-off-by: GermaVinsmoke <vaibhav1180@gmail.com> * chore: renamed redux dispatch Signed-off-by: GermaVinsmoke <vaibhav1180@gmail.com> * fix: build is fixed --------- Signed-off-by: GermaVinsmoke <vaibhav1180@gmail.com> Co-authored-by: Palash Gupta <palashgdev@gmail.com>
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import { Form, Row } from 'antd';
|
|
import FormAlertRules from 'container/FormAlertRules';
|
|
import { useState } from 'react';
|
|
import { AlertTypes } from 'types/api/alerts/alertTypes';
|
|
|
|
import {
|
|
alertDefaults,
|
|
exceptionAlertDefaults,
|
|
logAlertDefaults,
|
|
traceAlertDefaults,
|
|
} from './defaults';
|
|
import SelectAlertType from './SelectAlertType';
|
|
|
|
function CreateRules(): JSX.Element {
|
|
const [initValues, setInitValues] = useState(alertDefaults);
|
|
const [step, setStep] = useState(0);
|
|
const [alertType, setAlertType] = useState<AlertTypes>(
|
|
AlertTypes.METRICS_BASED_ALERT,
|
|
);
|
|
const [formInstance] = Form.useForm();
|
|
|
|
const onSelectType = (typ: AlertTypes): void => {
|
|
setAlertType(typ);
|
|
switch (typ) {
|
|
case AlertTypes.LOGS_BASED_ALERT:
|
|
setInitValues(logAlertDefaults);
|
|
break;
|
|
case AlertTypes.TRACES_BASED_ALERT:
|
|
setInitValues(traceAlertDefaults);
|
|
break;
|
|
case AlertTypes.EXCEPTIONS_BASED_ALERT:
|
|
setInitValues(exceptionAlertDefaults);
|
|
break;
|
|
default:
|
|
setInitValues(alertDefaults);
|
|
}
|
|
setStep(1);
|
|
};
|
|
|
|
if (step === 0) {
|
|
return (
|
|
<Row wrap={false}>
|
|
<SelectAlertType onSelect={onSelectType} />
|
|
</Row>
|
|
);
|
|
}
|
|
return (
|
|
<FormAlertRules
|
|
alertType={alertType}
|
|
formInstance={formInstance}
|
|
initialValue={initValues}
|
|
ruleId={0}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default CreateRules;
|