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 */}
<AlertRuleNameAndMetric />
{/* Step 2 */}
<QueryAndExpressionsStep editingExistingRule={!!existing} onDataChange={checkAlertCondition} />
<QueryAndExpressionsStep editingExistingRule={!!existing} onDataChange={checkAlertCondition} mode="edit" />
{/* Step 3-4-5 */}
{showDataSourceDependantStep && (
<>
@@ -100,7 +100,7 @@ export function ModifyExportRuleForm({ ruleForm, alertUid }: ModifyExportRuleFor
{/* Step 1 */}
<AlertRuleNameAndMetric />
{/* Step 2 */}
<QueryAndExpressionsStep editingExistingRule={existing} onDataChange={checkAlertCondition} />
<QueryAndExpressionsStep editingExistingRule={existing} onDataChange={checkAlertCondition} mode="draft" />
{/* Step 3-4-5 */}
<GrafanaFolderAndLabelsStep />
@@ -77,9 +77,15 @@ import { useAlertQueryRunner } from './useAlertQueryRunner';
interface Props {
editingExistingRule: boolean;
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 {
setValue,
getValues,
@@ -515,12 +521,14 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
}}
/>
</Field>
<SmartAlertTypeDetector
editingExistingRule={editingExistingRule}
queries={queries}
rulesSourcesWithRuler={rulesSourcesWithRuler}
onClickSwitch={onClickSwitch}
/>
{mode === 'edit' && (
<SmartAlertTypeDetector
editingExistingRule={editingExistingRule}
queries={queries}
rulesSourcesWithRuler={rulesSourcesWithRuler}
onClickSwitch={onClickSwitch}
/>
)}
</Stack>
)}
@@ -555,7 +563,7 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
</Tooltip>
)}
{/* We only show Switch for Grafana managed alerts */}
{isGrafanaAlertingType && !simplifiedQueryStep && (
{isGrafanaAlertingType && !simplifiedQueryStep && mode === 'edit' && (
<SmartAlertTypeDetector
editingExistingRule={editingExistingRule}
rulesSourcesWithRuler={rulesSourcesWithRuler}