Commit 74ed4502 authored by Jeremy Elder's avatar Jeremy Elder Committed by Nicolò Maria Mezzopera

Migrate Bootstrap button to GlButton in MR discussion

parent ade7aa1c
...@@ -55,7 +55,7 @@ export default { ...@@ -55,7 +55,7 @@ export default {
<div class="discussion-with-resolve-btn clearfix"> <div class="discussion-with-resolve-btn clearfix">
<reply-placeholder <reply-placeholder
data-qa-selector="discussion_reply_tab" data-qa-selector="discussion_reply_tab"
:button-text="s__('MergeRequests|Reply...')" :button-text="s__('MergeRequests|Reply')"
@onClick="$emit('showReplyForm')" @onClick="$emit('showReplyForm')"
/> />
......
<script> <script>
import { GlButton } from '@gitlab/ui';
export default { export default {
name: 'ReplyPlaceholder', name: 'ReplyPlaceholder',
components: {
GlButton,
},
props: { props: {
buttonText: { buttonText: {
type: String, type: String,
...@@ -11,13 +16,13 @@ export default { ...@@ -11,13 +16,13 @@ export default {
</script> </script>
<template> <template>
<button <gl-button
ref="button" category="primary"
type="button" variant="success"
class="js-vue-discussion-reply btn btn-text-field" class="js-vue-discussion-reply"
:title="s__('MergeRequests|Add a reply')" :title="s__('MergeRequests|Add a reply')"
@click="$emit('onClick')" @click="$emit('onClick')"
> >
{{ buttonText }} {{ buttonText }}
</button> </gl-button>
</template> </template>
...@@ -244,20 +244,15 @@ ...@@ -244,20 +244,15 @@
} }
&.btn-text-field { &.btn-text-field {
color: $gray-500;
justify-content: start;
width: 100%; width: 100%;
text-align: left; text-align: left;
padding: 6px 16px;
border-color: $border-color;
color: $gray-darkest;
background-color: $white;
&:hover, &:hover,
&:active, &:active,
&:focus { &:focus {
cursor: text; cursor: text;
box-shadow: none;
border-color: lighten($blue-300, 20%);
color: $gray-darkest;
} }
} }
......
---
title: Replacing deprecated Bootstrap button with GlButton and updating btn-text-field
class to align with styles
merge_request: 41430
author:
type: other
...@@ -15936,7 +15936,7 @@ msgstr "" ...@@ -15936,7 +15936,7 @@ msgstr ""
msgid "MergeRequests|Jump to next unresolved thread" msgid "MergeRequests|Jump to next unresolved thread"
msgstr "" msgstr ""
msgid "MergeRequests|Reply..." msgid "MergeRequests|Reply"
msgstr "" msgstr ""
msgid "MergeRequests|Resolve this thread in a new issue" msgid "MergeRequests|Resolve this thread in a new issue"
......
...@@ -834,7 +834,7 @@ RSpec.describe 'GFM autocomplete', :js do ...@@ -834,7 +834,7 @@ RSpec.describe 'GFM autocomplete', :js do
end end
def start_and_cancel_discussion def start_and_cancel_discussion
click_button('Reply...') click_button('Reply')
fill_in('note_note', with: 'Whoops!') fill_in('note_note', with: 'Whoops!')
......
...@@ -238,7 +238,7 @@ end ...@@ -238,7 +238,7 @@ end
def write_reply_to_discussion(button_text: 'Start a review', text: 'Line is wrong', resolve: false, unresolve: false) def write_reply_to_discussion(button_text: 'Start a review', text: 'Line is wrong', resolve: false, unresolve: false)
page.within(first('.diff-files-holder .discussion-reply-holder')) do page.within(first('.diff-files-holder .discussion-reply-holder')) do
click_button('Reply...') click_button('Reply')
fill_in('note_note', with: text) fill_in('note_note', with: text)
......
...@@ -186,7 +186,7 @@ RSpec.describe 'Merge request > User posts diff notes', :js do ...@@ -186,7 +186,7 @@ RSpec.describe 'Merge request > User posts diff notes', :js do
it 'adds as discussion' do it 'adds as discussion' do
should_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]'), asset_form_reset: false) should_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]'), asset_form_reset: false)
expect(page).to have_css('.notes_holder .note.note-discussion', count: 1) expect(page).to have_css('.notes_holder .note.note-discussion', count: 1)
expect(page).to have_button('Reply...') expect(page).to have_button('Reply')
end end
end end
end end
......
...@@ -146,7 +146,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do ...@@ -146,7 +146,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it 'allows user to comment' do it 'allows user to comment' do
page.within '.diff-content' do page.within '.diff-content' do
click_button 'Reply...' click_button 'Reply'
find(".js-unresolve-checkbox").set false find(".js-unresolve-checkbox").set false
find('.js-note-text').set 'testing' find('.js-note-text').set 'testing'
...@@ -176,7 +176,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do ...@@ -176,7 +176,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it 'allows user to comment & unresolve thread' do it 'allows user to comment & unresolve thread' do
page.within '.diff-content' do page.within '.diff-content' do
click_button 'Reply...' click_button 'Reply'
find('.js-note-text').set 'testing' find('.js-note-text').set 'testing'
...@@ -205,7 +205,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do ...@@ -205,7 +205,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it 'allows user to comment & resolve thread' do it 'allows user to comment & resolve thread' do
page.within '.diff-content' do page.within '.diff-content' do
click_button 'Reply...' click_button 'Reply'
find('.js-note-text').set 'testing' find('.js-note-text').set 'testing'
...@@ -438,7 +438,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do ...@@ -438,7 +438,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it 'allows user to comment & resolve thread' do it 'allows user to comment & resolve thread' do
page.within '.diff-content' do page.within '.diff-content' do
click_button 'Reply...' click_button 'Reply'
find('.js-note-text').set 'testing' find('.js-note-text').set 'testing'
...@@ -457,7 +457,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do ...@@ -457,7 +457,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
page.within '.diff-content' do page.within '.diff-content' do
click_button 'Resolve thread' click_button 'Resolve thread'
click_button 'Reply...' click_button 'Reply'
find('.js-note-text').set 'testing' find('.js-note-text').set 'testing'
......
...@@ -37,7 +37,7 @@ RSpec.describe 'Merge request > User sees avatars on diff notes', :js do ...@@ -37,7 +37,7 @@ RSpec.describe 'Merge request > User sees avatars on diff notes', :js do
end end
it 'does not render avatars after commenting on discussion tab' do it 'does not render avatars after commenting on discussion tab' do
click_button 'Reply...' click_button 'Reply'
page.within('.js-discussion-note-form') do page.within('.js-discussion-note-form') do
find('.note-textarea').native.send_keys('Test comment') find('.note-textarea').native.send_keys('Test comment')
...@@ -132,7 +132,7 @@ RSpec.describe 'Merge request > User sees avatars on diff notes', :js do ...@@ -132,7 +132,7 @@ RSpec.describe 'Merge request > User sees avatars on diff notes', :js do
end end
it 'adds avatar when commenting' do it 'adds avatar when commenting' do
click_button 'Reply...' click_button 'Reply'
page.within '.js-discussion-note-form' do page.within '.js-discussion-note-form' do
find('.js-note-text').native.send_keys('Test') find('.js-note-text').native.send_keys('Test')
...@@ -151,7 +151,7 @@ RSpec.describe 'Merge request > User sees avatars on diff notes', :js do ...@@ -151,7 +151,7 @@ RSpec.describe 'Merge request > User sees avatars on diff notes', :js do
it 'adds multiple comments' do it 'adds multiple comments' do
3.times do 3.times do
click_button 'Reply...' click_button 'Reply'
page.within '.js-discussion-note-form' do page.within '.js-discussion-note-form' do
find('.js-note-text').native.send_keys('Test') find('.js-note-text').native.send_keys('Test')
......
...@@ -60,7 +60,7 @@ RSpec.describe 'Merge request > User sees threads', :js do ...@@ -60,7 +60,7 @@ RSpec.describe 'Merge request > User sees threads', :js do
it 'can be replied to' do it 'can be replied to' do
within(".discussion[data-discussion-id='#{discussion_id}']") do within(".discussion[data-discussion-id='#{discussion_id}']") do
click_button 'Reply...' click_button 'Reply'
fill_in 'note[note]', with: 'Test!' fill_in 'note[note]', with: 'Test!'
click_button 'Comment' click_button 'Comment'
......
...@@ -27,7 +27,7 @@ RSpec.describe 'Merge request > User sees notes from forked project', :js do ...@@ -27,7 +27,7 @@ RSpec.describe 'Merge request > User sees notes from forked project', :js do
expect(page).to have_content('A commit comment') expect(page).to have_content('A commit comment')
page.within('.discussion-notes') do page.within('.discussion-notes') do
find('.btn-text-field').click find('.js-vue-discussion-reply').click
scroll_to(page.find('#note_note', visible: false)) scroll_to(page.find('#note_note', visible: false))
find('#note_note').send_keys('A reply comment') find('#note_note').send_keys('A reply comment')
find('.js-comment-button').click find('.js-comment-button').click
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui';
import ReplyPlaceholder from '~/notes/components/discussion_reply_placeholder.vue'; import ReplyPlaceholder from '~/notes/components/discussion_reply_placeholder.vue';
const buttonText = 'Test Button Text'; const buttonText = 'Test Button Text';
...@@ -6,7 +7,7 @@ const buttonText = 'Test Button Text'; ...@@ -6,7 +7,7 @@ const buttonText = 'Test Button Text';
describe('ReplyPlaceholder', () => { describe('ReplyPlaceholder', () => {
let wrapper; let wrapper;
const findButton = () => wrapper.find({ ref: 'button' }); const findButton = () => wrapper.find(GlButton);
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(ReplyPlaceholder, { wrapper = shallowMount(ReplyPlaceholder, {
...@@ -20,8 +21,8 @@ describe('ReplyPlaceholder', () => { ...@@ -20,8 +21,8 @@ describe('ReplyPlaceholder', () => {
wrapper.destroy(); wrapper.destroy();
}); });
it('emits onClick event on button click', () => { it('should emit a onClick event on button click', () => {
findButton().trigger('click'); findButton().vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted()).toEqual({ expect(wrapper.emitted()).toEqual({
......
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