diff --git a/web/server/vue-cli/src/views/Reports.vue b/web/server/vue-cli/src/views/Reports.vue index c1af76a516..786938e2d0 100644 --- a/web/server/vue-cli/src/views/Reports.vue +++ b/web/server/vue-cli/src/views/Reports.vue @@ -249,24 +249,64 @@ class="tree-item-label clickable" @click.stop="onTreeItemClick(item)" >{{ item.name }} - {{ item.findings }} - {{ item.stats.style || '' }} - {{ item.stats.low || '' }} - {{ item.stats.medium || '' }} - {{ item.stats.high || '' }} - + {{ item.findings }} + {{ item.stats.style || '' }} + {{ item.stats.low || '' }} + {{ item.stats.medium || '' }} + {{ item.stats.high || '' }} + {{ item.stats.critical || '' }} - + {{ item.stats.unreviewed || '' }} - + {{ item.stats.confirmed || '' }} - + {{ item.stats.false_positive || '' }} - + {{ item.stats.intentional || '' }} @@ -287,6 +327,7 @@ import { ccService, handleThriftError } from "@cc-api"; import { Checker, Order, + ReviewStatus, Severity, SortMode, SortType @@ -533,10 +574,44 @@ function setReportFilter(params) { store.commit(`${namespace}/${SET_REPORT_FILTER}`, params); } -function onTreeItemClick(item) { +const SEVERITY_STAT_KEYS = { + style: Severity.STYLE, + low: Severity.LOW, + medium: Severity.MEDIUM, + high: Severity.HIGH, + critical: Severity.CRITICAL +}; + +const REVIEW_STATUS_STAT_KEYS = { + unreviewed: ReviewStatus.UNREVIEWED, + confirmed: ReviewStatus.CONFIRMED, + false_positive: ReviewStatus.FALSE_POSITIVE, + intentional: ReviewStatus.INTENTIONAL +}; + +function getTreeItemFilePattern(item) { const isDir = item.children && item.children.length > 0; - const pattern = isDir ? item.fullPath + "/*" : item.fullPath; - setReportFilter({ filepath: [ pattern ] }); + return isDir ? item.fullPath + "/*" : item.fullPath; +} + +function onTreeItemClick(item) { + setReportFilter({ filepath: [ getTreeItemFilePattern(item) ] }); + viewMode.value = "table"; +} + +function onTreeStatClick(item, statKey) { + const count = statKey === "all" ? item.findings : item.stats[statKey]; + if (!count) return; + + const params = { filepath: [ getTreeItemFilePattern(item) ] }; + + if (statKey in SEVERITY_STAT_KEYS) { + params.severity = [ SEVERITY_STAT_KEYS[statKey] ]; + } else if (statKey in REVIEW_STATUS_STAT_KEYS) { + params.reviewStatus = [ REVIEW_STATUS_STAT_KEYS[statKey] ]; + } + + setReportFilter(params); viewMode.value = "table"; } @@ -898,6 +973,15 @@ body { text-align: center; flex-shrink: 0; font-size: 0.8em; + + &.clickable { + cursor: pointer; + + &:hover { + text-decoration: underline; + color: rgb(var(--v-theme-primary)); + } + } } .v-data-table {