Commit 5258a998 authored by Dave Pisek's avatar Dave Pisek

Vulnerability Modal: Fix issue with long URLs

This commit adds a fix that will make long URLs wrap if they exceed
the width of the Vulnerability Modal.

Changelog: fixed
EE: true
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73713
parent 2a3aa782
<script> <script>
import { GlLink } from '@gitlab/ui'; import { GlFriendlyWrap, GlLink } from '@gitlab/ui';
export default { export default {
components: { components: {
GlLink, GlLink,
GlFriendlyWrap,
}, },
inheritAttrs: false, inheritAttrs: false,
props: { props: {
...@@ -12,8 +13,11 @@ export default { ...@@ -12,8 +13,11 @@ export default {
required: true, required: true,
}, },
}, },
wrapSymbols: ['/', '?', '&', '='],
}; };
</script> </script>
<template> <template>
<gl-link :href="href">{{ href }}</gl-link> <gl-link :href="href">
<gl-friendly-wrap :text="href" :symbols="$options.wrapSymbols" />
</gl-link>
</template> </template>
...@@ -35,7 +35,12 @@ ...@@ -35,7 +35,12 @@
li { li {
@include gl-ml-0; @include gl-ml-0;
@include gl-mb-2;
@include gl-list-style-none; @include gl-list-style-none;
&:last-child {
@include gl-mb-0;
}
} }
&.generic-report-list-nested li { &.generic-report-list-nested li {
......
import { GlLink } from '@gitlab/ui'; import { GlFriendlyWrap, GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Url from 'ee/vulnerabilities/components/generic_report/types/url.vue'; import Url from 'ee/vulnerabilities/components/generic_report/types/url.vue';
...@@ -35,7 +35,8 @@ describe('ee/vulnerabilities/components/generic_report/types/url.vue', () => { ...@@ -35,7 +35,8 @@ describe('ee/vulnerabilities/components/generic_report/types/url.vue', () => {
expect(findLink().attributes('href')).toBe(TEST_DATA.href); expect(findLink().attributes('href')).toBe(TEST_DATA.href);
}); });
it('shows the href as the link-text', () => { it('shows the href as the link-text and makes it wrap if needed', () => {
expect(findLink().text()).toBe(TEST_DATA.href); // `GlFriendlyWrap` is a functional component, so we have to use `attributes` instead of `props`
expect(findLink().findComponent(GlFriendlyWrap).attributes('text')).toBe(TEST_DATA.href);
}); });
}); });
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