mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Cloudwatch: Dynamic labels frontend migration (#48579)
* migrate metric queries * restructure migrations * self review * cleanup tests * ensure alias is not changed * apply pr feedback
This commit is contained in:
@@ -6,7 +6,7 @@ import { InlineField } from '@grafana/ui';
|
||||
import { Dimensions } from '..';
|
||||
import { CloudWatchDatasource } from '../../datasource';
|
||||
import { useDimensionKeys, useMetrics, useNamespaces, useRegions } from '../../hooks';
|
||||
import { migrateVariableQuery } from '../../migrations';
|
||||
import { migrateVariableQuery } from '../../migrations/variableQueryMigrations';
|
||||
import { CloudWatchJsonData, CloudWatchQuery, VariableQuery, VariableQueryType } from '../../types';
|
||||
|
||||
import { MultiFilter } from './MultiFilter';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import deepEqual from 'fast-deep-equal';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
|
||||
import { migrateMetricQuery } from '../migrations/metricQueryMigrations';
|
||||
import { CloudWatchMetricsQuery, MetricEditorMode, MetricQueryType } from '../types';
|
||||
|
||||
export const DEFAULT_QUERY: Omit<CloudWatchMetricsQuery, 'refId'> = {
|
||||
@@ -21,10 +22,11 @@ export const DEFAULT_QUERY: Omit<CloudWatchMetricsQuery, 'refId'> = {
|
||||
|
||||
const prepareQuery = (query: CloudWatchMetricsQuery) => {
|
||||
const withDefaults = { ...DEFAULT_QUERY, ...query };
|
||||
const migratedQuery = migrateMetricQuery(withDefaults);
|
||||
|
||||
// If we didn't make any changes to the object, then return the original object to keep the
|
||||
// identity the same, and not trigger any other useEffects or anything.
|
||||
return deepEqual(withDefaults, query) ? query : withDefaults;
|
||||
return deepEqual(migratedQuery, query) ? query : migratedQuery;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user