aboutsummaryrefslogtreecommitdiff
path: root/src/listComponents.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/listComponents.js')
-rw-r--r--src/listComponents.js135
1 files changed, 135 insertions, 0 deletions
diff --git a/src/listComponents.js b/src/listComponents.js
new file mode 100644
index 0000000..f830538
--- /dev/null
+++ b/src/listComponents.js
@@ -0,0 +1,135 @@
1/*
2 * JaCoCo Report Viewer, a web-based coverage report viewer
3 * Copyright (C) 2018 Pacien TRAN-GIRARD
4 * Adam NAILI
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20import React, { Component } from 'react';
21import { CoverageListing } from './CoverageListing.js';
22
23function renderRows(renderRowFunc, rows, inline) {
24 const renderedRows = rows ? rows.map(renderRowFunc) : (<li>None.</li>);
25 return (<ul inline-list={inline.toString()}>{renderedRows}</ul>);
26}
27
28export class SessionInfo extends Component {
29 _renderRow(row) {
30 const date = new Date(parseInt(row.start));
31 return (<li key={row.id}>{row.id}: {date.toISOString()} ({row.dump - row.start} ms)</li>);
32 }
33
34 render() {
35 return renderRows(row => this._renderRow(row.$), this.props.data, false);
36 }
37}
38
39export class Counters extends Component {
40 _renderRow(row) {
41 const covered = parseInt(row.covered);
42 const totalCount = covered + parseInt(row.missed);
43 const wellCovered = covered === totalCount;
44 return (<li key={row.type} well-covered={wellCovered.toString()}>{row.type}: {covered}/{totalCount}</li>);
45 }
46
47 render() {
48 return renderRows(row => this._renderRow(row.$), this.props.data, this.props.inlineList !== undefined);
49 }
50}
51
52export class PackagesCoverage extends Component {
53 _renderRow(row) {
54 return (
55 <li key={row.$.name}>
56 <span>{row.$.name}</span>
57 <Counters data={row.counter} inlineList="true" />
58 <ClassesCoverage classes={row.class} />
59 </li>
60 )
61 }
62
63 render() {
64 return renderRows(this._renderRow, this.props.packages, false);
65 }
66}
67
68class ClassesCoverage extends Component {
69 _renderRow(row) {
70 const counters = row.counter.filter(counter => counter.$.type !== 'CLASS');
71 return (
72 <li key={row.$.name}>
73 <span>{row.$.name}</span>
74 <Counters data={counters} inlineList="true" />
75 <MethodsCoverage methods={row.method} />
76 </li>
77 )
78 }
79
80 render() {
81 return renderRows(this._renderRow, this.props.classes, false);
82 }
83}
84
85class MethodsCoverage extends Component {
86 _renderRow(row) {
87 const counters = row.counter.filter(counter => counter.$.type !== 'METHOD');
88 const method = row.$.name + row.$.desc + ':' + row.$.line;
89 return (
90 <li key={method}>
91 <span>{method}</span>
92 <Counters data={counters} inlineList="true" />
93 </li>
94 )
95 }
96
97 render() {
98 return renderRows(this._renderRow, this.props.methods, false);
99 }
100}
101
102export class PackagesSourceCoverage extends Component {
103 _renderRow(row) {
104 return (
105 <li key={row.$.name}>
106 <span>{row.$.name}</span>
107 <SourcesCoverage package={row.$.name}
108 packageSourceFiles={row.sourcefile}
109 sourceSet={this.props.sourceSet} />
110 </li>
111 )
112 }
113
114 render() {
115 return renderRows(row => this._renderRow(row), this.props.packages, false);
116 }
117}
118
119class SourcesCoverage extends Component {
120 _renderRow(row) {
121 const fileName = this.props.package + '/' + row.$.name;
122 return (
123 <li key={fileName}>
124 <span>{fileName}</span>
125 <CoverageListing fileName={fileName}
126 sourceSet={this.props.sourceSet}
127 coverage={row.line} />
128 </li>
129 )
130 }
131
132 render() {
133 return renderRows(row => this._renderRow(row), this.props.packageSourceFiles, false);
134 }
135}