chore: fix visibility toggle in host filters (#6976)

This commit is contained in:
Amlan Kumar Nandy 2025-01-30 00:15:19 +05:30 committed by GitHub
parent 6dfea14219
commit ffd72cf406
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 47 additions and 2 deletions

View File

@ -1,7 +1,7 @@
import './InfraMonitoring.styles.scss';
import { VerticalAlignTopOutlined } from '@ant-design/icons';
import { Tooltip, Typography } from 'antd';
import { Button, Tooltip, Typography } from 'antd';
import logEvent from 'api/common/logEvent';
import { HostListPayload } from 'api/infraMonitoring/getHostLists';
import HostMetricDetail from 'components/HostMetricsDetail';
@ -11,6 +11,7 @@ import { usePageSize } from 'container/InfraMonitoringK8s/utils';
import { useGetHostList } from 'hooks/infraMonitoring/useGetHostList';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations';
import { Filter } from 'lucide-react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useSelector } from 'react-redux';
import { AppState } from 'store/reducers';
@ -140,7 +141,21 @@ function HostsList(): JSX.Element {
</div>
)}
<div className="hosts-list-table-container">
<HostsListControls handleFiltersChange={handleFiltersChange} />
<div className="hosts-list-table-header">
{!showFilters && (
<div className="quick-filters-toggle-container">
<Button
className="periscope-btn ghost"
type="text"
size="small"
onClick={handleFilterVisibilityChange}
>
<Filter size={14} />
</Button>
</div>
)}
<HostsListControls handleFiltersChange={handleFiltersChange} />
</div>
<HostsListTable
isLoading={isLoading}
isFetching={isFetching}

View File

@ -11,6 +11,7 @@
}
.hosts-list-controls {
flex: 1;
padding: 8px;
display: flex;
@ -73,6 +74,16 @@
.hosts-list-table-container {
flex: 1;
.hosts-list-table-header {
display: flex;
justify-content: space-between;
align-items: center;
.quick-filters-toggle-container {
padding: 0 8px;
}
}
}
.hosts-list-table {

View File

@ -37,6 +37,25 @@ function K8sFiltersSidePanel({
}
}, [searchValue]);
// Close side panel when clicking outside of it
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
sidePanelRef.current &&
!sidePanelRef.current.contains(event.target as Node)
) {
onClose();
}
};
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<div className="k8s-filters-side-panel-container">
<div className="k8s-filters-side-panel" ref={sidePanelRef}>