Skip to content

Commit

Permalink
Merge pull request #810 from setchy/feat/project-policy-violations-ba…
Browse files Browse the repository at this point in the history
…dges

feat: dynamic policy violation badges based on show suppressed flag
  • Loading branch information
nscuro authored Aug 16, 2024
2 parents 2744e3b + 4e7b8dc commit fe3e40c
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
71 changes: 56 additions & 15 deletions src/views/portfolio/projects/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -309,31 +309,47 @@
variant="tab-total"
v-b-tooltip.hover
:title="$t('policy_violation.total')"
>{{ totalViolations }}</b-badge
>{{
showSuppressedViolations
? policyViolationsTotal
: policyViolationsUnaudited
}}</b-badge
>
<b-badge
variant="tab-info"
v-b-tooltip.hover
:title="$t('policy_violation.infos')"
>{{ infoViolations }}</b-badge
>{{
showSuppressedViolations
? policyViolationsInfoTotal
: policyViolationsInfoUnaudited
}}</b-badge
>
<b-badge
variant="tab-warn"
v-b-tooltip.hover
:title="$t('policy_violation.warns')"
>{{ warnViolations }}</b-badge
>{{
showSuppressedViolations
? policyViolationsWarnTotal
: policyViolationsWarnUnaudited
}}</b-badge
>
<b-badge
variant="tab-fail"
v-b-tooltip.hover
:title="$t('policy_violation.fails')"
>{{ failViolations }}</b-badge
>{{
showSuppressedViolations
? policyViolationsFailTotal
: policyViolationsFailUnaudited
}}</b-badge
>
</template>
<project-policy-violations
:key="this.uuid"
:uuid="this.uuid"
v-on:total="totalViolations = $event"
v-on:showSuppressedViolations="showSuppressedViolations = $event"
/>
</b-tab>
</b-tabs>
Expand Down Expand Up @@ -428,10 +444,15 @@ export default {
totalFindings: 0,
totalFindingsIncludingAliases: 0,
totalEpss: 0,
totalViolations: 0,
infoViolations: 0,
warnViolations: 0,
failViolations: 0,
showSuppressedViolations: false,
policyViolationsTotal: 0,
policyViolationsUnaudited: 0,
policyViolationsFailTotal: 0,
policyViolationsFailUnaudited: 0,
policyViolationsWarnTotal: 0,
policyViolationsWarnUnaudited: 0,
policyViolationsInfoTotal: 0,
policyViolationsInfoUnaudited: 0,
tabIndex: 0,
};
},
Expand Down Expand Up @@ -486,16 +507,36 @@ export default {
this.project.metrics.findingsTotal,
0,
);
this.infoViolations = common.valueWithDefault(
this.project.metrics.policyViolationsInfo,
this.policyViolationsTotal = common.valueWithDefault(
this.project.metrics.policyViolationsTotal,
0,
);
this.warnViolations = common.valueWithDefault(
this.project.metrics.policyViolationsWarn,
this.policyViolationsUnaudited = common.valueWithDefault(
this.project.metrics.policyViolationsUnaudited,
0,
);
this.failViolations = common.valueWithDefault(
this.project.metrics.policyViolationsFail,
this.policyViolationsFailTotal = common.valueWithDefault(
this.project.metrics.policyViolationsFailTotal,
0,
);
this.policyViolationsFailUnaudited = common.valueWithDefault(
this.project.metrics.policyViolationsFailUnaudited,
0,
);
this.policyViolationsWarnTotal = common.valueWithDefault(
this.project.metrics.policyViolationsWarnTotal,
0,
);
this.policyViolationsWarnUnaudited = common.valueWithDefault(
this.project.metrics.policyViolationsWarnUnaudited,
0,
);
this.policyViolationsInfoTotal = common.valueWithDefault(
this.project.metrics.policyViolationsInfoTotal,
0,
);
this.policyViolationsInfoUnaudited = common.valueWithDefault(
this.project.metrics.policyViolationsInfoUnaudited,
0,
);
EventBus.$emit('addCrumb', this.projectLabel);
Expand Down
1 change: 1 addition & 0 deletions src/views/portfolio/projects/ProjectPolicyViolations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ export default {
this.$refs.table.columns,
);
this.$emit('total', data.total);
this.$emit('showSuppressedViolations', this.showSuppressedViolations);
},
initializeTooltips: function () {
$('[data-toggle="tooltip"]').tooltip({
Expand Down

0 comments on commit fe3e40c

Please sign in to comment.