mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix: Rename timezones prop to timezone for plugins compatibility (#53926)
This commit is contained in:
parent
4f2d30b153
commit
edb54fc8d3
@ -175,7 +175,7 @@ OptionsWithLegend: {
|
|||||||
|
|
||||||
// TODO docs
|
// TODO docs
|
||||||
OptionsWithTimezones: {
|
OptionsWithTimezones: {
|
||||||
timezones?: [...string]
|
timezone?: [...string]
|
||||||
} @cuetsy(kind="interface")
|
} @cuetsy(kind="interface")
|
||||||
|
|
||||||
// TODO docs
|
// TODO docs
|
||||||
|
@ -208,11 +208,11 @@ export interface OptionsWithLegend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface OptionsWithTimezones {
|
export interface OptionsWithTimezones {
|
||||||
timezones?: string[];
|
timezone?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultOptionsWithTimezones: Partial<OptionsWithTimezones> = {
|
export const defaultOptionsWithTimezones: Partial<OptionsWithTimezones> = {
|
||||||
timezones: [],
|
timezone: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface OptionsWithTextFormatting {
|
export interface OptionsWithTextFormatting {
|
||||||
|
@ -44,7 +44,7 @@ export interface GraphNGProps extends Themeable2 {
|
|||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
timeRange: TimeRange;
|
timeRange: TimeRange;
|
||||||
timeZones: TimeZone[] | TimeZone;
|
timeZone: TimeZone[] | TimeZone;
|
||||||
legend: VizLegendOptions;
|
legend: VizLegendOptions;
|
||||||
fields?: XYFieldMatchers; // default will assume timeseries data
|
fields?: XYFieldMatchers; // default will assume timeseries data
|
||||||
renderers?: Renderers;
|
renderers?: Renderers;
|
||||||
@ -216,17 +216,17 @@ export class GraphNG extends Component<GraphNGProps, GraphNGState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps: GraphNGProps) {
|
componentDidUpdate(prevProps: GraphNGProps) {
|
||||||
const { frames, structureRev, timeZones, propsToDiff } = this.props;
|
const { frames, structureRev, timeZone, propsToDiff } = this.props;
|
||||||
|
|
||||||
const propsChanged = !sameProps(prevProps, this.props, propsToDiff);
|
const propsChanged = !sameProps(prevProps, this.props, propsToDiff);
|
||||||
|
|
||||||
if (frames !== prevProps.frames || propsChanged || timeZones !== prevProps.timeZones) {
|
if (frames !== prevProps.frames || propsChanged || timeZone !== prevProps.timeZone) {
|
||||||
let newState = this.prepState(this.props, false);
|
let newState = this.prepState(this.props, false);
|
||||||
|
|
||||||
if (newState) {
|
if (newState) {
|
||||||
const shouldReconfig =
|
const shouldReconfig =
|
||||||
this.state.config === undefined ||
|
this.state.config === undefined ||
|
||||||
timeZones !== prevProps.timeZones ||
|
timeZone !== prevProps.timeZone ||
|
||||||
structureRev !== prevProps.structureRev ||
|
structureRev !== prevProps.structureRev ||
|
||||||
!structureRev ||
|
!structureRev ||
|
||||||
propsChanged;
|
propsChanged;
|
||||||
|
@ -20,12 +20,12 @@ export class UnthemedTimeSeries extends Component<TimeSeriesProps> {
|
|||||||
|
|
||||||
prepConfig = (alignedFrame: DataFrame, allFrames: DataFrame[], getTimeRange: () => TimeRange) => {
|
prepConfig = (alignedFrame: DataFrame, allFrames: DataFrame[], getTimeRange: () => TimeRange) => {
|
||||||
const { eventBus, sync } = this.context as PanelContext;
|
const { eventBus, sync } = this.context as PanelContext;
|
||||||
const { theme, timeZones, renderers, tweakAxis, tweakScale } = this.props;
|
const { theme, timeZone, renderers, tweakAxis, tweakScale } = this.props;
|
||||||
|
|
||||||
return preparePlotConfigBuilder({
|
return preparePlotConfigBuilder({
|
||||||
frame: alignedFrame,
|
frame: alignedFrame,
|
||||||
theme,
|
theme,
|
||||||
timeZones: Array.isArray(timeZones) ? timeZones : [timeZones],
|
timeZones: Array.isArray(timeZone) ? timeZone : [timeZone],
|
||||||
getTimeRange,
|
getTimeRange,
|
||||||
eventBus,
|
eventBus,
|
||||||
sync,
|
sync,
|
||||||
|
@ -277,7 +277,7 @@ export const BarChartPanel: React.FunctionComponent<Props> = ({
|
|||||||
preparePlotFrame={(f) => f[0]} // already processed in by the panel above!
|
preparePlotFrame={(f) => f[0]} // already processed in by the panel above!
|
||||||
renderLegend={renderLegend}
|
renderLegend={renderLegend}
|
||||||
legend={options.legend}
|
legend={options.legend}
|
||||||
timeZones={timeZone}
|
timeZone={timeZone}
|
||||||
timeRange={{ from: 1, to: 1 } as unknown as TimeRange} // HACK
|
timeRange={{ from: 1, to: 1 } as unknown as TimeRange} // HACK
|
||||||
structureRev={structureRev}
|
structureRev={structureRev}
|
||||||
width={width}
|
width={width}
|
||||||
|
@ -233,7 +233,7 @@ export const CandlestickPanel: React.FC<CandlestickPanelProps> = ({
|
|||||||
frames={[info.frame]}
|
frames={[info.frame]}
|
||||||
structureRev={data.structureRev}
|
structureRev={data.structureRev}
|
||||||
timeRange={timeRange}
|
timeRange={timeRange}
|
||||||
timeZones={timeZone}
|
timeZone={timeZone}
|
||||||
width={width}
|
width={width}
|
||||||
height={height}
|
height={height}
|
||||||
legend={options.legend}
|
legend={options.legend}
|
||||||
|
@ -67,7 +67,7 @@ export const StateTimelinePanel: React.FC<TimelinePanelProps> = ({
|
|||||||
[frames, options.legend, theme]
|
[frames, options.legend, theme]
|
||||||
);
|
);
|
||||||
|
|
||||||
const timezones = useMemo(() => getTimezones(options.timezones, timeZone), [options.timezones, timeZone]);
|
const timezones = useMemo(() => getTimezones(options.timezone, timeZone), [options.timezone, timeZone]);
|
||||||
|
|
||||||
const renderCustomTooltip = useCallback(
|
const renderCustomTooltip = useCallback(
|
||||||
(alignedData: DataFrame, seriesIdx: number | null, datapointIdx: number | null, onAnnotationAdd?: () => void) => {
|
(alignedData: DataFrame, seriesIdx: number | null, datapointIdx: number | null, onAnnotationAdd?: () => void) => {
|
||||||
@ -153,7 +153,7 @@ export const StateTimelinePanel: React.FC<TimelinePanelProps> = ({
|
|||||||
frames={frames}
|
frames={frames}
|
||||||
structureRev={data.structureRev}
|
structureRev={data.structureRev}
|
||||||
timeRange={timeRange}
|
timeRange={timeRange}
|
||||||
timeZones={timezones}
|
timeZone={timezones}
|
||||||
width={width}
|
width={width}
|
||||||
height={height}
|
height={height}
|
||||||
legendItems={legendItems}
|
legendItems={legendItems}
|
||||||
|
@ -62,7 +62,7 @@ export class TimelineChart extends React.Component<TimelineProps> {
|
|||||||
...this.props,
|
...this.props,
|
||||||
|
|
||||||
// Ensure timezones is passed as an array
|
// Ensure timezones is passed as an array
|
||||||
timeZones: Array.isArray(this.props.timeZones) ? this.props.timeZones : [this.props.timeZones],
|
timeZones: Array.isArray(this.props.timeZone) ? this.props.timeZone : [this.props.timeZone],
|
||||||
|
|
||||||
// When there is only one row, use the full space
|
// When there is only one row, use the full space
|
||||||
rowHeight: alignedFrame.fields.length > 2 ? this.props.rowHeight : 1,
|
rowHeight: alignedFrame.fields.length > 2 ? this.props.rowHeight : 1,
|
||||||
|
@ -126,7 +126,7 @@ export const StatusHistoryPanel: React.FC<TimelinePanelProps> = ({
|
|||||||
[timeZone, frames, shouldDisplayCloseButton]
|
[timeZone, frames, shouldDisplayCloseButton]
|
||||||
);
|
);
|
||||||
|
|
||||||
const timezones = useMemo(() => getTimezones(options.timezones, timeZone), [options.timezones, timeZone]);
|
const timezones = useMemo(() => getTimezones(options.timezone, timeZone), [options.timezone, timeZone]);
|
||||||
|
|
||||||
if (!frames || warn) {
|
if (!frames || warn) {
|
||||||
return (
|
return (
|
||||||
@ -154,7 +154,7 @@ export const StatusHistoryPanel: React.FC<TimelinePanelProps> = ({
|
|||||||
frames={frames}
|
frames={frames}
|
||||||
structureRev={data.structureRev}
|
structureRev={data.structureRev}
|
||||||
timeRange={timeRange}
|
timeRange={timeRange}
|
||||||
timeZones={timezones}
|
timeZone={timezones}
|
||||||
width={width}
|
width={width}
|
||||||
height={height}
|
height={height}
|
||||||
legendItems={legendItems}
|
legendItems={legendItems}
|
||||||
|
@ -37,7 +37,7 @@ export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const frames = useMemo(() => prepareGraphableFields(data.series, config.theme2, timeRange), [data, timeRange]);
|
const frames = useMemo(() => prepareGraphableFields(data.series, config.theme2, timeRange), [data, timeRange]);
|
||||||
const timezones = useMemo(() => getTimezones(options.timezones, timeZone), [options.timezones, timeZone]);
|
const timezones = useMemo(() => getTimezones(options.timezone, timeZone), [options.timezone, timeZone]);
|
||||||
|
|
||||||
if (!frames) {
|
if (!frames) {
|
||||||
return (
|
return (
|
||||||
@ -58,7 +58,7 @@ export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
|
|||||||
frames={frames}
|
frames={frames}
|
||||||
structureRev={data.structureRev}
|
structureRev={data.structureRev}
|
||||||
timeRange={timeRange}
|
timeRange={timeRange}
|
||||||
timeZones={timezones}
|
timeZone={timezones}
|
||||||
width={width}
|
width={width}
|
||||||
height={height}
|
height={height}
|
||||||
legend={options.legend}
|
legend={options.legend}
|
||||||
|
Loading…
Reference in New Issue
Block a user