From 5d309ff52cd399a6b71968a6b9a70c8ac0b98981 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 5 Mar 2022 19:02:27 +0200 Subject: Added node_modules for the updating to work properly. --- .../istanbul-reports/lib/html-spa/src/index.js | 160 +++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 node_modules/istanbul-reports/lib/html-spa/src/index.js (limited to 'node_modules/istanbul-reports/lib/html-spa/src/index.js') diff --git a/node_modules/istanbul-reports/lib/html-spa/src/index.js b/node_modules/istanbul-reports/lib/html-spa/src/index.js new file mode 100644 index 0000000..c89c416 --- /dev/null +++ b/node_modules/istanbul-reports/lib/html-spa/src/index.js @@ -0,0 +1,160 @@ +// The index file for the spa running on the summary page +const React = require('react'); +const ReactDOM = require('react-dom'); +const SummaryTableHeader = require('./summaryTableHeader'); +const SummaryTableLine = require('./summaryTableLine'); +const SummaryHeader = require('./summaryHeader'); +const getChildData = require('./getChildData'); +const FlattenToggle = require('./flattenToggle'); +const FilterToggle = require('./filterToggle'); +const FileBreadcrumbs = require('./fileBreadcrumbs'); +const { setLocation, decodeLocation } = require('./routing'); + +const { useState, useMemo, useEffect } = React; + +const sourceData = window.data; +const metricsToShow = {}; +for (let i = 0; i < window.metricsToShow.length; i++) { + metricsToShow[window.metricsToShow[i]] = true; +} + +let firstMount = true; + +function App() { + const routingDefaults = decodeLocation(); + + const [activeSort, setSort] = useState( + (routingDefaults && routingDefaults.activeSort) || { + sortKey: 'file', + order: 'desc' + } + ); + const [isFlat, setIsFlat] = useState( + (routingDefaults && routingDefaults.isFlat) || false + ); + const [activeFilters, setFilters] = useState( + (routingDefaults && routingDefaults.activeFilters) || { + low: true, + medium: true, + high: true + } + ); + const [expandedLines, setExpandedLines] = useState( + (routingDefaults && routingDefaults.expandedLines) || [] + ); + const [fileFilter, setFileFilter] = useState( + (routingDefaults && routingDefaults.fileFilter) || '' + ); + const childData = useMemo( + () => + getChildData( + sourceData, + metricsToShow, + activeSort, + isFlat, + activeFilters, + fileFilter + ), + [activeSort, isFlat, activeFilters, fileFilter] + ); + const overallMetrics = sourceData.metrics; + + useEffect(() => { + setLocation( + firstMount, + activeSort, + isFlat, + activeFilters, + fileFilter, + expandedLines + ); + firstMount = false; + }, [activeSort, isFlat, activeFilters, fileFilter, expandedLines]); + + useEffect(() => { + window.onpopstate = () => { + const routingState = decodeLocation(); + if (routingState) { + // make sure all the state is set before rendering to avoid url updates + // alternative is to merge all the states into one so it can be set in one go + // https://github.com/facebook/react/issues/14259 + ReactDOM.unstable_batchedUpdates(() => { + setFilters(routingState.activeFilters); + setSort(routingState.activeSort); + setIsFlat(routingState.isFlat); + setExpandedLines(routingState.expandedLines); + setFileFilter(routingState.fileFilter); + }); + } + }; + }, []); + + return ( +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+

+ +

+
+
+ + { + setSort(newSort); + }} + activeSort={activeSort} + metricsToShow={metricsToShow} + /> + + {childData.map(child => ( + + ))} + +
+
+
+ Code coverage generated by{' '} + + istanbul + {' '} + at {window.generatedDatetime} +
+
+ ); +} + +ReactDOM.render(, document.getElementById('app')); -- cgit v1.2.3