Skip to content

Commit

Permalink
chore: fix visibility toggle in host filters (#6976)
Browse files Browse the repository at this point in the history
  • Loading branch information
amlannandy authored Jan 29, 2025
1 parent 6dfea14 commit ffd72cf
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
19 changes: 17 additions & 2 deletions frontend/src/container/InfraMonitoringHosts/HostsList.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
}

.hosts-list-controls {
flex: 1;
padding: 8px;

display: flex;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}>
Expand Down

0 comments on commit ffd72cf

Please sign in to comment.