Skip to content

Commit

Permalink
fix cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie committed Sep 30, 2022
1 parent a58e167 commit d9c2575
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ const time_grain_sqla: SharedControlConfig<'SelectControl'> = {
label: TIME_FILTER_LABELS.time_grain_sqla,
initialValue: (control: ControlState, state: ControlPanelState) => {
if (!isDefined(state)) {
// should return control value if the chart is from Dashboard
// If a chart is in a Dashboard, the ControlPanelState is empty.
return control.value;
}
// use default value 'P1D' for a new chart only.
return isDefined(state.slice) ? control.value : 'P1D';
// if a chart is a new one that isn't saved, the 'time_grain_sqla' isn't in the form_data.
return 'time_grain_sqla' in (state?.form_data ?? {})
? state.form_data?.time_grain_sqla
: 'P1D';
},
description: t(
'The time granularity for the visualization. This ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export interface ControlPanelState {
form_data: QueryFormData;
datasource: Dataset | QueryResponse | null;
controls: ControlStateMapping;
slice?: AnyDict;
}

/**
Expand Down

0 comments on commit d9c2575

Please sign in to comment.