fix: don't allow editing rule types for existing rules (#47512) (#47516)

(cherry picked from commit c530100d45)

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-04-08 15:45:42 +02:00
committed by GitHub
co-authored by Gilles De Mey
parent df94aa979c
commit 056ff9cf32
@@ -38,27 +38,24 @@ export const AlertTypeStep: FC<Props> = ({ editingExistingRule }) => {
return (
<RuleEditorSection stepNo={1} title="Rule type">
<Field
disabled={editingExistingRule}
error={errors.type?.message}
invalid={!!errors.type?.message}
data-testid="alert-type-picker"
>
<InputControl
render={({ field: { onChange } }) => (
<RuleTypePicker
aria-label="Rule type"
selected={getValues('type') ?? RuleFormType.grafana}
onChange={onChange}
/>
)}
name="type"
control={control}
rules={{
required: { value: true, message: 'Please select alert type' },
}}
/>
</Field>
{!editingExistingRule && (
<Field error={errors.type?.message} invalid={!!errors.type?.message} data-testid="alert-type-picker">
<InputControl
render={({ field: { onChange } }) => (
<RuleTypePicker
aria-label="Rule type"
selected={getValues('type') ?? RuleFormType.grafana}
onChange={onChange}
/>
)}
name="type"
control={control}
rules={{
required: { value: true, message: 'Please select alert type' },
}}
/>
</Field>
)}
<Field
className={styles.formInput}