aboutsummaryrefslogtreecommitdiff
path: root/node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
committerJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
commit5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch)
tree360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js
parentb500a50f1b97d93c98b36ed9a980f8188d648147 (diff)
downloadLYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz
LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js')
-rw-r--r--node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js130
1 files changed, 130 insertions, 0 deletions
diff --git a/node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js b/node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js
new file mode 100644
index 0000000..7cf964e
--- /dev/null
+++ b/node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js
@@ -0,0 +1,130 @@
+const React = require('react');
+
+function getSortDetails(sortKey, activeSort) {
+ let newSort = { sortKey, order: 'desc' };
+ let sortClass = '';
+ if (activeSort && activeSort.sortKey === sortKey) {
+ sortClass = 'sorted';
+ if (activeSort.order === 'desc') {
+ sortClass += '-desc';
+ newSort.order = 'asc';
+ } else {
+ if (sortKey !== 'file') {
+ newSort = { sortKey: 'file', order: 'desc' };
+ }
+ }
+ }
+
+ return {
+ newSort,
+ sortClass
+ };
+}
+
+function SummaryTableHeaderCell({ name, onSort, sortKey, activeSort }) {
+ const { newSort, sortClass } = getSortDetails(sortKey, activeSort);
+ return (
+ <th
+ className={'sortable headercell ' + sortClass}
+ onClick={() => onSort(newSort)}
+ >
+ {name}
+ <span className="sorter" />
+ </th>
+ );
+}
+
+function FileHeaderCell({ onSort, activeSort }) {
+ const { newSort, sortClass } = getSortDetails('file', activeSort);
+
+ return (
+ <th
+ className={'sortable file ' + sortClass}
+ onClick={() => onSort(newSort)}
+ >
+ File
+ <span className="sorter" />
+ </th>
+ );
+}
+
+function SubHeadings({ sortKeyPrefix, onSort, activeSort }) {
+ return (
+ <>
+ <SummaryTableHeaderCell
+ name="%"
+ onSort={onSort}
+ sortKey={sortKeyPrefix + '.pct'}
+ activeSort={activeSort}
+ />
+ <th className="headercell"></th>
+ <SummaryTableHeaderCell
+ name="Covered"
+ onSort={onSort}
+ sortKey={sortKeyPrefix + '.covered'}
+ activeSort={activeSort}
+ />
+ <SummaryTableHeaderCell
+ name="Missed"
+ onSort={onSort}
+ sortKey={sortKeyPrefix + '.missed'}
+ activeSort={activeSort}
+ />
+ <SummaryTableHeaderCell
+ name="Total"
+ onSort={onSort}
+ sortKey={sortKeyPrefix + '.total'}
+ activeSort={activeSort}
+ />
+ </>
+ );
+}
+
+module.exports = function SummaryTableHeader({
+ onSort,
+ activeSort,
+ metricsToShow
+}) {
+ return (
+ <thead>
+ <tr className="topheading">
+ <th></th>
+ {metricsToShow.statements && <th colSpan={4}>Statements</th>}
+ {metricsToShow.branches && <th colSpan={4}>Branches</th>}
+ {metricsToShow.functions && <th colSpan={4}>Functions</th>}
+ {metricsToShow.lines && <th colSpan={4}>Lines</th>}
+ </tr>
+ <tr className="subheading">
+ <FileHeaderCell onSort={onSort} activeSort={activeSort} />
+ {metricsToShow.statements && (
+ <SubHeadings
+ sortKeyPrefix="statements"
+ onSort={onSort}
+ activeSort={activeSort}
+ />
+ )}
+ {metricsToShow.branches && (
+ <SubHeadings
+ sortKeyPrefix="branches"
+ onSort={onSort}
+ activeSort={activeSort}
+ />
+ )}
+ {metricsToShow.functions && (
+ <SubHeadings
+ sortKeyPrefix="functions"
+ onSort={onSort}
+ activeSort={activeSort}
+ />
+ )}
+ {metricsToShow.lines && (
+ <SubHeadings
+ sortKeyPrefix="lines"
+ onSort={onSort}
+ activeSort={activeSort}
+ />
+ )}
+ </tr>
+ </thead>
+ );
+};