mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: adds missing type info to the FieldConfigSource
(#43619)
This commit is contained in:
parent
d7273c1158
commit
7de5d5fbd1
@ -4,6 +4,7 @@ import { css } from '@emotion/css';
|
||||
import { FieldConfigSource, GrafanaTheme2, PanelData, ThresholdsConfig } from '@grafana/data';
|
||||
import { PanelRenderer } from '@grafana/runtime';
|
||||
import { PanelContext, PanelContextProvider, useStyles2 } from '@grafana/ui';
|
||||
import { GraphFieldConfig, GraphTresholdsStyleMode } from '@grafana/schema';
|
||||
import { PanelOptions } from 'app/plugins/panel/table/models.gen';
|
||||
import { useVizHeight } from '../../hooks/useVizHeight';
|
||||
import { SupportedPanelPlugins, PanelPluginsButtonGroup } from '../PanelPluginsButtonGroup';
|
||||
@ -17,6 +18,8 @@ interface Props {
|
||||
onThresholdsChange: (thresholds: ThresholdsConfig) => void;
|
||||
}
|
||||
|
||||
type PanelFieldConfig = FieldConfigSource<GraphFieldConfig>;
|
||||
|
||||
export const VizWrapper: FC<Props> = ({ data, currentPanel, changePanel, onThresholdsChange, thresholds }) => {
|
||||
const [options, setOptions] = useState<PanelOptions>({
|
||||
frameIndex: 0,
|
||||
@ -25,7 +28,7 @@ export const VizWrapper: FC<Props> = ({ data, currentPanel, changePanel, onThres
|
||||
const vizHeight = useVizHeight(data, currentPanel, options.frameIndex);
|
||||
const styles = useStyles2(getStyles(vizHeight));
|
||||
|
||||
const [fieldConfig, setFieldConfig] = useState<FieldConfigSource>(defaultFieldConfig(thresholds, data));
|
||||
const [fieldConfig, setFieldConfig] = useState<PanelFieldConfig>(defaultFieldConfig(thresholds, data));
|
||||
|
||||
useEffect(() => {
|
||||
setFieldConfig((fieldConfig) => ({
|
||||
@ -37,7 +40,7 @@ export const VizWrapper: FC<Props> = ({ data, currentPanel, changePanel, onThres
|
||||
custom: {
|
||||
...fieldConfig.defaults.custom,
|
||||
thresholdsStyle: {
|
||||
mode: 'line',
|
||||
mode: GraphTresholdsStyleMode.Line,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -104,7 +107,7 @@ function defaultUnit(data: PanelData): string | undefined {
|
||||
return data.series[0]?.fields.find((field) => field.type === 'number')?.config.unit;
|
||||
}
|
||||
|
||||
function defaultFieldConfig(thresholds: ThresholdsConfig, data: PanelData): FieldConfigSource {
|
||||
function defaultFieldConfig(thresholds: ThresholdsConfig, data: PanelData): PanelFieldConfig {
|
||||
if (!thresholds) {
|
||||
return { defaults: {}, overrides: [] };
|
||||
}
|
||||
@ -115,7 +118,7 @@ function defaultFieldConfig(thresholds: ThresholdsConfig, data: PanelData): Fiel
|
||||
unit: defaultUnit(data),
|
||||
custom: {
|
||||
thresholdsStyle: {
|
||||
mode: 'line',
|
||||
mode: GraphTresholdsStyleMode.Line,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user