mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
fix(Explore): "Customize" tab rendering behavior (#15841)
* Remove getDerivedStateFromProps * Set loading
This commit is contained in:
parent
1297fd9169
commit
e6a37022ac
@ -118,6 +118,7 @@ type ControlPanelsContainerState = {
|
|||||||
expandedCustomizeSections: string[];
|
expandedCustomizeSections: string[];
|
||||||
querySections: ControlPanelSectionConfig[];
|
querySections: ControlPanelSectionConfig[];
|
||||||
customizeSections: ControlPanelSectionConfig[];
|
customizeSections: ControlPanelSectionConfig[];
|
||||||
|
loading: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const isTimeSection = (section: ControlPanelSectionConfig): boolean =>
|
const isTimeSection = (section: ControlPanelSectionConfig): boolean =>
|
||||||
@ -189,6 +190,7 @@ function getState(
|
|||||||
expandedCustomizeSections,
|
expandedCustomizeSections,
|
||||||
querySections,
|
querySections,
|
||||||
customizeSections,
|
customizeSections,
|
||||||
|
loading: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,24 +208,12 @@ export class ControlPanelsContainer extends React.Component<
|
|||||||
expandedCustomizeSections: [],
|
expandedCustomizeSections: [],
|
||||||
querySections: [],
|
querySections: [],
|
||||||
customizeSections: [],
|
customizeSections: [],
|
||||||
|
loading: false,
|
||||||
};
|
};
|
||||||
this.renderControl = this.renderControl.bind(this);
|
this.renderControl = this.renderControl.bind(this);
|
||||||
this.renderControlPanelSection = this.renderControlPanelSection.bind(this);
|
this.renderControlPanelSection = this.renderControlPanelSection.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDerivedStateFromProps(
|
|
||||||
props: ControlPanelsContainerProps,
|
|
||||||
state: ControlPanelsContainerState,
|
|
||||||
): ControlPanelsContainerState {
|
|
||||||
// only update the sections, not the expanded/collapsed state
|
|
||||||
const newState = getState(props);
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
customizeSections: newState.customizeSections,
|
|
||||||
querySections: newState.querySections,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate(prevProps: ControlPanelsContainerProps) {
|
componentDidUpdate(prevProps: ControlPanelsContainerProps) {
|
||||||
if (
|
if (
|
||||||
this.props.form_data.datasource !== prevProps.form_data.datasource ||
|
this.props.form_data.datasource !== prevProps.form_data.datasource ||
|
||||||
@ -234,6 +224,17 @@ export class ControlPanelsContainer extends React.Component<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// required for an Antd bug that would otherwise malfunction re-rendering
|
||||||
|
// a collapsed panel after changing the datasource or viz type
|
||||||
|
UNSAFE_componentWillReceiveProps(nextProps: ControlPanelsContainerProps) {
|
||||||
|
if (
|
||||||
|
this.props.form_data.datasource !== nextProps.form_data.datasource ||
|
||||||
|
this.props.form_data.viz_type !== nextProps.form_data.viz_type
|
||||||
|
) {
|
||||||
|
this.setState({ loading: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.setState(getState(this.props));
|
this.setState(getState(this.props));
|
||||||
}
|
}
|
||||||
@ -382,8 +383,9 @@ export class ControlPanelsContainer extends React.Component<
|
|||||||
render() {
|
render() {
|
||||||
const controlPanelRegistry = getChartControlPanelRegistry();
|
const controlPanelRegistry = getChartControlPanelRegistry();
|
||||||
if (
|
if (
|
||||||
!controlPanelRegistry.has(this.props.form_data.viz_type) &&
|
(!controlPanelRegistry.has(this.props.form_data.viz_type) &&
|
||||||
this.context.loading
|
this.context.loading) ||
|
||||||
|
this.state.loading
|
||||||
) {
|
) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user