forked from HuolalaTech/page-spy-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
96 lines (93 loc) · 2.78 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { useSocketMessageStore } from '@/store/socket-message';
import { ClearOutlined } from '@ant-design/icons';
import { Row, Col, Tooltip, Button, Select, Space } from 'antd';
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { ProxyType } from '@huolala-tech/page-spy/dist/types/lib/console';
import { ReactComponent as ErrorSvg } from '@/assets/image/error.svg';
import { ReactComponent as InfoSvg } from '@/assets/image/info.svg';
import { ReactComponent as WarnSvg } from '@/assets/image/warn.svg';
import { ReactComponent as UserSvg } from '@/assets/image/user.svg';
import { ReactComponent as DebugSvg } from '@/assets/image/debug.svg';
import './index.less';
export const HeaderActions = () => {
const { t } = useTranslation();
const [clearRecord, changeConsoleMsgFilter] = useSocketMessageStore(
(state) => [state.clearRecord, state.setConsoleMsgTypeFilter],
);
const logLevelList: Array<{
label: string | React.ReactNode;
value: ProxyType;
}> = [
{
label: (
<div className="select-item">
<UserSvg style={{ height: 15, width: 15 }} />
<span className="select-item label-text">User messages</span>
</div>
),
value: 'log',
},
{
label: (
<div className="select-item">
<ErrorSvg style={{ height: 15, width: 15 }} />
<span className="select-item label-text">Errors</span>
</div>
),
value: 'error',
},
{
label: (
<div className="select-item">
<WarnSvg style={{ height: 15, width: 15 }} />
<span className="select-item label-text">Warnings</span>
</div>
),
value: 'warn',
},
{
label: (
<div className="select-item">
<InfoSvg style={{ height: 15, width: 15 }} />
<span className="select-item label-text">Info</span>
</div>
),
value: 'info',
},
{
label: (
<div className="select-item">
<DebugSvg style={{ height: 15, width: 15 }} />
<span className="select-item label-text">Verbose</span>
</div>
),
value: 'debug',
},
];
const clear = useCallback(() => {
clearRecord('console');
}, [clearRecord]);
return (
<Row justify="end">
<Col>
<Space>
<Select
onChange={changeConsoleMsgFilter}
maxTagCount="responsive"
mode="multiple"
allowClear={true}
options={logLevelList}
placeholder="Log Level Filter"
style={{ width: 200 }}
/>
<Tooltip title={t('common.clear')}>
<Button onClick={clear}>
<ClearOutlined />
</Button>
</Tooltip>
</Space>
</Col>
</Row>
);
};