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