diff --git a/public/app/features/alerting/unified/components/rule-editor/RecordingRuleEditor.tsx b/public/app/features/alerting/unified/components/rule-editor/RecordingRuleEditor.tsx index 6221bfd4770..89416127d04 100644 --- a/public/app/features/alerting/unified/components/rule-editor/RecordingRuleEditor.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/RecordingRuleEditor.tsx @@ -60,14 +60,17 @@ export const RecordingRuleEditor: FC = ({ const merged = { ...query, - refId: changedQuery.refId, - queryType: changedQuery.queryType ?? '', + ...changedQuery, datasourceUid: dataSourceId, expr, model: { - refId: changedQuery.refId, expr, - editorMode: 'code', + datasource: changedQuery.datasource, + refId: changedQuery.refId, + editorMode: changedQuery.editorMode, + instant: Boolean(changedQuery.instant), + range: Boolean(changedQuery.range), + legendFormat: changedQuery.legendFormat, }, }; onChangeQuery([merged]); diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts index 0fc29628ed3..08aecf832f9 100644 --- a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/reducer.ts @@ -80,7 +80,7 @@ export const queriesAndExpressionsReducer = createReducer(initialState, (builder const query = payload.recordingRuleQueries[0]; const recordingRuleQuery = { ...query, - ...{ expr: payload.expression, model: { expr: payload.expression, refId: query.model.refId } }, + ...{ expr: payload.expression, model: query?.model }, }; state.queries = [recordingRuleQuery];