Skip to content

Commit 64382c5

Browse files
Moved component contatination to common
1 parent 2bb97c4 commit 64382c5

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/shared/common.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ $common.formatTimestamp = function formatTimestamp(timestamp, includeTime) {
130130
}
131131
};
132132

133+
/*
134+
* Concatenates the group, name, and version of a component.
135+
*/
136+
$common.concatenateComponentName = function concatenateComponentName(group, name, version) {
137+
let g = $common.trimToNull(group);
138+
let n = $common.trimToNull(name);
139+
let v = $common.trimToNull(version);
140+
return (g != null? g + " " : "") + (n != null? n : "") + (v != null? " " + v: "");
141+
}
142+
133143
/**
134144
* Helper function that returns the variable if it is not null, undefined, NaN,
135145
* an empty string (""), 0, or false. Otherwise, returns the default value.
@@ -205,6 +215,7 @@ module.exports = {
205215
formatCweLabel: $common.formatCweLabel,
206216
formatAnalyzerLabel: $common.formatAnalyzerLabel,
207217
formatTimestamp: $common.formatTimestamp,
218+
concatenateComponentName: $common.concatenateComponentName,
208219
valueWithDefault: $common.valueWithDefault,
209220
calcProgressPercent: $common.calcProgressPercent,
210221
sleep: $common.sleep,

src/views/portfolio/projects/ProjectPolicyViolations.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ export default {
7777
sortable: true,
7878
formatter(value, row, index) {
7979
let url = xssFilters.uriInUnQuotedAttr("../components/" + row.component.uuid);
80-
let versionString = "";
81-
if (row.component.version) {
82-
versionString = " " + row.component.version;
83-
}
84-
return `<a href="${url}">${xssFilters.inHTMLData(value + versionString)}</a>`;
80+
let name = common.concatenateComponentName(null, row.component.name, row.component.version);
81+
return `<a href="${url}">${xssFilters.inHTMLData(name)}</a>`;
8582
}
8683
},
8784
{

0 commit comments

Comments
 (0)