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 (
onSort(newSort)}
>
{name}
|
);
}
function FileHeaderCell({ onSort, activeSort }) {
const { newSort, sortClass } = getSortDetails('file', activeSort);
return (
onSort(newSort)}
>
File
|
);
}
function SubHeadings({ sortKeyPrefix, onSort, activeSort }) {
return (
<>
|
>
);
}
module.exports = function SummaryTableHeader({
onSort,
activeSort,
metricsToShow
}) {
return (
|
{metricsToShow.statements && Statements | }
{metricsToShow.branches && Branches | }
{metricsToShow.functions && Functions | }
{metricsToShow.lines && Lines | }
{metricsToShow.statements && (
)}
{metricsToShow.branches && (
)}
{metricsToShow.functions && (
)}
{metricsToShow.lines && (
)}
);
};