perf(explore): virtualized datasource field sections (#27625)

This commit is contained in:
JUST.in DO IT
2024-03-27 11:25:55 -07:00
committed by GitHub
parent c73b24ad08
commit 38eecfc5d4
7 changed files with 504 additions and 185 deletions

View File

@@ -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>