2025-06-12 19:55:32 +05:30
|
|
|
import './AlertList.styles.scss';
|
|
|
|
|
|
2021-11-22 11:49:09 +05:30
|
|
|
import { Tabs } from 'antd';
|
2024-05-24 14:02:37 +05:30
|
|
|
import { TabsProps } from 'antd/lib';
|
2024-09-04 21:26:10 +05:30
|
|
|
import ConfigureIcon from 'assets/AlertHistory/ConfigureIcon';
|
|
|
|
|
import ROUTES from 'constants/routes';
|
2021-11-22 11:49:09 +05:30
|
|
|
import AllAlertRules from 'container/ListAlertRules';
|
2024-05-24 14:02:37 +05:30
|
|
|
import { PlannedDowntime } from 'container/PlannedDowntime/PlannedDowntime';
|
2021-11-22 11:49:09 +05:30
|
|
|
import TriggeredAlerts from 'container/TriggeredAlerts';
|
2025-02-14 08:24:49 +04:30
|
|
|
import { useSafeNavigate } from 'hooks/useSafeNavigate';
|
2024-05-24 14:02:37 +05:30
|
|
|
import useUrlQuery from 'hooks/useUrlQuery';
|
2024-09-04 21:26:10 +05:30
|
|
|
import { GalleryVerticalEnd, Pyramid } from 'lucide-react';
|
|
|
|
|
import AlertDetails from 'pages/AlertDetails';
|
2024-05-24 14:02:37 +05:30
|
|
|
import { useLocation } from 'react-router-dom';
|
2022-03-22 12:10:31 +05:30
|
|
|
|
|
|
|
|
function AllAlertList(): JSX.Element {
|
2024-05-24 14:02:37 +05:30
|
|
|
const urlQuery = useUrlQuery();
|
|
|
|
|
const location = useLocation();
|
2025-02-14 08:24:49 +04:30
|
|
|
const { safeNavigate } = useSafeNavigate();
|
2024-05-24 14:02:37 +05:30
|
|
|
|
|
|
|
|
const tab = urlQuery.get('tab');
|
2024-09-04 21:26:10 +05:30
|
|
|
const isAlertHistory = location.pathname === ROUTES.ALERT_HISTORY;
|
|
|
|
|
const isAlertOverview = location.pathname === ROUTES.ALERT_OVERVIEW;
|
|
|
|
|
|
|
|
|
|
const search = urlQuery.get('search');
|
|
|
|
|
|
2024-05-24 14:02:37 +05:30
|
|
|
const items: TabsProps['items'] = [
|
2023-03-22 12:01:37 +05:30
|
|
|
{
|
2024-09-04 21:26:10 +05:30
|
|
|
label: (
|
|
|
|
|
<div className="periscope-tab top-level-tab">
|
|
|
|
|
<GalleryVerticalEnd size={16} />
|
|
|
|
|
Triggered Alerts
|
|
|
|
|
</div>
|
|
|
|
|
),
|
2024-05-24 14:02:37 +05:30
|
|
|
key: 'TriggeredAlerts',
|
2023-03-22 12:01:37 +05:30
|
|
|
children: <TriggeredAlerts />,
|
|
|
|
|
},
|
2024-05-24 14:02:37 +05:30
|
|
|
{
|
2024-09-04 21:26:10 +05:30
|
|
|
label: (
|
|
|
|
|
<div className="periscope-tab top-level-tab">
|
|
|
|
|
<Pyramid size={16} />
|
|
|
|
|
Alert Rules
|
|
|
|
|
</div>
|
|
|
|
|
),
|
|
|
|
|
key: 'AlertRules',
|
|
|
|
|
children:
|
|
|
|
|
isAlertHistory || isAlertOverview ? <AlertDetails /> : <AllAlertRules />,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: (
|
|
|
|
|
<div className="periscope-tab top-level-tab">
|
|
|
|
|
<ConfigureIcon />
|
|
|
|
|
Configuration
|
|
|
|
|
</div>
|
|
|
|
|
),
|
2024-05-24 14:02:37 +05:30
|
|
|
key: 'Configuration',
|
|
|
|
|
children: <PlannedDowntime />,
|
|
|
|
|
},
|
2023-03-22 12:01:37 +05:30
|
|
|
];
|
2021-11-22 11:49:09 +05:30
|
|
|
|
2023-03-22 12:01:37 +05:30
|
|
|
return (
|
2024-05-24 14:02:37 +05:30
|
|
|
<Tabs
|
|
|
|
|
destroyInactiveTabPane
|
|
|
|
|
items={items}
|
|
|
|
|
activeKey={tab || 'AlertRules'}
|
|
|
|
|
onChange={(tab): void => {
|
|
|
|
|
urlQuery.set('tab', tab);
|
2024-09-04 21:26:10 +05:30
|
|
|
let params = `tab=${tab}`;
|
|
|
|
|
|
|
|
|
|
if (search) {
|
|
|
|
|
params += `&search=${search}`;
|
|
|
|
|
}
|
2025-02-14 08:24:49 +04:30
|
|
|
safeNavigate(`/alerts?${params}`);
|
2024-05-24 14:02:37 +05:30
|
|
|
}}
|
2025-06-12 19:55:32 +05:30
|
|
|
className={`alerts-container ${
|
2024-09-04 21:26:10 +05:30
|
|
|
isAlertHistory || isAlertOverview ? 'alert-details-tabs' : ''
|
|
|
|
|
}`}
|
2024-05-24 14:02:37 +05:30
|
|
|
/>
|
2021-11-22 11:49:09 +05:30
|
|
|
);
|
2022-03-22 12:10:31 +05:30
|
|
|
}
|
2021-11-22 11:49:09 +05:30
|
|
|
|
|
|
|
|
export default AllAlertList;
|