Commit 6c0b8af7 authored by Annabel Dunstone Gray's avatar Annabel Dunstone Gray

Merge branch 'ee-add-gl-link-to-markdown-header' into 'master'

Change markdown header tab anchor links to buttons

See merge request gitlab-org/gitlab-ee!8001
parents 5bfc5179 f5494b83
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import tooltip from '../../directives/tooltip'; import Tooltip from '../../directives/tooltip';
import toolbarButton from './toolbar_button.vue'; import ToolbarButton from './toolbar_button.vue';
import icon from '../icon.vue'; import Icon from '../icon.vue';
export default { export default {
directives: { directives: {
tooltip, Tooltip,
}, },
components: { components: {
toolbarButton, ToolbarButton,
icon, Icon,
}, },
props: { props: {
previewMarkdown: { previewMarkdown: {
...@@ -68,27 +68,27 @@ export default { ...@@ -68,27 +68,27 @@ export default {
:class="{ active: !previewMarkdown }" :class="{ active: !previewMarkdown }"
class="md-header-tab" class="md-header-tab"
> >
<a <button
class="js-write-link" class="js-write-link"
href="#md-write-holder"
tabindex="-1" tabindex="-1"
@click.prevent="writeMarkdownTab($event)" type="button"
@click="writeMarkdownTab($event)"
> >
Write Write
</a> </button>
</li> </li>
<li <li
:class="{ active: previewMarkdown }" :class="{ active: previewMarkdown }"
class="md-header-tab" class="md-header-tab"
> >
<a <button
class="js-preview-link js-md-preview-button" class="js-preview-link js-md-preview-button"
href="#md-preview-holder"
tabindex="-1" tabindex="-1"
@click.prevent="previewMarkdownTab($event)" type="button"
@click="previewMarkdownTab($event)"
> >
Preview Preview
</a> </button>
</li> </li>
<li <li
:class="{ active: !previewMarkdown }" :class="{ active: !previewMarkdown }"
......
...@@ -161,6 +161,7 @@ ...@@ -161,6 +161,7 @@
.nav-links li { .nav-links li {
&.active a, &.active a,
&.md-header-tab.active button,
a.active { a.active {
border-bottom: 2px solid $active-tab-border; border-bottom: 2px solid $active-tab-border;
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
.md-header-tab { .md-header-tab {
@include media-breakpoint-down(xs) { @include media-breakpoint-down(xs) {
flex: 1; flex: 1;
flex-direction: column;
width: 100%; width: 100%;
border-bottom: 1px solid $border-color; border-bottom: 1px solid $border-color;
text-align: center; text-align: center;
......
...@@ -8,15 +8,17 @@ ...@@ -8,15 +8,17 @@
height: auto; height: auto;
border-bottom: 1px solid $border-color; border-bottom: 1px solid $border-color;
li { li:not(.md-header-toolbar) {
display: flex; display: flex;
a { a,
button {
padding: $gl-btn-padding; padding: $gl-btn-padding;
padding-bottom: 11px; padding-bottom: 11px;
font-size: 14px; font-size: 14px;
line-height: 28px; line-height: 28px;
color: $gl-text-color-secondary; color: $gl-text-color-secondary;
border: 0;
border-bottom: 2px solid transparent; border-bottom: 2px solid transparent;
white-space: nowrap; white-space: nowrap;
...@@ -33,7 +35,12 @@ ...@@ -33,7 +35,12 @@
} }
} }
button {
padding-top: 0;
}
&.active a, &.active a,
&.active button,
a.active { a.active {
color: $black; color: $black;
font-weight: $gl-font-weight-bold; font-weight: $gl-font-weight-bold;
...@@ -42,6 +49,10 @@ ...@@ -42,6 +49,10 @@
color: $black; color: $black;
} }
} }
&.md-header-tab button {
line-height: 19px;
}
} }
} }
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
.md-header .md-header
%ul.nav.nav-tabs.nav-links.clearfix %ul.nav.nav-tabs.nav-links.clearfix
%li.md-header-tab.active %li.md-header-tab.active
%a.js-md-write-button{ href: "#md-write-holder", tabindex: -1 } %button.js-md-write-button{ tabindex: -1 }
Write Write
%li.md-header-tab %li.md-header-tab
%a.js-md-preview-button{ href: "#md-preview-holder", tabindex: -1 } %button.js-md-preview-button{ tabindex: -1 }
Preview Preview
%li.md-header-toolbar.active %li.md-header-toolbar.active
......
---
title: Change markdown header tab anchor links to buttons
merge_request: 21988
author: George Tsiolis
type: other
...@@ -47,7 +47,7 @@ describe 'Update Epic', :js do ...@@ -47,7 +47,7 @@ describe 'Update Epic', :js do
fill_in 'issue-description', with: 'New epic description' fill_in 'issue-description', with: 'New epic description'
page.within('.detail-page-description') do page.within('.detail-page-description') do
click_link('Preview') click_button('Preview')
expect(find('.md-preview')).to have_content('New epic description') expect(find('.md-preview')).to have_content('New epic description')
end end
...@@ -97,7 +97,7 @@ describe 'Update Epic', :js do ...@@ -97,7 +97,7 @@ describe 'Update Epic', :js do
expect(page.find_field("issue-description").value).to have_content('banana_sample') expect(page.find_field("issue-description").value).to have_content('banana_sample')
page.within('.detail-page-description') do page.within('.detail-page-description') do
click_link('Preview') click_button('Preview')
wait_for_requests wait_for_requests
within('.md-preview') do within('.md-preview') do
......
...@@ -23,17 +23,17 @@ describe 'Group milestones' do ...@@ -23,17 +23,17 @@ describe 'Group milestones' do
description.native.send_keys('') description.native.send_keys('')
click_link('Preview') click_button('Preview')
preview = find('.js-md-preview') preview = find('.js-md-preview')
expect(preview).to have_content('Nothing to preview.') expect(preview).to have_content('Nothing to preview.')
click_link('Write') click_button('Write')
description.native.send_keys(':+1: Nice') description.native.send_keys(':+1: Nice')
click_link('Preview') click_button('Preview')
expect(preview).to have_css('gl-emoji') expect(preview).to have_css('gl-emoji')
expect(find('#milestone_description', visible: false)).not_to be_visible expect(find('#milestone_description', visible: false)).not_to be_visible
......
...@@ -47,15 +47,15 @@ describe "User creates issue" do ...@@ -47,15 +47,15 @@ describe "User creates issue" do
textarea = first(".gfm-form textarea") textarea = first(".gfm-form textarea")
page.within(form) do page.within(form) do
click_link("Preview") click_button("Preview")
preview = find(".js-md-preview") # this element is findable only when the "Preview" link is clicked. preview = find(".js-md-preview") # this element is findable only when the "Preview" link is clicked.
expect(preview).to have_content("Nothing to preview.") expect(preview).to have_content("Nothing to preview.")
click_link("Write") click_button("Write")
fill_in("Description", with: "Bug fixed :smile:") fill_in("Description", with: "Bug fixed :smile:")
click_link("Preview") click_button("Preview")
expect(preview).to have_css("gl-emoji") expect(preview).to have_css("gl-emoji")
expect(textarea).not_to be_visible expect(textarea).not_to be_visible
......
...@@ -17,9 +17,9 @@ describe "User edits issue", :js do ...@@ -17,9 +17,9 @@ describe "User edits issue", :js do
page.within(form) do page.within(form) do
fill_in("Description", with: "Bug fixed :smile:") fill_in("Description", with: "Bug fixed :smile:")
click_link("Preview") click_button("Preview")
end end
expect(form).to have_link("Write") expect(form).to have_button("Write")
end end
end end
...@@ -41,7 +41,7 @@ describe 'User views an open merge request' do ...@@ -41,7 +41,7 @@ describe 'User views an open merge request' do
find('.gfm-form').fill_in(:merge_request_description, with: '') find('.gfm-form').fill_in(:merge_request_description, with: '')
page.within('.gfm-form') do page.within('.gfm-form') do
click_link('Preview') click_button('Preview')
expect(find('.js-md-preview')).to have_content('Nothing to preview.') expect(find('.js-md-preview')).to have_content('Nothing to preview.')
end end
...@@ -51,12 +51,12 @@ describe 'User views an open merge request' do ...@@ -51,12 +51,12 @@ describe 'User views an open merge request' do
find('.gfm-form').fill_in(:merge_request_description, with: ':+1: Nice') find('.gfm-form').fill_in(:merge_request_description, with: ':+1: Nice')
page.within('.gfm-form') do page.within('.gfm-form') do
click_link('Preview') click_button('Preview')
expect(find('.js-md-preview')).to have_css('gl-emoji') expect(find('.js-md-preview')).to have_css('gl-emoji')
end end
expect(find('.gfm-form')).to have_css('.js-md-preview').and have_link('Write') expect(find('.gfm-form')).to have_css('.js-md-preview').and have_button('Write')
expect(find('#merge_request_description', visible: false)).not_to be_visible expect(find('#merge_request_description', visible: false)).not_to be_visible
end end
end end
......
...@@ -28,19 +28,19 @@ describe "User adds a comment on a commit", :js do ...@@ -28,19 +28,19 @@ describe "User adds a comment on a commit", :js do
fill_in("note[note]", with: "#{comment_text} #{emoji}") fill_in("note[note]", with: "#{comment_text} #{emoji}")
# Check on `Preview` tab # Check on `Preview` tab
click_link("Preview") click_button("Preview")
expect(find(".js-md-preview")).to have_content(comment_text).and have_css("gl-emoji") expect(find(".js-md-preview")).to have_content(comment_text).and have_css("gl-emoji")
expect(page).not_to have_css(".js-note-text") expect(page).not_to have_css(".js-note-text")
# Check on the `Write` tab # Check on the `Write` tab
click_link("Write") click_button("Write")
expect(page).to have_field("note[note]", with: "#{comment_text} #{emoji}") expect(page).to have_field("note[note]", with: "#{comment_text} #{emoji}")
# Submit comment from the `Preview` tab to get rid of a separate `it` block # Submit comment from the `Preview` tab to get rid of a separate `it` block
# which would specially tests if everything gets cleared from the note form. # which would specially tests if everything gets cleared from the note form.
click_link("Preview") click_button("Preview")
click_button("Comment") click_button("Comment")
end end
...@@ -88,13 +88,13 @@ describe "User adds a comment on a commit", :js do ...@@ -88,13 +88,13 @@ describe "User adds a comment on a commit", :js do
# Test Preview feature for both forms. # Test Preview feature for both forms.
page.within("form[data-line-code='#{sample_commit.line_code}']") do page.within("form[data-line-code='#{sample_commit.line_code}']") do
click_link("Preview") click_button("Preview")
end end
page.within("form[data-line-code='#{sample_commit.del_line_code}']") do page.within("form[data-line-code='#{sample_commit.del_line_code}']") do
fill_in("note[note]", with: another_comment_text) fill_in("note[note]", with: another_comment_text)
click_link("Preview") click_button("Preview")
end end
expect(page).to have_css(".js-md-preview", visible: true, count: 2) expect(page).to have_css(".js-md-preview", visible: true, count: 2)
......
...@@ -25,19 +25,19 @@ describe "User comments on commit", :js do ...@@ -25,19 +25,19 @@ describe "User comments on commit", :js do
fill_in("note[note]", with: "#{comment_text} #{emoji_code}") fill_in("note[note]", with: "#{comment_text} #{emoji_code}")
# Check on `Preview` tab # Check on `Preview` tab
click_link("Preview") click_button("Preview")
expect(find(".js-md-preview")).to have_content(comment_text).and have_css("gl-emoji") expect(find(".js-md-preview")).to have_content(comment_text).and have_css("gl-emoji")
expect(page).not_to have_css(".js-note-text") expect(page).not_to have_css(".js-note-text")
# Check on `Write` tab # Check on `Write` tab
click_link("Write") click_button("Write")
expect(page).to have_field("note[note]", with: "#{comment_text} #{emoji_code}") expect(page).to have_field("note[note]", with: "#{comment_text} #{emoji_code}")
# Submit comment from the `Preview` tab to get rid of a separate `it` block # Submit comment from the `Preview` tab to get rid of a separate `it` block
# which would specially tests if everything gets cleared from the note form. # which would specially tests if everything gets cleared from the note form.
click_link("Preview") click_button("Preview")
click_button("Comment") click_button("Comment")
end end
......
...@@ -76,7 +76,7 @@ describe('Markdown field header component', () => { ...@@ -76,7 +76,7 @@ describe('Markdown field header component', () => {
}); });
it('blurs preview link after click', done => { it('blurs preview link after click', done => {
const link = vm.$el.querySelector('li:nth-child(2) a'); const link = vm.$el.querySelector('li:nth-child(2) button');
spyOn(HTMLElement.prototype, 'blur'); spyOn(HTMLElement.prototype, 'blur');
link.click(); link.click();
......
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