Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
10441c65
Commit
10441c65
authored
Nov 23, 2020
by
jerasmus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace squash checkbox with glCheckbox
Replaced the squash checkbox with the glCheckbox
parent
dd13cc03
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
61 deletions
+23
-61
app/assets/javascripts/vue_merge_request_widget/components/states/squash_before_merge.vue
..._request_widget/components/states/squash_before_merge.vue
+10
-18
changelogs/unreleased/225275-add-glcheckbox-to-squah-commits.yml
...ogs/unreleased/225275-add-glcheckbox-to-squah-commits.yml
+5
-0
spec/frontend/vue_mr_widget/components/states/mr_widget_squash_before_merge_spec.js
...t/components/states/mr_widget_squash_before_merge_spec.js
+8
-43
No files found.
app/assets/javascripts/vue_merge_request_widget/components/states/squash_before_merge.vue
View file @
10441c65
<
script
>
import
{
GlIcon
,
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
,
GlTooltipDirective
,
GlFormCheckbox
}
from
'
@gitlab/ui
'
;
import
{
SQUASH_BEFORE_MERGE
}
from
'
../../i18n
'
;
export
default
{
components
:
{
GlIcon
,
GlFormCheckbox
,
},
directives
:
{
GlTooltip
:
GlTooltipDirective
,
...
...
@@ -32,32 +33,23 @@ export default {
tooltipTitle
()
{
return
this
.
isDisabled
?
this
.
$options
.
i18n
.
tooltipTitle
:
null
;
},
tooltipFocusable
()
{
return
this
.
isDisabled
?
'
0
'
:
null
;
},
},
};
</
script
>
<
template
>
<div
class=
"
inline
"
>
<
label
<div
class=
"
gl-display-flex gl-align-items-center
"
>
<
gl-form-checkbox
v-gl-tooltip
:class=
"
{ 'gl-text-gray-400': isDisabled }"
:tabindex="tooltipFocusable"
data-testid="squashLabel"
:checked=
"value"
:disabled=
"isDisabled"
name=
"squash"
class=
"qa-squash-checkbox js-squash-checkbox gl-mb-0 gl-mr-2"
:title=
"tooltipTitle"
@
change=
"checked => $emit('input', checked)"
>
<input
:checked=
"value"
:disabled=
"isDisabled"
type=
"checkbox"
name=
"squash"
class=
"qa-squash-checkbox js-squash-checkbox"
@
change=
"$emit('input', $event.target.checked)"
/>
{{
$options
.
i18n
.
checkboxLabel
}}
</
label
>
</
gl-form-checkbox
>
<a
v-if=
"helpPath"
v-gl-tooltip
...
...
changelogs/unreleased/225275-add-glcheckbox-to-squah-commits.yml
0 → 100644
View file @
10441c65
---
title
:
Add GlFormCheckbox to squash commits
merge_request
:
48338
author
:
type
:
changed
spec/frontend/vue_mr_widget/components/states/mr_widget_squash_before_merge_spec.js
View file @
10441c65
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlFormCheckbox
}
from
'
@gitlab/ui
'
;
import
SquashBeforeMerge
from
'
~/vue_merge_request_widget/components/states/squash_before_merge.vue
'
;
import
{
SQUASH_BEFORE_MERGE
}
from
'
~/vue_merge_request_widget/i18n
'
;
...
...
@@ -20,17 +21,15 @@ describe('Squash before merge component', () => {
wrapper
.
destroy
();
});
const
find
Label
=
()
=>
wrapper
.
find
(
'
[data-testid="squashLabel"]
'
);
const
find
Checkbox
=
()
=>
wrapper
.
find
(
GlFormCheckbox
);
describe
(
'
checkbox
'
,
()
=>
{
const
findCheckbox
=
()
=>
wrapper
.
find
(
'
.js-squash-checkbox
'
);
it
(
'
is unchecked if passed value prop is false
'
,
()
=>
{
createComponent
({
value
:
false
,
});
expect
(
findCheckbox
().
element
.
checked
).
toBeFalsy
(
);
expect
(
findCheckbox
().
vm
.
$attrs
.
checked
).
toBe
(
false
);
});
it
(
'
is checked if passed value prop is true
'
,
()
=>
{
...
...
@@ -38,22 +37,7 @@ describe('Squash before merge component', () => {
value
:
true
,
});
expect
(
findCheckbox
().
element
.
checked
).
toBeTruthy
();
});
it
(
'
changes value on click
'
,
done
=>
{
createComponent
({
value
:
false
,
});
findCheckbox
().
element
.
checked
=
true
;
findCheckbox
().
trigger
(
'
change
'
);
wrapper
.
vm
.
$nextTick
(()
=>
{
expect
(
findCheckbox
().
element
.
checked
).
toBeTruthy
();
done
();
});
expect
(
findCheckbox
().
vm
.
$attrs
.
checked
).
toBe
(
true
);
});
it
(
'
is disabled if isDisabled prop is true
'
,
()
=>
{
...
...
@@ -62,31 +46,12 @@ describe('Squash before merge component', () => {
isDisabled
:
true
,
});
expect
(
findCheckbox
().
attributes
(
'
disabled
'
)).
toBeTruthy
();
});
});
describe
(
'
label
'
,
()
=>
{
describe
.
each
`
isDisabled | expectation
${
true
}
|
${
'
grays out text if it is true
'
}
${
false
}
|
${
'
does not gray out text if it is false
'
}
`
(
'
isDisabled prop
'
,
({
isDisabled
,
expectation
})
=>
{
beforeEach
(()
=>
{
createComponent
({
value
:
false
,
isDisabled
,
});
});
it
(
expectation
,
()
=>
{
expect
(
findLabel
().
classes
(
'
gl-text-gray-400
'
)).
toBe
(
isDisabled
);
});
expect
(
findCheckbox
().
vm
.
$attrs
.
disabled
).
toBe
(
true
);
});
});
describe
(
'
tooltip
'
,
()
=>
{
const
tooltipTitle
=
()
=>
find
Label
().
attributes
(
'
title
'
);
const
tooltipTitle
=
()
=>
find
Checkbox
().
attributes
(
'
title
'
);
it
(
'
does not render when isDisabled is false
'
,
()
=>
{
createComponent
({
...
...
@@ -114,7 +79,7 @@ describe('Squash before merge component', () => {
const
aboutLink
=
wrapper
.
find
(
'
a
'
);
expect
(
aboutLink
.
exists
()).
toBe
Falsy
(
);
expect
(
aboutLink
.
exists
()).
toBe
(
false
);
});
it
(
'
is rendered if help path is passed
'
,
()
=>
{
...
...
@@ -125,7 +90,7 @@ describe('Squash before merge component', () => {
const
aboutLink
=
wrapper
.
find
(
'
a
'
);
expect
(
aboutLink
.
exists
()).
toBe
Truthy
(
);
expect
(
aboutLink
.
exists
()).
toBe
(
true
);
});
it
(
'
should have a correct help path if passed
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment