Commit 1dfa821d authored by Fernando's avatar Fernando

Handle .Net license scan results

* In the license compliance UI gracefully handle when the
.Net scanner returns URLs for license names

Add changelog

* Add entry for .Net License scan results UI fix

Change toContain to toBe in license compliance spec

* Update test assertion
parent 907466b6
<script> <script>
import { GlLink, GlSkeletonLoading, GlBadge, GlIcon } from '@gitlab/ui'; import { GlLink, GlSkeletonLoading, GlBadge, GlIcon, GlFriendlyWrap } from '@gitlab/ui';
import LicenseComponentLinks from './license_component_links.vue'; import LicenseComponentLinks from './license_component_links.vue';
import { LICENSE_APPROVAL_CLASSIFICATION } from 'ee/vue_shared/license_compliance/constants'; import { LICENSE_APPROVAL_CLASSIFICATION } from 'ee/vue_shared/license_compliance/constants';
...@@ -11,6 +11,7 @@ export default { ...@@ -11,6 +11,7 @@ export default {
GlSkeletonLoading, GlSkeletonLoading,
GlBadge, GlBadge,
GlIcon, GlIcon,
GlFriendlyWrap,
}, },
props: { props: {
license: { license: {
...@@ -28,6 +29,9 @@ export default { ...@@ -28,6 +29,9 @@ export default {
isDenied() { isDenied() {
return this.license.classification === LICENSE_APPROVAL_CLASSIFICATION.DENIED; return this.license.classification === LICENSE_APPROVAL_CLASSIFICATION.DENIED;
}, },
nameIsLink() {
return this.license.name.includes('http');
},
}, },
}; };
</script> </script>
...@@ -54,7 +58,14 @@ export default { ...@@ -54,7 +58,14 @@ export default {
<gl-link v-if="license.url" :href="license.url" target="_blank">{{ <gl-link v-if="license.url" :href="license.url" target="_blank">{{
license.name license.name
}}</gl-link> }}</gl-link>
<template v-else>{{ license.name }}</template>
<gl-link v-else-if="nameIsLink" :href="license.name" target="blank">
<gl-friendly-wrap :text="license.name" />
</gl-link>
<template v-else>
{{ license.name }}
</template>
</div> </div>
</div> </div>
......
---
title: Show .Net license scan results as links
merge_request: 31552
author:
type: fixed
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlLink, GlSkeletonLoading, GlBadge } from '@gitlab/ui'; import { GlLink, GlSkeletonLoading, GlBadge, GlFriendlyWrap } from '@gitlab/ui';
import LicenseComponentLinks from 'ee/license_compliance/components/license_component_links.vue'; import LicenseComponentLinks from 'ee/license_compliance/components/license_component_links.vue';
import LicensesTableRow from 'ee/license_compliance/components/licenses_table_row.vue'; import LicensesTableRow from 'ee/license_compliance/components/licenses_table_row.vue';
import { makeLicense } from './utils'; import { makeLicense } from './utils';
...@@ -81,6 +81,26 @@ describe('LicensesTableRow component', () => { ...@@ -81,6 +81,26 @@ describe('LicensesTableRow component', () => {
}); });
}); });
describe('when a license has a url in name field', () => {
beforeEach(() => {
license.url = null;
license.name = 'https://github.com/dotnet/corefx/blob/master/LICENSE.TXT';
factory({
isLoading: false,
license,
});
});
it('renders the GlFriendlyWrap and GlLink components', () => {
const nameSection = findNameSeciton();
expect(nameSection.find(GlLink).exists()).toBe(true);
expect(nameSection.find(GlFriendlyWrap).exists()).toBe(true);
expect(nameSection.find(GlFriendlyWrap).props().text).toBe(license.name);
});
});
describe('with a license without a url', () => { describe('with a license without a url', () => {
beforeEach(() => { beforeEach(() => {
license.url = null; license.url = null;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment