Skip to content

Commit 9c4a3b9

Browse files
authored
Merge pull request #723 from setchy/feature/vulnerabilities-active-inactive-toggle
feat(vulnerabilities): support active/inactive affected projects
2 parents 4b9d3e7 + 4707694 commit 9c4a3b9

File tree

2 files changed

+62
-3
lines changed

2 files changed

+62
-3
lines changed

src/views/portfolio/vulnerabilities/AffectedProjects.vue

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,45 @@
11
<template>
2+
<div>
3+
<div id="projectsToolbar" class="bs-table-custom-toolbar">
4+
<c-switch style="margin-left:1rem; margin-right:.5rem" id="showInactiveProjects" color="primary" v-model="showInactiveProjects" label v-bind="labelIcon" /><span class="text-muted">{{ $t('message.show_inactive_projects') }}</span>
5+
</div>
26
<bootstrap-table
37
ref="table"
48
:columns="columns"
59
:data="data"
610
:options="options"
7-
@on-load-success="tableLoaded">
11+
@on-load-success="tableLoaded"
12+
@on-post-body="onPostBody">
813
</bootstrap-table>
14+
</div>
915
</template>
1016

1117
<script>
1218
import xssFilters from "xss-filters";
1319
import permissionsMixin from "../../../mixins/permissionsMixin";
20+
import { Switch as cSwitch } from '@coreui/vue';
21+
1422
1523
export default {
1624
mixins: [permissionsMixin],
25+
components: {
26+
cSwitch
27+
},
28+
beforeCreate() {
29+
this.showInactiveProjects = (localStorage && localStorage.getItem("AffectedProjectListShowInactiveProjects") !== null) ? (localStorage.getItem("AffectedProjectListShowInactiveProjects") === "true") : false;
30+
},
1731
props: {
1832
source: String,
1933
vulnId: String,
2034
vulnerability: String
2135
},
2236
data() {
2337
return {
38+
showInactiveProjects: this.showInactiveProjects,
39+
labelIcon: {
40+
dataOn: '\u2713',
41+
dataOff: '\u2715'
42+
},
2443
columns: [
2544
{
2645
title: this.$t('message.name'),
@@ -45,6 +64,15 @@
4564
title: this.$t('message.version'),
4665
field: "version",
4766
sortable: true,
67+
},
68+
{
69+
title: this.$t('message.active'),
70+
field: "active",
71+
formatter(value) {
72+
return value === true ? '<i class="fa fa-check-square-o" />' : "";
73+
},
74+
align: "center",
75+
sortable: true
4876
}
4977
],
5078
data: [],
@@ -58,17 +86,47 @@
5886
queryParamsType: 'pageSize',
5987
pageList: '[10, 25, 50, 100]',
6088
pageSize: 10,
89+
toolbar: '#projectsToolbar',
6190
icons: {
6291
refresh: 'fa-refresh'
6392
},
64-
url: `${this.$api.BASE_URL}/${this.$api.URL_VULNERABILITY}/source/${this.source}/vuln/${this.vulnId}/projects`
93+
url: this.apiUrl()
6594
}
6695
};
6796
},
6897
methods: {
98+
apiUrl: function () {
99+
let url = `${this.$api.BASE_URL}/${this.$api.URL_VULNERABILITY}/source/${this.source}/vuln/${this.vulnId}/projects`;
100+
if (this.showInactiveProjects === undefined) {
101+
url += "?excludeInactive=true";
102+
} else {
103+
url += "?excludeInactive=" + !this.showInactiveProjects;
104+
}
105+
return url;
106+
},
69107
tableLoaded: function(array) {
70108
this.$emit('total', array.length);
109+
},
110+
refreshTable: function () {
111+
this.$refs.table.refresh({
112+
url: this.apiUrl(),
113+
silent: true,
114+
pageNumber: 1
115+
});
116+
},
117+
onPostBody: function () {
118+
this.$refs.table.hideLoading();
71119
}
120+
},
121+
watch: {
122+
showInactiveProjects() {
123+
if (localStorage) {
124+
localStorage.setItem("AffectedProjectListShowInactiveProjects", this.showInactiveProjects.toString());
125+
}
126+
this.$refs.table.showLoading();
127+
this.currentPage = 1;
128+
this.refreshTable();
129+
},
72130
}
73131
};
74132
</script>

src/views/portfolio/vulnerabilities/VulnerabilityList.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import VulnerabilityCreateVulnerabilityModal from "./VulnerabilityCreateVulnerab
5353
},
5454
data() {
5555
return {
56+
showInactiveProjects: this.showInactiveProjects,
5657
columns: [
5758
{
5859
title: this.$t('message.name'),
@@ -111,7 +112,7 @@ import VulnerabilityCreateVulnerabilityModal from "./VulnerabilityCreateVulnerab
111112
},
112113
{
113114
title: this.$t('message.projects'),
114-
field: "affectedProjectCount",
115+
field: "affectedActiveProjectCount",
115116
class: "tight",
116117
sortable: false
117118
},

0 commit comments

Comments
 (0)