Commit 925847e4 authored by Jannik Lehmann's avatar Jannik Lehmann Committed by Vitaly Slobodin

Update DAST Modal Download Handling

This commit will remove the download button
from the Dast Modal and add the download
link to the Banner which is
advertising to Download the DAST-Report
parent ed6c5640
<script> <script>
import { GlModal, GlIcon, GlSprintf, GlTruncate } from '@gitlab/ui'; import { GlModal, GlIcon, GlSprintf, GlTruncate, GlLink } from '@gitlab/ui';
import { n__, __ } from '~/locale'; import { n__, __ } from '~/locale';
export default { export default {
components: { GlModal, GlIcon, GlSprintf, GlTruncate }, components: { GlModal, GlIcon, GlSprintf, GlTruncate, GlLink },
props: { props: {
scannedUrls: { scannedUrls: {
required: true, required: true,
...@@ -33,29 +33,11 @@ export default { ...@@ -33,29 +33,11 @@ export default {
// show only 15 scanned urls // show only 15 scanned urls
return this.scannedUrls.slice(0, 15); return this.scannedUrls.slice(0, 15);
}, },
downloadButton() {
const buttonAttrs = {
text: __('Download as CSV'),
attributes: {
variant: 'success',
class: 'gl-button btn-success-secondary',
href: this.downloadLink,
download: '',
'data-testid': 'download-button',
},
};
return this.downloadLink ? buttonAttrs : null;
},
}, },
}; };
</script> </script>
<template> <template>
<gl-modal <gl-modal :title="title" title-tag="h5" v-bind="$options.modal">
:title="title"
title-tag="h5"
v-bind="$options.modal"
:action-secondary="downloadButton"
>
<!-- heading --> <!-- heading -->
<div class="row gl-text-gray-400"> <div class="row gl-text-gray-400">
<div class="col-1">{{ __('Method') }}</div> <div class="col-1">{{ __('Method') }}</div>
...@@ -80,9 +62,16 @@ export default { ...@@ -80,9 +62,16 @@ export default {
<b class="gl-vertical-align-middle"> <b class="gl-vertical-align-middle">
<gl-sprintf <gl-sprintf
:message=" :message="
__('To view all %{scannedResourcesCount} scanned URLs, please download the CSV file') __(
'To view all %{scannedResourcesCount} scanned URLs, %{linkStart}please download the CSV file%{linkEnd}',
)
" "
> >
<template #link="{ content }">
<gl-link download :href="downloadLink" data-testid="download-link">
{{ content }}
</gl-link>
</template>
<template #scannedResourcesCount> <template #scannedResourcesCount>
{{ scannedResourcesCount }} {{ scannedResourcesCount }}
</template> </template>
......
---
title: Enhance User-Experience on Dast-report Download Button
merge_request: 46681
author:
type: changed
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Component from 'ee/vue_shared/security_reports/components/dast_modal.vue'; import Component from 'ee/vue_shared/security_reports/components/dast_modal.vue';
import { GlModal } from '@gitlab/ui'; import { GlModal, GlSprintf } from '@gitlab/ui';
describe('DAST Modal', () => { describe('DAST Modal', () => {
let wrapper; let wrapper;
...@@ -11,7 +11,7 @@ describe('DAST Modal', () => { ...@@ -11,7 +11,7 @@ describe('DAST Modal', () => {
downloadLink: 'https://gitlab.com', downloadLink: 'https://gitlab.com',
}; };
const findDownloadButton = () => wrapper.find('[data-testid="download-button"]'); const findDownloadLink = () => wrapper.find('[data-testid="download-link"]');
const createWrapper = propsData => { const createWrapper = propsData => {
wrapper = shallowMount(Component, { wrapper = shallowMount(Component, {
...@@ -21,6 +21,7 @@ describe('DAST Modal', () => { ...@@ -21,6 +21,7 @@ describe('DAST Modal', () => {
}, },
stubs: { stubs: {
GlModal, GlModal,
GlSprintf,
}, },
}); });
}; };
...@@ -34,9 +35,12 @@ describe('DAST Modal', () => { ...@@ -34,9 +35,12 @@ describe('DAST Modal', () => {
}); });
it('has the download button with required attrs', () => { it('has the download button with required attrs', () => {
expect(findDownloadButton().exists()).toBe(true); const downloadLink = findDownloadLink();
expect(findDownloadButton().attributes('href')).toBe(defaultProps.downloadLink);
expect(findDownloadButton().attributes('download')).toBeDefined(); expect(downloadLink.attributes()).toMatchObject({
href: defaultProps.downloadLink,
download: expect.anything(),
});
}); });
it('should contain the dynamic title', () => { it('should contain the dynamic title', () => {
...@@ -46,7 +50,7 @@ describe('DAST Modal', () => { ...@@ -46,7 +50,7 @@ describe('DAST Modal', () => {
it('should not show download button when link is not present', () => { it('should not show download button when link is not present', () => {
createWrapper({ downloadLink: '' }); createWrapper({ downloadLink: '' });
expect(findDownloadButton().exists()).toBe(false); expect(findDownloadLink().exists()).toBe(false);
}); });
it('scanned urls should be limited to 15', () => { it('scanned urls should be limited to 15', () => {
......
...@@ -9709,9 +9709,6 @@ msgstr "" ...@@ -9709,9 +9709,6 @@ msgstr ""
msgid "Download as" msgid "Download as"
msgstr "" msgstr ""
msgid "Download as CSV"
msgstr ""
msgid "Download codes" msgid "Download codes"
msgstr "" msgstr ""
...@@ -28270,7 +28267,7 @@ msgstr "" ...@@ -28270,7 +28267,7 @@ msgstr ""
msgid "To use Gitpod you must first enable the feature in the integrations section of your %{user_prefs}." msgid "To use Gitpod you must first enable the feature in the integrations section of your %{user_prefs}."
msgstr "" msgstr ""
msgid "To view all %{scannedResourcesCount} scanned URLs, please download the CSV file" msgid "To view all %{scannedResourcesCount} scanned URLs, %{linkStart}please download the CSV file%{linkEnd}"
msgstr "" msgstr ""
msgid "To view instance-level analytics, ask an admin to turn on %{docLinkStart}usage ping%{docLinkEnd}." msgid "To view instance-level analytics, ask an admin to turn on %{docLinkStart}usage ping%{docLinkEnd}."
......
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