Skip to content

Commit 8022f26

Browse files
author
mbrill-nt
committed
Improved Code Style of Statistics.tsx.
1 parent 87f62c1 commit 8022f26

File tree

1 file changed

+24
-35
lines changed

1 file changed

+24
-35
lines changed

src/panel/statistics/Statistics.tsx

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,24 @@ export const Statistics: React.FC<StatisticsProps> = ({
3939
);
4040
}
4141

42-
var requests = <div></div>;
43-
if (selectionStatistics.requests >= 0) {
44-
requests = (
42+
const requests =
43+
selectionStatistics.requests >= 0 ? (
4544
<tr>
4645
<td className="table--td--selection">Requests</td>
4746
<td className="table--td--selection">{selectionStatistics.requests}</td>
4847
</tr>
49-
);
50-
}
48+
) : null;
5149

52-
var errors = <div></div>;
53-
if (selectionStatistics.errors >= 0) {
54-
errors = (
50+
const errors =
51+
selectionStatistics.errors >= 0 ? (
5552
<tr>
5653
<td className="table--td--selection">Errors</td>
5754
<td className="table--td--selection">{selectionStatistics.errors}</td>
5855
</tr>
59-
);
60-
}
56+
) : null;
6157

62-
var errorRate = <div></div>;
63-
if (selectionStatistics.requests >= 0 && selectionStatistics.errors >= 0) {
64-
errorRate = (
58+
var errorRate =
59+
selectionStatistics.requests >= 0 && selectionStatistics.errors >= 0 ? (
6560
<tr ng-show="">
6661
<td className="table--td--selection">Error Rate</td>
6762
<td className="table--td--selection">
@@ -71,38 +66,32 @@ export const Statistics: React.FC<StatisticsProps> = ({
7166
)}
7267
</td>
7368
</tr>
74-
);
75-
}
69+
) : null;
7670

77-
var avgResponseTime = <div></div>;
78-
if (selectionStatistics.responseTime >= 0) {
79-
avgResponseTime = (
71+
var avgResponseTime =
72+
selectionStatistics.responseTime >= 0 ? (
8073
<tr>
8174
<td className="table--td--selection">Avg. Response Time</td>
8275
<td className="table--td--selection">{selectionStatistics.responseTime} ms</td>
8376
</tr>
84-
);
85-
}
77+
) : null;
8678

87-
var baseline = <div></div>;
88-
if (showBaselines && selectionStatistics.threshold) {
89-
var threshold = (
90-
<td className="table--td--selection threshold--good">Good "(&lt;= {selectionStatistics.threshold}ms)"</td>
91-
);
92-
if (selectionStatistics.thresholdViolation) {
93-
threshold = (
94-
<td className="table--td--selection threshold--bad">
95-
Bad ({'>'} {selectionStatistics.threshold}ms)
96-
</td>
97-
);
98-
}
99-
baseline = (
79+
var threshold = selectionStatistics.thresholdViolation ? (
80+
<td className="table--td--selection threshold--bad">
81+
Bad ({'>'} {selectionStatistics.threshold}ms)
82+
</td>
83+
) : (
84+
<td className="table--td--selection threshold--good"> Good "(&lt;= {selectionStatistics.threshold}ms)" </td>
85+
);
86+
87+
var baseline =
88+
showBaselines && selectionStatistics.threshold ? (
10089
<tr>
10190
<td className="table--td--selection">Response Time Health (Upper Baseline)</td>
10291
{threshold}
10392
</tr>
104-
);
105-
}
93+
) : null;
94+
10695
statistics = (
10796
<div className="statistics">
10897
<div className="header--selection">

0 commit comments

Comments
 (0)