mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: fixing so we can edit queries on existing alerting rules. (#34227)
* fixing so old query editors can mutate the query object. * fixing so angular editors that mutate state works.
This commit is contained in:
parent
d30efb4651
commit
8b9ff62cbb
@ -28,6 +28,7 @@ export const QueryOperationAction: React.FC<QueryOperationActionProps> = ({ icon
|
||||
disabled={!!disabled}
|
||||
onClick={onClick}
|
||||
surface="header"
|
||||
type="button"
|
||||
aria-label={selectors.components.QueryEditorRow.actionButton(title)}
|
||||
/>
|
||||
);
|
||||
|
@ -28,7 +28,11 @@ export class AlertingQueryRows extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
onRemoveQuery = (query: DataQuery) => {
|
||||
this.props.onQueriesChange(this.props.queries.filter((item) => item.model !== query));
|
||||
this.props.onQueriesChange(
|
||||
this.props.queries.filter((item) => {
|
||||
return item.model.refId !== query.refId;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
onChangeTimeRange = (timeRange: RelativeTimeRange, index: number) => {
|
||||
|
@ -13,6 +13,7 @@ import { QueryEditorRow } from '../../query/components/QueryEditorRow';
|
||||
import { VizWrapper } from '../unified/components/rule-editor/VizWrapper';
|
||||
import { isExpressionQuery } from '../../expressions/guards';
|
||||
import { GrafanaQuery } from 'app/types/unified-alerting-dto';
|
||||
import { cloneDeep } from 'lodash';
|
||||
|
||||
interface Props {
|
||||
data: PanelData;
|
||||
@ -66,7 +67,7 @@ export const AlertingQueryWrapper: FC<Props> = ({
|
||||
index={index}
|
||||
key={query.refId}
|
||||
data={data}
|
||||
query={query.model}
|
||||
query={cloneDeep(query.model)}
|
||||
onChange={(query) => onChangeQuery(query, index)}
|
||||
onRemoveQuery={onRemoveQuery}
|
||||
onAddQuery={onDuplicateQuery}
|
||||
|
Loading…
Reference in New Issue
Block a user