Fix: Rename timezones prop to timezone for plugins compatibility (#53926)

This commit is contained in:
Esteban Beltran 2022-08-19 16:59:56 +02:00 committed by GitHub
parent 4f2d30b153
commit edb54fc8d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 18 additions and 18 deletions

View File

@ -175,7 +175,7 @@ OptionsWithLegend: {
// TODO docs
OptionsWithTimezones: {
timezones?: [...string]
timezone?: [...string]
} @cuetsy(kind="interface")
// TODO docs

View File

@ -208,11 +208,11 @@ export interface OptionsWithLegend {
}
export interface OptionsWithTimezones {
timezones?: string[];
timezone?: string[];
}
export const defaultOptionsWithTimezones: Partial<OptionsWithTimezones> = {
timezones: [],
timezone: [],
};
export interface OptionsWithTextFormatting {

View File

@ -44,7 +44,7 @@ export interface GraphNGProps extends Themeable2 {
width: number;
height: number;
timeRange: TimeRange;
timeZones: TimeZone[] | TimeZone;
timeZone: TimeZone[] | TimeZone;
legend: VizLegendOptions;
fields?: XYFieldMatchers; // default will assume timeseries data
renderers?: Renderers;
@ -216,17 +216,17 @@ export class GraphNG extends Component<GraphNGProps, GraphNGState> {
}
componentDidUpdate(prevProps: GraphNGProps) {
const { frames, structureRev, timeZones, propsToDiff } = this.props;
const { frames, structureRev, timeZone, propsToDiff } = this.props;
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);
if (newState) {
const shouldReconfig =
this.state.config === undefined ||
timeZones !== prevProps.timeZones ||
timeZone !== prevProps.timeZone ||
structureRev !== prevProps.structureRev ||
!structureRev ||
propsChanged;

View File

@ -20,12 +20,12 @@ export class UnthemedTimeSeries extends Component<TimeSeriesProps> {
prepConfig = (alignedFrame: DataFrame, allFrames: DataFrame[], getTimeRange: () => TimeRange) => {
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({
frame: alignedFrame,
theme,
timeZones: Array.isArray(timeZones) ? timeZones : [timeZones],
timeZones: Array.isArray(timeZone) ? timeZone : [timeZone],
getTimeRange,
eventBus,
sync,

View File

@ -277,7 +277,7 @@ export const BarChartPanel: React.FunctionComponent<Props> = ({
preparePlotFrame={(f) => f[0]} // already processed in by the panel above!
renderLegend={renderLegend}
legend={options.legend}
timeZones={timeZone}
timeZone={timeZone}
timeRange={{ from: 1, to: 1 } as unknown as TimeRange} // HACK
structureRev={structureRev}
width={width}

View File

@ -233,7 +233,7 @@ export const CandlestickPanel: React.FC<CandlestickPanelProps> = ({
frames={[info.frame]}
structureRev={data.structureRev}
timeRange={timeRange}
timeZones={timeZone}
timeZone={timeZone}
width={width}
height={height}
legend={options.legend}

View File

@ -67,7 +67,7 @@ export const StateTimelinePanel: React.FC<TimelinePanelProps> = ({
[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(
(alignedData: DataFrame, seriesIdx: number | null, datapointIdx: number | null, onAnnotationAdd?: () => void) => {
@ -153,7 +153,7 @@ export const StateTimelinePanel: React.FC<TimelinePanelProps> = ({
frames={frames}
structureRev={data.structureRev}
timeRange={timeRange}
timeZones={timezones}
timeZone={timezones}
width={width}
height={height}
legendItems={legendItems}

View File

@ -62,7 +62,7 @@ export class TimelineChart extends React.Component<TimelineProps> {
...this.props,
// 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
rowHeight: alignedFrame.fields.length > 2 ? this.props.rowHeight : 1,

View File

@ -126,7 +126,7 @@ export const StatusHistoryPanel: React.FC<TimelinePanelProps> = ({
[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) {
return (
@ -154,7 +154,7 @@ export const StatusHistoryPanel: React.FC<TimelinePanelProps> = ({
frames={frames}
structureRev={data.structureRev}
timeRange={timeRange}
timeZones={timezones}
timeZone={timezones}
width={width}
height={height}
legendItems={legendItems}

View File

@ -37,7 +37,7 @@ export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
};
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) {
return (
@ -58,7 +58,7 @@ export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
frames={frames}
structureRev={data.structureRev}
timeRange={timeRange}
timeZones={timezones}
timeZone={timezones}
width={width}
height={height}
legend={options.legend}