Commit e7921d56 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'slashmanov/align-diff-expansion-buttons' into 'master'

Align Diff expansion footer buttons

See merge request gitlab-org/gitlab!79697
parents 05bd6e61 84f2c2fb
...@@ -223,25 +223,31 @@ export default { ...@@ -223,25 +223,31 @@ export default {
<template> <template>
<div class="content js-line-expansion-content"> <div class="content js-line-expansion-content">
<a <button
v-if="canExpandDown" type="button"
class="gl-mx-2 gl-cursor-pointer js-unfold-down gl-display-inline-block gl-py-4" :disabled="!canExpandDown"
class="js-unfold-down gl-mx-2 gl-py-4 gl-cursor-pointer"
@click="handleExpandLines(EXPAND_DOWN)" @click="handleExpandLines(EXPAND_DOWN)"
> >
<gl-icon :size="12" name="expand-down" /> <gl-icon :size="12" name="expand-down" />
<span>{{ $options.i18n.showMore }}</span> <span>{{ $options.i18n.showMore }}</span>
</a> </button>
<a class="gl-mx-2 cursor-pointer js-unfold-all" @click="handleExpandLines()"> <button
type="button"
class="js-unfold-all gl-mx-2 gl-py-4 gl-cursor-pointer"
@click="handleExpandLines()"
>
<gl-icon :size="12" name="expand" /> <gl-icon :size="12" name="expand" />
<span>{{ $options.i18n.showAll }}</span> <span>{{ $options.i18n.showAll }}</span>
</a> </button>
<a <button
v-if="canExpandUp" type="button"
class="gl-mx-2 gl-cursor-pointer js-unfold gl-display-inline-block gl-py-4" :disabled="!canExpandUp"
class="js-unfold gl-mx-2 gl-py-4 gl-cursor-pointer"
@click="handleExpandLines(EXPAND_UP)" @click="handleExpandLines(EXPAND_UP)"
> >
<gl-icon :size="12" name="expand-up" /> <gl-icon :size="12" name="expand-up" />
<span>{{ $options.i18n.showMore }}</span> <span>{{ $options.i18n.showMore }}</span>
</a> </button>
</div> </div>
</template> </template>
...@@ -582,6 +582,25 @@ table.code { ...@@ -582,6 +582,25 @@ table.code {
} }
} }
.diff-expansion-cell {
flex: 1 1;
min-width: max-content;
}
.diff-expansion-cell-middle {
flex: 0 1 max-content;
}
@media only screen and (min-width: $breakpoint-xl) {
.diff-expansion-cell-start {
text-align: right;
}
.diff-expansion-cell-end {
text-align: left;
}
}
// Merge request diff grid layout // Merge request diff grid layout
.diff-grid { .diff-grid {
.diff-td { .diff-td {
......
...@@ -28,8 +28,24 @@ ...@@ -28,8 +28,24 @@
border-bottom: 1px solid $border; border-bottom: 1px solid $border;
} }
a { button {
color: $link; color: $link;
border: 0;
background: transparent;
&[disabled] {
color: desaturate($link, 100%);
opacity: 0.5;
cursor: default;
}
&:hover:not([disabled]) {
text-decoration: underline;
}
&:not(:focus-visible) {
outline: 0;
}
} }
} }
......
...@@ -158,7 +158,7 @@ RSpec.describe 'User comments on a diff', :js do ...@@ -158,7 +158,7 @@ RSpec.describe 'User comments on a diff', :js do
it 'allows comments on previously hidden lines at the bottom of a file' do it 'allows comments on previously hidden lines at the bottom of a file' do
# Click +28, expand down, select 37 add and verify comment # Click +28, expand down, select 37 add and verify comment
page.within('[data-path="files/ruby/popen.rb"]') do page.within('[data-path="files/ruby/popen.rb"]') do
all('.js-unfold-down')[1].click all('.js-unfold-down:not([disabled])')[1].click
end end
click_diff_line(find('div[data-path="files/ruby/popen.rb"] .left-side a[data-linenumber="30"]').find(:xpath, '../..'), 'left') click_diff_line(find('div[data-path="files/ruby/popen.rb"] .left-side a[data-linenumber="30"]').find(:xpath, '../..'), 'left')
add_comment('+28', '37') add_comment('+28', '37')
......
...@@ -91,7 +91,9 @@ describe('DiffExpansionCell', () => { ...@@ -91,7 +91,9 @@ describe('DiffExpansionCell', () => {
}); });
expect(findExpandUp(wrapper).exists()).toBe(true); expect(findExpandUp(wrapper).exists()).toBe(true);
expect(findExpandDown(wrapper).exists()).toBe(false); expect(findExpandDown(wrapper).exists()).toBe(true);
expect(findExpandUp(wrapper).attributes('disabled')).not.toBeDefined();
expect(findExpandDown(wrapper).attributes('disabled')).toBeDefined();
expect(findExpandAll(wrapper)).not.toBe(null); expect(findExpandAll(wrapper)).not.toBe(null);
}); });
}); });
...@@ -112,8 +114,10 @@ describe('DiffExpansionCell', () => { ...@@ -112,8 +114,10 @@ describe('DiffExpansionCell', () => {
isBottom: true, isBottom: true,
}); });
expect(findExpandUp(wrapper).exists()).toBe(false);
expect(findExpandDown(wrapper).exists()).toBe(true); expect(findExpandDown(wrapper).exists()).toBe(true);
expect(findExpandUp(wrapper).exists()).toBe(true);
expect(findExpandDown(wrapper).attributes('disabled')).not.toBeDefined();
expect(findExpandUp(wrapper).attributes('disabled')).toBeDefined();
expect(findExpandAll(wrapper)).not.toBe(null); expect(findExpandAll(wrapper)).not.toBe(null);
}); });
}); });
......
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