Commit 8fe3c979 authored by Brandon Labuschagne's avatar Brandon Labuschagne

Merge branch...

Merge branch 'Migrate-Bootstrap-dropdown-to-GitLab-UI-GlDropdown-in-app/assets/javascripts/diffs' into 'master'

Migrate Bootstrap dropdown to GlDropdown in app/assets/javascripts/diffs

See merge request gitlab-org/gitlab!41451
parents c2988dd5 6d54a981
<script> <script>
import { GlIcon } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
export default { export default {
components: { components: {
GlIcon, GlDropdown,
GlDropdownItem,
TimeAgo, TimeAgo,
}, },
props: { props: {
...@@ -22,29 +23,22 @@ export default { ...@@ -22,29 +23,22 @@ export default {
</script> </script>
<template> <template>
<span class="dropdown inline"> <gl-dropdown :text="selectedVersionName" data-qa-selector="dropdown_content">
<a <gl-dropdown-item
class="dropdown-menu-toggle btn btn-default w-100" v-for="version in versions"
data-toggle="dropdown" :key="version.id"
aria-expanded="false" :class="{
'is-active': version.selected,
}"
:is-check-item="true"
:is-checked="version.selected"
:href="version.href"
> >
<span> {{ selectedVersionName }} </span>
<gl-icon :size="12" name="angle-down" class="position-absolute" />
</a>
<div class="dropdown-menu dropdown-select dropdown-menu-selectable">
<div class="dropdown-content" data-qa-selector="dropdown_content">
<ul>
<li v-for="version in versions" :key="version.id">
<a :class="{ 'is-active': version.selected }" :href="version.href">
<div> <div>
<strong> <strong>
{{ version.versionName }} {{ version.versionName }}
<template v-if="version.isHead">{{ <template v-if="version.isHead">{{ s__('DiffsCompareBaseBranch|(HEAD)') }}</template>
s__('DiffsCompareBaseBranch|(HEAD)') <template v-else-if="version.isBase">{{ s__('DiffsCompareBaseBranch|(base)') }}</template>
}}</template>
<template v-else-if="version.isBase">{{
s__('DiffsCompareBaseBranch|(base)')
}}</template>
</strong> </strong>
</div> </div>
<div> <div>
...@@ -55,24 +49,9 @@ export default { ...@@ -55,24 +49,9 @@ export default {
<template v-if="version.commitsText"> <template v-if="version.commitsText">
{{ version.commitsText }} {{ version.commitsText }}
</template> </template>
<time-ago <time-ago v-if="version.created_at" :time="version.created_at" class="js-timeago" />
v-if="version.created_at"
:time="version.created_at"
class="js-timeago"
/>
</small> </small>
</div> </div>
</a> </gl-dropdown-item>
</li> </gl-dropdown>
</ul>
</div>
</div>
</span>
</template> </template>
<style>
.dropdown {
min-width: 0;
max-height: 170px;
}
</style>
...@@ -720,7 +720,7 @@ $mr-widget-min-height: 69px; ...@@ -720,7 +720,7 @@ $mr-widget-min-height: 69px;
z-index: 199; z-index: 199;
white-space: nowrap; white-space: nowrap;
.dropdown-menu-toggle { .gl-dropdown-toggle {
width: auto; width: auto;
max-width: 170px; max-width: 170px;
......
---
title: Migrate bootstrap dropdown to GlDropdown in app/assets/javascripts/diffs
merge_request: 41451
author: nuwe1
type: other
...@@ -73,14 +73,14 @@ RSpec.describe 'Merge request > User sees versions', :js do ...@@ -73,14 +73,14 @@ RSpec.describe 'Merge request > User sees versions', :js do
it 'shows the commit SHAs for every version in the dropdown' do it 'shows the commit SHAs for every version in the dropdown' do
page.within '.mr-version-dropdown' do page.within '.mr-version-dropdown' do
find('.btn-default').click find('.gl-dropdown-toggle').click
end
page.within('.dropdown-content') do page.within '.mr-version-dropdown' do
shas = merge_request.merge_request_diffs.map { |diff| Commit.truncate_sha(diff.head_commit_sha) } shas = merge_request.merge_request_diffs.map { |diff| Commit.truncate_sha(diff.head_commit_sha) }
shas.each { |sha| expect(page).to have_content(sha) } shas.each { |sha| expect(page).to have_content(sha) }
end end
end end
end
it 'shows comments that were last relevant at that version' do it 'shows comments that were last relevant at that version' do
expect(page).to have_content '5 files' expect(page).to have_content '5 files'
...@@ -182,7 +182,7 @@ RSpec.describe 'Merge request > User sees versions', :js do ...@@ -182,7 +182,7 @@ RSpec.describe 'Merge request > User sees versions', :js do
it 'has 0 chages between versions' do it 'has 0 chages between versions' do
page.within '.mr-version-compare-dropdown' do page.within '.mr-version-compare-dropdown' do
expect(find('.dropdown-menu-toggle')).to have_content 'version 1' expect(find('.gl-dropdown-toggle')).to have_content 'version 1'
end end
page.within '.mr-version-dropdown' do page.within '.mr-version-dropdown' do
...@@ -203,7 +203,7 @@ RSpec.describe 'Merge request > User sees versions', :js do ...@@ -203,7 +203,7 @@ RSpec.describe 'Merge request > User sees versions', :js do
it 'sets the compared versions to be the same' do it 'sets the compared versions to be the same' do
page.within '.mr-version-compare-dropdown' do page.within '.mr-version-compare-dropdown' do
expect(find('.dropdown-menu-toggle')).to have_content 'version 2' expect(find('.gl-dropdown-toggle')).to have_content 'version 2'
end end
page.within '.mr-version-dropdown' do page.within '.mr-version-dropdown' do
......
import { shallowMount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { trimText } from 'helpers/text_helper'; import { trimText } from 'helpers/text_helper';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import CompareDropdownLayout from '~/diffs/components/compare_dropdown_layout.vue'; import CompareDropdownLayout from '~/diffs/components/compare_dropdown_layout.vue';
...@@ -22,7 +22,7 @@ describe('CompareDropdownLayout', () => { ...@@ -22,7 +22,7 @@ describe('CompareDropdownLayout', () => {
}); });
const createComponent = (propsData = {}) => { const createComponent = (propsData = {}) => {
wrapper = shallowMount(CompareDropdownLayout, { wrapper = mount(CompareDropdownLayout, {
propsData: { propsData: {
...propsData, ...propsData,
}, },
...@@ -35,7 +35,7 @@ describe('CompareDropdownLayout', () => { ...@@ -35,7 +35,7 @@ describe('CompareDropdownLayout', () => {
href: listItem.find('a').attributes('href'), href: listItem.find('a').attributes('href'),
text: trimText(listItem.text()), text: trimText(listItem.text()),
createdAt: listItem.findAll(TimeAgo).wrappers[0]?.props('time'), createdAt: listItem.findAll(TimeAgo).wrappers[0]?.props('time'),
isActive: listItem.find('a.is-active').exists(), isActive: listItem.classes().includes('is-active'),
})); }));
afterEach(() => { afterEach(() => {
...@@ -69,7 +69,7 @@ describe('CompareDropdownLayout', () => { ...@@ -69,7 +69,7 @@ describe('CompareDropdownLayout', () => {
expect(findListItemsData()).toEqual([ expect(findListItemsData()).toEqual([
{ {
href: 'version/1', href: 'version/1',
text: 'version 1 (base) abcdef1 1 commit', text: 'version 1 (base) abcdef1 1 commit 2 years ago',
createdAt: TEST_CREATED_AT, createdAt: TEST_CREATED_AT,
isActive: true, isActive: true,
}, },
......
...@@ -59,8 +59,8 @@ describe('CompareVersions', () => { ...@@ -59,8 +59,8 @@ describe('CompareVersions', () => {
expect(sourceDropdown.exists()).toBe(true); expect(sourceDropdown.exists()).toBe(true);
expect(targetDropdown.exists()).toBe(true); expect(targetDropdown.exists()).toBe(true);
expect(sourceDropdown.find('a span').html()).toContain('latest version'); expect(sourceDropdown.find('a p').html()).toContain('latest version');
expect(targetDropdown.find('a span').html()).toContain(targetBranchName); expect(targetDropdown.find('button').html()).toContain(targetBranchName);
}); });
it('should not render comparison dropdowns if no mergeRequestDiffs are specified', () => { it('should not render comparison dropdowns if no mergeRequestDiffs are specified', () => {
......
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