Commit 5b05d3c2 authored by David O'Regan's avatar David O'Regan

Merge branch '353429-migrate-hidden-files-warning' into 'master'

Make hidden files warning use GlAlert

See merge request gitlab-org/gitlab!82635
parents b7985e90 02d0234e
<script> <script>
/* eslint-disable @gitlab/vue-require-i18n-strings */ import { GlAlert, GlSprintf } from '@gitlab/ui';
import { __ } from '~/locale';
export const i18n = {
title: __('Too many changes to show.'),
plainDiff: __('Plain diff'),
emailPatch: __('Email patch'),
};
export default { export default {
i18n,
components: {
GlAlert,
GlSprintf,
},
props: { props: {
total: { total: {
type: String, type: String,
...@@ -23,17 +36,28 @@ export default { ...@@ -23,17 +36,28 @@ export default {
</script> </script>
<template> <template>
<div class="alert alert-warning"> <gl-alert
<h4> variant="warning"
{{ __('Too many changes to show.') }} :title="$options.i18n.title"
<div class="float-right"> :primary-button-text="$options.i18n.plainDiff"
<a :href="plainDiffPath" class="btn btn-sm"> {{ __('Plain diff') }} </a> :primary-button-link="plainDiffPath"
<a :href="emailPatchPath" class="btn btn-sm"> {{ __('Email patch') }} </a> :secondary-button-text="$options.i18n.emailPatch"
</div> :secondary-button-link="emailPatchPath"
</h4> :dismissible="false"
<p> >
To preserve performance only <strong> {{ visible }} of {{ total }} </strong> files are <gl-sprintf
displayed. :message="
</p> sprintf(
</div> __(
'To preserve performance only %{strongStart}%{visible} of %{total}%{strongEnd} files are displayed.',
),
{ visible, total },
)
"
>
<template #strong="{ content }">
<strong>{{ content }}</strong>
</template>
</gl-sprintf>
</gl-alert>
</template> </template>
...@@ -38768,6 +38768,9 @@ msgstr "" ...@@ -38768,6 +38768,9 @@ msgstr ""
msgid "To personalize your GitLab experience, we'd like to know a bit more about you" msgid "To personalize your GitLab experience, we'd like to know a bit more about you"
msgstr "" msgstr ""
msgid "To preserve performance only %{strongStart}%{visible} of %{total}%{strongEnd} files are displayed."
msgstr ""
msgid "To preserve performance only %{strong_open}%{display_size} of %{real_size}%{strong_close} files are displayed." msgid "To preserve performance only %{strong_open}%{display_size} of %{real_size}%{strong_close} files are displayed."
msgstr "" msgstr ""
......
...@@ -45,8 +45,8 @@ RSpec.describe 'Merge request > User sees diff', :js do ...@@ -45,8 +45,8 @@ RSpec.describe 'Merge request > User sees diff', :js do
visit diffs_project_merge_request_path(project, merge_request) visit diffs_project_merge_request_path(project, merge_request)
page.within('.alert') do page.within('.gl-alert') do
expect(page).to have_text("Too many changes to show. Plain diff Email patch To preserve performance only 3 of 3+ files are displayed.") expect(page).to have_text("Too many changes to show. To preserve performance only 3 of 3+ files are displayed. Plain diff Email patch")
end end
end end
end end
......
import { shallowMount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui';
import { __ } from '~/locale';
import HiddenFilesWarning from '~/diffs/components/hidden_files_warning.vue'; import HiddenFilesWarning from '~/diffs/components/hidden_files_warning.vue';
const propsData = { const propsData = {
...@@ -12,7 +14,7 @@ describe('HiddenFilesWarning', () => { ...@@ -12,7 +14,7 @@ describe('HiddenFilesWarning', () => {
let wrapper; let wrapper;
const createComponent = () => { const createComponent = () => {
wrapper = shallowMount(HiddenFilesWarning, { wrapper = mount(HiddenFilesWarning, {
propsData, propsData,
}); });
}; };
...@@ -26,22 +28,20 @@ describe('HiddenFilesWarning', () => { ...@@ -26,22 +28,20 @@ describe('HiddenFilesWarning', () => {
}); });
it('has a correct plain diff URL', () => { it('has a correct plain diff URL', () => {
const plainDiffLink = wrapper.findAll('a').wrappers.filter((x) => x.text() === 'Plain diff')[0]; const plainDiffLink = wrapper.findAllComponents(GlButton).at(0);
expect(plainDiffLink.attributes('href')).toBe(propsData.plainDiffPath); expect(plainDiffLink.attributes('href')).toBe(propsData.plainDiffPath);
}); });
it('has a correct email patch URL', () => { it('has a correct email patch URL', () => {
const emailPatchLink = wrapper const emailPatchLink = wrapper.findAllComponents(GlButton).at(1);
.findAll('a')
.wrappers.filter((x) => x.text() === 'Email patch')[0];
expect(emailPatchLink.attributes('href')).toBe(propsData.emailPatchPath); expect(emailPatchLink.attributes('href')).toBe(propsData.emailPatchPath);
}); });
it('has a correct visible/total files text', () => { it('has a correct visible/total files text', () => {
const filesText = wrapper.find('strong'); expect(wrapper.text()).toContain(
__('To preserve performance only 5 of 10 files are displayed.'),
expect(filesText.text()).toBe('5 of 10'); );
}); });
}); });
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