Alerting: Remove rule type switch for modified export mode (#102287)

This commit is contained in:
Konrad Lalik
2025-03-20 15:19:52 +01:00
committed by GitHub
parent d3832c7f8b
commit 41a2aa41f8
3 changed files with 18 additions and 10 deletions
@@ -320,7 +320,7 @@ export const AlertRuleForm = ({ existing, prefill, isManualRestore }: Props) =>
{/* Step 1 */} {/* Step 1 */}
<AlertRuleNameAndMetric /> <AlertRuleNameAndMetric />
{/* Step 2 */} {/* Step 2 */}
<QueryAndExpressionsStep editingExistingRule={!!existing} onDataChange={checkAlertCondition} /> <QueryAndExpressionsStep editingExistingRule={!!existing} onDataChange={checkAlertCondition} mode="edit" />
{/* Step 3-4-5 */} {/* Step 3-4-5 */}
{showDataSourceDependantStep && ( {showDataSourceDependantStep && (
<> <>
@@ -100,7 +100,7 @@ export function ModifyExportRuleForm({ ruleForm, alertUid }: ModifyExportRuleFor
{/* Step 1 */} {/* Step 1 */}
<AlertRuleNameAndMetric /> <AlertRuleNameAndMetric />
{/* Step 2 */} {/* Step 2 */}
<QueryAndExpressionsStep editingExistingRule={existing} onDataChange={checkAlertCondition} /> <QueryAndExpressionsStep editingExistingRule={existing} onDataChange={checkAlertCondition} mode="draft" />
{/* Step 3-4-5 */} {/* Step 3-4-5 */}
<GrafanaFolderAndLabelsStep /> <GrafanaFolderAndLabelsStep />
@@ -77,9 +77,15 @@ import { useAlertQueryRunner } from './useAlertQueryRunner';
interface Props { interface Props {
editingExistingRule: boolean; editingExistingRule: boolean;
onDataChange: (error: string) => void; onDataChange: (error: string) => void;
/**
* The mode of the rule editor.
* - 'edit' standard rule editor mode
* - 'draft' non-saveable form mode used for exporting to provisioning formats
*/
mode: 'edit' | 'draft';
} }
export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: Props) => { export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange, mode }: Props) => {
const { const {
setValue, setValue,
getValues, getValues,
@@ -515,12 +521,14 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
}} }}
/> />
</Field> </Field>
<SmartAlertTypeDetector {mode === 'edit' && (
editingExistingRule={editingExistingRule} <SmartAlertTypeDetector
queries={queries} editingExistingRule={editingExistingRule}
rulesSourcesWithRuler={rulesSourcesWithRuler} queries={queries}
onClickSwitch={onClickSwitch} rulesSourcesWithRuler={rulesSourcesWithRuler}
/> onClickSwitch={onClickSwitch}
/>
)}
</Stack> </Stack>
)} )}
@@ -555,7 +563,7 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
</Tooltip> </Tooltip>
)} )}
{/* We only show Switch for Grafana managed alerts */} {/* We only show Switch for Grafana managed alerts */}
{isGrafanaAlertingType && !simplifiedQueryStep && ( {isGrafanaAlertingType && !simplifiedQueryStep && mode === 'edit' && (
<SmartAlertTypeDetector <SmartAlertTypeDetector
editingExistingRule={editingExistingRule} editingExistingRule={editingExistingRule}
rulesSourcesWithRuler={rulesSourcesWithRuler} rulesSourcesWithRuler={rulesSourcesWithRuler}