Skip to content

Commit

Permalink
refactor: add tooltip on the dashboard chart title
Browse files Browse the repository at this point in the history
告警详情页获取group_id为业务组id;
  • Loading branch information
guguji5 committed Dec 14, 2021
1 parent 2e1e35a commit 96043ed
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "n9e-fe",
"version": "5.0.0-ga-03",
"version": "5.0.0-ga-04",
"scripts": {
"dev": "vite --port 8765 --host",
"preinstall": "sh beforeinstall.sh",
Expand Down
8 changes: 6 additions & 2 deletions src/pages/dashboard/chartGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext, useCallback, ReactElement, RefObject } from 'react';
import { Button, Collapse, Modal, Menu, Dropdown, Divider, Popover, Checkbox } from 'antd';
import { Button, Collapse, Modal, Menu, Dropdown, Divider, Popover, Checkbox, Tooltip } from 'antd';
import { Responsive, WidthProvider } from 'react-grid-layout';
const ResponsiveReactGridLayout = WidthProvider(Responsive);
const { Panel } = Collapse;
Expand Down Expand Up @@ -527,7 +527,11 @@ export default function ChartGroup(props: Props) {
legend: legend,
step,
range,
title: name,
title: (
<Tooltip title={name}>
<span>{name}</span>
</Tooltip>
),
promqls,
legendTitleFormats,
}}
Expand Down
54 changes: 31 additions & 23 deletions src/pages/event/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PageLayout from '@/components/pageLayout';
import React, { useEffect, useState } from 'react';
import { useHistory, useParams } from 'react-router';
import { getAlertEventsById, getHistoryEventsById } from '@/services/warning';
import { Button, Card, Col, Row, Space, Spin, Tag, Typography } from 'antd';
import { Button, Card, Col, message, Row, Space, Spin, Tag, Typography } from 'antd';
import { priorityColor } from '@/utils/constant';
import './detail.less';
import moment from 'moment';
Expand Down Expand Up @@ -56,7 +56,7 @@ const EventDetailPage: React.FC = () => {
label: '事件标签',
key: 'tags',
render(tags) {
return tags.map((tag) => <Tag color='blue'>{tag}</Tag>);
return tags ? tags.map((tag) => <Tag color='blue'>{tag}</Tag>) : '';
},
},
{ label: '对象备注', key: 'target_note' },
Expand Down Expand Up @@ -124,20 +124,22 @@ const EventDetailPage: React.FC = () => {
label: '告警接收组',
key: 'notify_groups_obj',
render(groups) {
return groups.map((group) => <Tag color='blue'>{group.name}</Tag>);
return groups ? groups.map((group) => <Tag color='blue'>{group.name}</Tag>) : '';
},
},
{
label: '回调地址',
key: 'callbacks',
render(callbacks) {
return callbacks.map((callback) => (
<Tag>
<Paragraph copyable style={{ margin: 0 }}>
{callback}
</Paragraph>
</Tag>
));
return callbacks
? callbacks.map((callback) => (
<Tag>
<Paragraph copyable style={{ margin: 0 }}>
{callback}
</Paragraph>
</Tag>
))
: '';
},
},
{
Expand Down Expand Up @@ -174,14 +176,16 @@ const EventDetailPage: React.FC = () => {
type='primary'
onClick={() => {
history.push('/alert-mutes/add', {
tags: eventDetail.tags.map((tag) => {
const [key, value] = tag.split('=');
return {
func: '==',
key,
value,
};
}),
tags: eventDetail.tags
? eventDetail.tags.map((tag) => {
const [key, value] = tag.split('=');
return {
func: '==',
key,
value,
};
})
: [],
});
}}
>
Expand All @@ -190,11 +194,15 @@ const EventDetailPage: React.FC = () => {
{!isHistory && (
<Button
danger
onClick={() =>
deleteAlertEventsModal(busiId, [Number(eventId)], () => {
history.replace('/alert-cur-events');
})
}
onClick={() => {
if (eventDetail.group_id) {
deleteAlertEventsModal(eventDetail.group_id, [Number(eventId)], () => {
history.replace('/alert-cur-events');
});
} else {
message.warn('该告警未返回业务组ID');
}
}}
>
删除
</Button>
Expand Down

0 comments on commit 96043ed

Please sign in to comment.