Follow-up from "Show dependency location count if `occurrenceCount` field is present"
The following discussion from !156557 (merged) should be addressed:
-
@dpisek started a discussion: (+1 comment) thought (non-blocking): This is related to the discussion yesterday - but does falling back to
0
actually make sense here?If there are no locations where the dependency was found, why is it on the report in the first place?
😅 As an alternative, we could check if
item.locationCount > 0
in the parent. This would prevent the location count from rendering when the count is a value that doesn't make sense🤔 diff --git a/ee/app/assets/javascripts/dependencies/components/dependencies_table.vue b/ee/app/assets/javascripts/dependencies/components/dependencies_table.vue index 5c1cbe908776..472f1ddeeda9 100644 --- a/ee/app/assets/javascripts/dependencies/components/dependencies_table.vue +++ b/ee/app/assets/javascripts/dependencies/components/dependencies_table.vue @@ -118,7 +118,7 @@ export default { })); }, displayLocationCount(item) { - return item.occurrenceCount !== undefined; + return item.occurrenceCount > 0; }, packager(dependency) { return dependency.packager || this.$options.i18n.unknown; diff --git a/ee/app/assets/javascripts/dependencies/components/dependency_location_count.vue b/ee/app/assets/javascripts/dependencies/components/dependency_location_count.vue index 201ec2f32a96..9d47b9092ff1 100644 --- a/ee/app/assets/javascripts/dependencies/components/dependency_location_count.vue +++ b/ee/app/assets/javascripts/dependencies/components/dependency_location_count.vue @@ -41,7 +41,7 @@ export default { }, computed: { locationText() { - const locationCount = this.locationCount || 0; + const { locationCount } = this; return sprintf( n__( 'Dependencies|%{locationCount} location',
I know, this is existing behaviour, so I am also open to leave as-is, or tackle it in a follow-up. In theory this should not happen, but since we do add a fallback already, I thought I bring it up
👍