Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Storage): tune popups for vdisk and pdisk #1883

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/components/HoverPopup/HoverPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type HoverPopupProps = {
anchorRef?: React.RefObject<HTMLElement>;
onShowPopup?: VoidFunction;
onHidePopup?: VoidFunction;
delayOpen?: number;
delayClose?: number;
} & Pick<PopupProps, 'placement' | 'contentClassName'>;

export const HoverPopup = ({
Expand All @@ -32,6 +34,8 @@ export const HoverPopup = ({
onHidePopup,
placement = ['top', 'bottom'],
contentClassName,
delayClose = DEBOUNCE_TIMEOUT,
delayOpen = DEBOUNCE_TIMEOUT,
}: HoverPopupProps) => {
const [isPopupVisible, setIsPopupVisible] = React.useState(false);
const anchor = React.useRef<HTMLDivElement>(null);
Expand All @@ -41,8 +45,8 @@ export const HoverPopup = ({
debounce(() => {
setIsPopupVisible(true);
onShowPopup?.();
}, DEBOUNCE_TIMEOUT),
[onShowPopup],
}, delayOpen),
[onShowPopup, delayOpen],
);

const hidePopup = React.useCallback(() => {
Expand All @@ -51,8 +55,8 @@ export const HoverPopup = ({
}, [onHidePopup]);

const debouncedHandleHidePopup = React.useMemo(
() => debounce(hidePopup, DEBOUNCE_TIMEOUT),
[hidePopup],
() => debounce(hidePopup, delayClose),
[hidePopup, delayClose],
);

const onMouseEnter = debouncedHandleShowPopup;
Expand Down
7 changes: 7 additions & 0 deletions src/components/VDisk/VDisk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface VDiskProps {
onShowPopup?: VoidFunction;
onHidePopup?: VoidFunction;
progressBarClassName?: string;
delayOpen?: number;
delayClose?: number;
}

export const VDisk = ({
Expand All @@ -29,6 +31,8 @@ export const VDisk = ({
onShowPopup,
onHidePopup,
progressBarClassName,
delayClose,
delayOpen,
}: VDiskProps) => {
const vDiskPath = getVDiskLink(data);

Expand All @@ -38,6 +42,9 @@ export const VDisk = ({
onShowPopup={onShowPopup}
onHidePopup={onHidePopup}
popupContent={<VDiskPopup data={data} />}
offset={[0, 5]}
delayClose={delayClose}
delayOpen={delayOpen}
>
<div className={b()}>
<InternalLink to={vDiskPath} className={b('content')}>
Expand Down
10 changes: 9 additions & 1 deletion src/containers/Storage/PDisk/PDisk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ export const PDisk = ({
flexGrow: Number(vdisk.AllocatedSize) || 1,
}}
>
<VDisk data={vdisk} inactive={!isVdiskActive(vdisk, viewContext)} compact />
<VDisk
data={vdisk}
inactive={!isVdiskActive(vdisk, viewContext)}
compact
delayClose={200}
delayOpen={200}
/>
</div>
))}
</div>
Expand All @@ -77,10 +83,12 @@ export const PDisk = ({
{renderVDisks()}
<HoverPopup
showPopup={showPopup}
offset={[0, 5]}
anchorRef={anchorRef}
onShowPopup={onShowPopup}
onHidePopup={onHidePopup}
popupContent={<PDiskPopup data={data} />}
delayClose={200}
>
<InternalLink to={pDiskPath} className={b('content')}>
<DiskStateProgressBar
Expand Down
Loading