Skip to content

Commit 7619019

Browse files
Added UI linking to query on project classifiers - DependencyTrack/dependency-track#1185
Signed-off-by: Steve Springett <[email protected]>
1 parent 0764f9f commit 7619019

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/shared/common.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
"use strict";
88

9+
const xssFilters = require("xss-filters");
910
const $common = function() {
1011
};
1112

@@ -213,6 +214,32 @@ $common.componentClassifierLabelFormatter = (i18n) => {
213214
}
214215
};
215216

217+
/**
218+
*
219+
* @param {*} i18n - VueI18n instance with $t translate function available
220+
* @returns a specialized label for component and project classifiers (APPLICATION, LIBRARY, etc).
221+
* It must have a corresponding entry in the locales files (e.g. src/locales/en.json)
222+
* (application, library, etc.)
223+
*/
224+
$common.componentClassifierLabelProjectUrlFormatter = (i18n) => {
225+
return function (value) {
226+
let url = "../projects/?classifier=" + value;
227+
switch (value) {
228+
case 'APPLICATION':
229+
case 'FRAMEWORK':
230+
case 'LIBRARY':
231+
case 'CONTAINER':
232+
case 'OPERATING_SYSTEM':
233+
case 'DEVICE':
234+
case 'FIRMWARE':
235+
case 'FILE':
236+
return `<a href="${url}">${i18n.$t(`message.component_${value.toLowerCase()}`)}</a>`
237+
default:
238+
return null;
239+
}
240+
}
241+
};
242+
216243
/**
217244
* Given a UNIX timestamp, this function will return a formatted date.
218245
* i.e. 15 Jan 2017
@@ -315,6 +342,7 @@ module.exports = {
315342
makeAnalysisStateLabelFormatter: $common.makeAnalysisStateLabelFormatter,
316343
makeAnalysisJustificationLabelFormatter: $common.makeAnalysisJustificationLabelFormatter,
317344
componentClassifierLabelFormatter: $common.componentClassifierLabelFormatter,
345+
componentClassifierLabelProjectUrlFormatter: $common.componentClassifierLabelProjectUrlFormatter,
318346
formatTimestamp: $common.formatTimestamp,
319347
concatenateComponentName: $common.concatenateComponentName,
320348
valueWithDefault: $common.valueWithDefault,

src/views/portfolio/projects/ProjectList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
title: this.$t('message.classifier'),
9898
field: "classifier",
9999
sortable: true,
100-
formatter: common.componentClassifierLabelFormatter(this),
100+
formatter: common.componentClassifierLabelProjectUrlFormatter(this),
101101
},
102102
{
103103
title: this.$t('message.last_bom_import'),

0 commit comments

Comments
 (0)