mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-11 08:23:40 +00:00
fix the entity collapsable right panel (#21317)
* fix the entity collapsable right panel * minor condition fix * optimize the code
This commit is contained in:
parent
4dab2be0ab
commit
25a00c6d1e
@ -11,7 +11,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
import { isEmpty, once } from 'lodash';
|
import { once } from 'lodash';
|
||||||
import React, {
|
import React, {
|
||||||
useCallback,
|
useCallback,
|
||||||
useContext,
|
useContext,
|
||||||
@ -152,30 +152,40 @@ export const GenericProvider = <T extends Omit<EntityReference, 'type'>>({
|
|||||||
// Handle the left side panel expand collapse
|
// Handle the left side panel expand collapse
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLayout((prev) => {
|
setLayout((prev) => {
|
||||||
if (!prev || !leftPanelWidget) {
|
// If layout is empty or no left panel widget, return as is
|
||||||
|
if (!prev?.length || !leftPanelWidget) {
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we need to update the layout
|
||||||
|
const currentLeftPanel = prev.find((widget) =>
|
||||||
|
widget.i.startsWith(DetailPageWidgetKeys.LEFT_PANEL)
|
||||||
|
);
|
||||||
|
|
||||||
|
const targetWidth = isTabExpanded ? 8 : 6;
|
||||||
|
|
||||||
|
// If the width is already what we want, don't update
|
||||||
|
if (currentLeftPanel?.w === targetWidth) {
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTabExpanded) {
|
if (isTabExpanded) {
|
||||||
const widget = leftPanelWidget;
|
// Store the current layout before modifying
|
||||||
widget.w = 8;
|
expandedLayout.current = [...prev];
|
||||||
|
|
||||||
// Store the expanded layout
|
|
||||||
expandedLayout.current = prev;
|
|
||||||
|
|
||||||
return [widget];
|
|
||||||
} else {
|
|
||||||
const leftPanelWidget = expandedLayout.current.find((widget) =>
|
|
||||||
widget.i.startsWith(DetailPageWidgetKeys.LEFT_PANEL)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (leftPanelWidget) {
|
|
||||||
leftPanelWidget.w = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore the collapsed layout
|
|
||||||
return isEmpty(expandedLayout.current) ? prev : expandedLayout.current;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the source layout to modify
|
||||||
|
const sourceLayout = isTabExpanded
|
||||||
|
? prev
|
||||||
|
: expandedLayout.current || prev;
|
||||||
|
|
||||||
|
// Update the layout with new width
|
||||||
|
return sourceLayout.map((widget) => ({
|
||||||
|
...widget,
|
||||||
|
w: widget.i.startsWith(DetailPageWidgetKeys.LEFT_PANEL)
|
||||||
|
? targetWidth
|
||||||
|
: widget.w,
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
}, [isTabExpanded, leftPanelWidget]);
|
}, [isTabExpanded, leftPanelWidget]);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user