Skip to content

Commit

Permalink
Merge pull request #1883 from IBMa/joho-HiddenCount-1882
Browse files Browse the repository at this point in the history
fix(extension): adjust hidden counts
  • Loading branch information
ErickRenteria authored Apr 11, 2024
2 parents 1b8bdaf + 4419955 commit 3253831
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { UtilIssue } from '../../util/UtilIssue';
import { UtilIssueReact } from '../../util/UtilIssueReact';
import { getDevtoolsController, ScanningState, ViewState } from '../devtoolsController';
import { getTabId } from '../../util/tabId';
import { getBGController, TabChangeType } from '../../background/backgroundController';
import { getBGController, issueBaselineMatch, TabChangeType } from '../../background/backgroundController';
import {
Button,
Column,
Expand Down Expand Up @@ -252,6 +252,7 @@ export class ScanSection extends React.Component<{}, ScanSectionState> {

getCounts(issues: UIIssue[] | null) : CountType {
let counts = this.initCount();
if (!issues) return counts;
if (issues) {
for (const issue of issues) {
let sing = UtilIssue.valueToStringSingular(issue.value);
Expand All @@ -263,11 +264,11 @@ export class ScanSection extends React.Component<{}, ScanSectionState> {
}
if (this.state.ignoredIssues) {
for (const ignoredIssue of this.state.ignoredIssues) {
if (!issues.some(issue => issueBaselineMatch(issue, ignoredIssue))) continue;
++counts["Hidden" as eLevel].total;
if (!this.state.selectedPath || ignoredIssue.path.dom.startsWith(this.state.selectedPath)) {
++counts["Hidden" as eLevel].focused;
}
// remove from appropriate eLevel V, NR, R
let sing = UtilIssue.valueToStringSingular(ignoredIssue.value);
--counts[sing as eLevel].total;
if (!this.state.selectedPath || ignoredIssue.path.dom.startsWith(this.state.selectedPath)) {
Expand All @@ -283,12 +284,12 @@ export class ScanSection extends React.Component<{}, ScanSectionState> {
render() {
let reportIssues : IIssue[] | null = null;
let filterCounts: CountType = this.initCount();
let quickTotalCount = 0;
// let quickTotalCount = 0;
let totalCount = 0;
if (this.state.report) {
quickTotalCount = this.state.report.counts.Violation +
this.state.report.counts['Needs review'] +
this.state.report.counts.Recommendation - this.state.ignoredIssues.length;
// quickTotalCount = this.state.report.counts.Violation +
// this.state.report.counts['Needs review'] +
// this.state.report.counts.Recommendation - this.state.ignoredIssues.length;
reportIssues = this.state.report ? JSON.parse(JSON.stringify(this.state.report.results)) : null;
}
if (reportIssues) {
Expand All @@ -308,7 +309,6 @@ export class ScanSection extends React.Component<{}, ScanSectionState> {
totalCount += filterCounts[levelStr as eLevel].total;
{UtilIssueReact.valueSingToIcon(levelStr, "reportSecIcon")}
})}

let selectedElementStr = this.state.selectedElemPath;

if (selectedElementStr) {
Expand Down Expand Up @@ -456,7 +456,7 @@ export class ScanSection extends React.Component<{}, ScanSectionState> {

<div className={totalCount === 0 ? "totalCountDisable" : "totalCountEnable"} >
{["Violation", "Needs review", "Recommendation"].map((levelStr) => {
totalCount += filterCounts[levelStr as eLevel].total;
// totalCount += filterCounts[levelStr as eLevel].total;
return <>
<span className='scanFilterSection' data-tip style={{ display: "inline-block", verticalAlign: "middle", paddingTop: "4px" }}>
<span className="countCol">
Expand All @@ -483,7 +483,11 @@ export class ScanSection extends React.Component<{}, ScanSectionState> {
{UtilIssueReact.valueSingToIcon(BrowserDetection.isDarkMode()?"ViewOn":"ViewOff", "reportSecIcon")}</DefinitionTooltip>
<span className="reportSecCounts" style={{ marginLeft: "4px" }}>
{reportIssues && <>
{this.state.ignoredIssues.length}
{(filterCounts["Hidden"].focused === filterCounts["Hidden"].total) ?
filterCounts["Hidden"].total
: <>
{filterCounts["Hidden"].focused}/{filterCounts["Hidden"].total}
</>}
</>}
</span>
<span style={{ marginRight: "18px" }}></span>
Expand All @@ -499,7 +503,7 @@ export class ScanSection extends React.Component<{}, ScanSectionState> {
let appController = getDevtoolsAppController();
getDevtoolsAppController().setSecondaryView("summary");
appController.openSecondary("totalIssuesCount");
}}>{quickTotalCount} issues found</Link>
}}>{totalCount} issues found</Link>
</div>
</Column>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
limitations under the License.
*****************************************************************************/

import { getBGController, TabChangeType } from "../background/backgroundController";
import { IBasicTableRowRecord, IIssue, IMessage, IReport, IStoredReportMeta } from "../interfaces/interfaces";
import { getBGController, issueBaselineMatch, TabChangeType } from "../background/backgroundController";
import { IBasicTableRowRecord, IIssue, IMessage, IReport, IStoredReportMeta, UIIssue } from "../interfaces/interfaces";
import { CommonMessaging } from "../messaging/commonMessaging";
import { Controller, eControllerType, ListenerType } from "../messaging/controller";
import Config from "../util/config";
Expand Down Expand Up @@ -212,18 +212,20 @@ export class DevtoolsController extends Controller {
}
}

async getCountsWithHidden (reportCounts: IReport["counts"], ignored: IIssue[]) {
async getCountsWithHidden (reportCounts: IReport["counts"], issues:UIIssue[], ignored: IIssue[]) {
let counts = this.initCount(); // setup counts
// populate initial counts
counts.Violation = reportCounts.Violation;
counts["Needs review"] = reportCounts["Needs review"];
counts.Recommendation = reportCounts.Recommendation;
counts.Hidden = ignored.length;
counts.Hidden = 0;
counts.Pass = reportCounts.Pass;

// correct issue type counts to take into account the hidden issues
if (ignored.length > 0) { // if we have hidden
for (const ignoredIssue of ignored) {
if (!issues.some(issue => issueBaselineMatch(issue, ignoredIssue))) continue;
counts.Hidden++;
if ("Violation" === this.valueMap[ignoredIssue.value[0]][ignoredIssue.value[1]]) {
counts.Violation--;
}
Expand All @@ -250,7 +252,7 @@ export class DevtoolsController extends Controller {
let tabId = getTabId();
let tabInfo = await bgController.getTabInfo(tabId);
let ignored: IIssue[] = await bgController.getIgnore(tabInfo.url!);
let newCounts = await this.getCountsWithHidden(report.counts, ignored);
let newCounts = await this.getCountsWithHidden(report.counts, report.results, ignored);
const now = new Date().getTime();
devtoolsState!.lastReportMeta = {
id: devtoolsState!.storedReports.length+"",
Expand Down

0 comments on commit 3253831

Please sign in to comment.