mirror of
https://github.com/apache/superset.git
synced 2026-05-09 18:05:52 +00:00
perf(explore): virtualized datasource field sections (#27625)
This commit is contained in:
@@ -229,6 +229,20 @@ const updateHistory = debounce(
|
||||
1000,
|
||||
);
|
||||
|
||||
const defaultSidebarsWidth = {
|
||||
controls_width: 320,
|
||||
datasource_width: 300,
|
||||
};
|
||||
|
||||
function getSidebarWidths(key) {
|
||||
return getItem(key, defaultSidebarsWidth[key]);
|
||||
}
|
||||
|
||||
function setSidebarWidths(key, dimension) {
|
||||
const newDimension = Number(getSidebarWidths(key)) + dimension.width;
|
||||
setItem(key, newDimension);
|
||||
}
|
||||
|
||||
function ExploreViewContainer(props) {
|
||||
const dynamicPluginContext = usePluginContext();
|
||||
const dynamicPlugin = dynamicPluginContext.dynamicPlugins[props.vizType];
|
||||
@@ -243,16 +257,13 @@ function ExploreViewContainer(props) {
|
||||
);
|
||||
|
||||
const [isCollapsed, setIsCollapsed] = useState(false);
|
||||
const [shouldForceUpdate, setShouldForceUpdate] = useState(-1);
|
||||
const [width, setWidth] = useState(
|
||||
getSidebarWidths(LocalStorageKeys.DatasourceWidth),
|
||||
);
|
||||
const tabId = useTabId();
|
||||
|
||||
const theme = useTheme();
|
||||
|
||||
const defaultSidebarsWidth = {
|
||||
controls_width: 320,
|
||||
datasource_width: 300,
|
||||
};
|
||||
|
||||
const addHistory = useCallback(
|
||||
async ({ isReplace = false, title } = {}) => {
|
||||
const formData = props.dashboardId
|
||||
@@ -534,15 +545,6 @@ function ExploreViewContainer(props) {
|
||||
);
|
||||
}
|
||||
|
||||
function getSidebarWidths(key) {
|
||||
return getItem(key, defaultSidebarsWidth[key]);
|
||||
}
|
||||
|
||||
function setSidebarWidths(key, dimension) {
|
||||
const newDimension = Number(getSidebarWidths(key)) + dimension.width;
|
||||
setItem(key, newDimension);
|
||||
}
|
||||
|
||||
if (props.standalone) {
|
||||
return renderChartContainer();
|
||||
}
|
||||
@@ -593,7 +595,7 @@ function ExploreViewContainer(props) {
|
||||
/>
|
||||
<Resizable
|
||||
onResizeStop={(evt, direction, ref, d) => {
|
||||
setShouldForceUpdate(d?.width);
|
||||
setWidth(ref.getBoundingClientRect().width);
|
||||
setSidebarWidths(LocalStorageKeys.DatasourceWidth, d);
|
||||
}}
|
||||
defaultSize={{
|
||||
@@ -627,7 +629,7 @@ function ExploreViewContainer(props) {
|
||||
datasource={props.datasource}
|
||||
controls={props.controls}
|
||||
actions={props.actions}
|
||||
shouldForceUpdate={shouldForceUpdate}
|
||||
width={width}
|
||||
user={props.user}
|
||||
/>
|
||||
</Resizable>
|
||||
|
||||
Reference in New Issue
Block a user