Commit 619ae3d7 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch...

Merge branch '241957-remove-v-html-from-app-assets-javascripts-notes-components-discussion_filter_note-vue' into 'master'

Replace v-html with GlSprintf in discussion_filter_note.vue

See merge request gitlab-org/gitlab!41482
parents 456bec4c 527ffaad
<script> <script>
/* eslint-disable vue/no-v-html */ import { GlButton, GlIcon, GlSprintf } from '@gitlab/ui';
import { GlButton, GlIcon } from '@gitlab/ui'; import { s__ } from '~/locale';
import { __, sprintf } from '~/locale';
import notesEventHub from '../event_hub'; import notesEventHub from '../event_hub';
export default { export default {
i18n: {
information: s__(
"Notes|You're only seeing %{boldStart}other activity%{boldEnd} in the feed. To add a comment, switch to one of the following options.",
),
},
components: { components: {
GlButton, GlButton,
GlIcon, GlIcon,
}, GlSprintf,
computed: {
timelineContent() {
return sprintf(
__(
"You're only seeing %{startTag}other activity%{endTag} in the feed. To add a comment, switch to one of the following options.",
),
{
startTag: `<b>`,
endTag: `</b>`,
},
false,
);
},
}, },
methods: { methods: {
selectFilter(value) { selectFilter(value) {
...@@ -41,12 +32,18 @@ export default { ...@@ -41,12 +32,18 @@ export default {
<gl-icon name="comment" /> <gl-icon name="comment" />
</div> </div>
<div class="timeline-content"> <div class="timeline-content">
<div ref="timelineContent" v-html="timelineContent"></div> <div data-testid="discussion-filter-timeline-content">
<gl-sprintf :message="$options.i18n.information">
<template #bold="{ content }">
<b>{{ content }}</b>
</template>
</gl-sprintf>
</div>
<div class="discussion-filter-actions mt-2"> <div class="discussion-filter-actions mt-2">
<gl-button ref="showAllActivity" variant="default" @click="selectFilter(0)"> <gl-button variant="default" @click="selectFilter(0)">
{{ __('Show all activity') }} {{ __('Show all activity') }}
</gl-button> </gl-button>
<gl-button ref="showComments" variant="default" @click="selectFilter(1)"> <gl-button variant="default" @click="selectFilter(1)">
{{ __('Show comments only') }} {{ __('Show comments only') }}
</gl-button> </gl-button>
</div> </div>
......
---
title: Replace v-html with GlSprintf in notes/.../discussion_filter_note.vue
merge_request: 41482
author: Takuya Noguchi
type: other
...@@ -18511,6 +18511,9 @@ msgstr "" ...@@ -18511,6 +18511,9 @@ msgstr ""
msgid "Notes|This comment has changed since you started editing, please review the %{open_link}updated comment%{close_link} to ensure information is not lost" msgid "Notes|This comment has changed since you started editing, please review the %{open_link}updated comment%{close_link} to ensure information is not lost"
msgstr "" msgstr ""
msgid "Notes|You're only seeing %{boldStart}other activity%{boldEnd} in the feed. To add a comment, switch to one of the following options."
msgstr ""
msgid "Nothing found…" msgid "Nothing found…"
msgstr "" msgstr ""
...@@ -30920,9 +30923,6 @@ msgstr "" ...@@ -30920,9 +30923,6 @@ msgstr ""
msgid "You're not allowed to make changes to this project directly. A fork of this project is being created that you can make changes in, so you can submit a merge request." msgid "You're not allowed to make changes to this project directly. A fork of this project is being created that you can make changes in, so you can submit a merge request."
msgstr "" msgstr ""
msgid "You're only seeing %{startTag}other activity%{endTag} in the feed. To add a comment, switch to one of the following options."
msgstr ""
msgid "You're receiving this email because of your account on %{host}." msgid "You're receiving this email because of your account on %{host}."
msgstr "" msgstr ""
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlButton, GlSprintf } from '@gitlab/ui';
import DiscussionFilterNote from '~/notes/components/discussion_filter_note.vue'; import DiscussionFilterNote from '~/notes/components/discussion_filter_note.vue';
import eventHub from '~/notes/event_hub'; import eventHub from '~/notes/event_hub';
...@@ -6,7 +7,11 @@ describe('DiscussionFilterNote component', () => { ...@@ -6,7 +7,11 @@ describe('DiscussionFilterNote component', () => {
let wrapper; let wrapper;
const createComponent = () => { const createComponent = () => {
wrapper = shallowMount(DiscussionFilterNote); wrapper = shallowMount(DiscussionFilterNote, {
stubs: {
GlSprintf,
},
});
}; };
beforeEach(() => { beforeEach(() => {
...@@ -19,21 +24,27 @@ describe('DiscussionFilterNote component', () => { ...@@ -19,21 +24,27 @@ describe('DiscussionFilterNote component', () => {
}); });
it('timelineContent renders a string containing instruction for switching feed type', () => { it('timelineContent renders a string containing instruction for switching feed type', () => {
expect(wrapper.find({ ref: 'timelineContent' }).html()).toBe( expect(wrapper.find('[data-testid="discussion-filter-timeline-content"]').html()).toBe(
"<div>You're only seeing <b>other activity</b> in the feed. To add a comment, switch to one of the following options.</div>", '<div data-testid="discussion-filter-timeline-content">You\'re only seeing <b>other activity</b> in the feed. To add a comment, switch to one of the following options.</div>',
); );
}); });
it('emits `dropdownSelect` event with 0 parameter on clicking Show all activity button', () => { it('emits `dropdownSelect` event with 0 parameter on clicking Show all activity button', () => {
jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
wrapper.find({ ref: 'showAllActivity' }).vm.$emit('click'); wrapper
.findAll(GlButton)
.at(0)
.vm.$emit('click');
expect(eventHub.$emit).toHaveBeenCalledWith('dropdownSelect', 0); expect(eventHub.$emit).toHaveBeenCalledWith('dropdownSelect', 0);
}); });
it('emits `dropdownSelect` event with 1 parameter on clicking Show comments only button', () => { it('emits `dropdownSelect` event with 1 parameter on clicking Show comments only button', () => {
jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
wrapper.find({ ref: 'showComments' }).vm.$emit('click'); wrapper
.findAll(GlButton)
.at(1)
.vm.$emit('click');
expect(eventHub.$emit).toHaveBeenCalledWith('dropdownSelect', 1); expect(eventHub.$emit).toHaveBeenCalledWith('dropdownSelect', 1);
}); });
......
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