-
Notifications
You must be signed in to change notification settings - Fork 67
/
Plugins.tsx
50 lines (45 loc) 路 1.69 KB
/
Plugins.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
import {Space, Switch, Typography} from 'antd';
import {useState} from 'react';
import {LinterResultPlugin} from 'models/LinterResult.model';
import Trace from 'models/Trace.model';
import TraceAnalyzerAnalytics from 'services/Analytics/TraceAnalyzer.service';
import AnalyzerService from 'services/Analyzer.service';
import * as S from './AnalyzerResult.styled';
import AnalyzerScore from '../AnalyzerScore/AnalyzerScore';
import Rule from './Rule';
import Collapse, {CollapsePanel} from '../Collapse';
interface IProps {
plugins: LinterResultPlugin[];
trace: Trace;
}
const Plugins = ({plugins: rawPlugins, trace}: IProps) => {
const [onlyErrors, setOnlyErrors] = useState(false);
const plugins = AnalyzerService.getPlugins(rawPlugins, onlyErrors);
return (
<>
<S.SwitchContainer>
<Switch checked={onlyErrors} id="only_errors_enabled" onChange={() => setOnlyErrors(prev => !prev)} />
<label htmlFor="only_errors_enabled">Show only errors</label>
</S.SwitchContainer>
<Collapse onChange={() => TraceAnalyzerAnalytics.onPluginClick()}>
{plugins.map(plugin => (
<CollapsePanel
header={
<Space>
<AnalyzerScore width="35px" height="35px" score={plugin.score} />
<Typography.Text strong>{plugin.name}</Typography.Text>
<Typography.Text type="secondary">{plugin.description}</Typography.Text>
</Space>
}
key={plugin.name}
>
{plugin.rules.map(rule => (
<Rule rule={rule} key={rule.name} trace={trace} />
))}
</CollapsePanel>
))}
</Collapse>
</>
);
};
export default Plugins;