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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
c07ee641
Commit
c07ee641
authored
Jun 04, 2018
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve modal prop interface
parent
5377e97d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
3 deletions
+41
-3
app/assets/javascripts/vue_shared/components/gl_modal.vue
app/assets/javascripts/vue_shared/components/gl_modal.vue
+8
-3
spec/javascripts/vue_shared/components/gl_modal_spec.js
spec/javascripts/vue_shared/components/gl_modal_spec.js
+33
-0
No files found.
app/assets/javascripts/vue_shared/components/gl_modal.vue
View file @
c07ee641
<
script
>
<
script
>
const
buttonVariants
=
[
'
danger
'
,
'
primary
'
,
'
success
'
,
'
warning
'
];
const
buttonVariants
=
[
'
danger
'
,
'
primary
'
,
'
success
'
,
'
warning
'
];
const
sizeVariants
=
[
'
sm
'
,
'
md
'
,
'
lg
'
];
export
default
{
export
default
{
name
:
'
GlModal
'
,
name
:
'
GlModal
'
,
props
:
{
props
:
{
id
:
{
id
:
{
type
:
String
,
type
:
String
,
...
@@ -14,6 +14,7 @@ export default {
...
@@ -14,6 +14,7 @@ export default {
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
default
:
'
md
'
,
default
:
'
md
'
,
validator
:
value
=>
sizeVariants
.
includes
(
value
),
},
},
headerTitleText
:
{
headerTitleText
:
{
type
:
String
,
type
:
String
,
...
@@ -32,7 +33,11 @@ export default {
...
@@ -32,7 +33,11 @@ export default {
default
:
''
,
default
:
''
,
},
},
},
},
computed
:
{
modalSizeClass
()
{
return
this
.
modalSize
===
'
md
'
?
''
:
`modal-
${
this
.
modalSize
}
`
;
},
},
methods
:
{
methods
:
{
emitCancel
(
event
)
{
emitCancel
(
event
)
{
this
.
$emit
(
'
cancel
'
,
event
);
this
.
$emit
(
'
cancel
'
,
event
);
...
@@ -53,7 +58,7 @@ export default {
...
@@ -53,7 +58,7 @@ export default {
>
>
<div
<div
class=
"modal-dialog"
class=
"modal-dialog"
:class=
"
`modal-$
{modalSize}`
"
:class=
"
modalSizeClass
"
role=
"document"
role=
"document"
>
>
<div
class=
"modal-content"
>
<div
class=
"modal-content"
>
...
...
spec/javascripts/vue_shared/components/gl_modal_spec.js
View file @
c07ee641
...
@@ -190,4 +190,37 @@ describe('GlModal', () => {
...
@@ -190,4 +190,37 @@ describe('GlModal', () => {
});
});
});
});
});
});
describe
(
'
handling sizes
'
,
()
=>
{
it
(
'
should render modal-sm
'
,
()
=>
{
vm
=
mountComponent
(
modalComponent
,
{
modalSize
:
'
sm
'
,
});
expect
(
vm
.
$el
.
querySelector
(
'
.modal-dialog
'
).
classList
.
contains
(
'
modal-sm
'
)).
toEqual
(
true
);
});
it
(
'
should render modal-lg
'
,
()
=>
{
vm
=
mountComponent
(
modalComponent
,
{
modalSize
:
'
lg
'
,
});
expect
(
vm
.
$el
.
querySelector
(
'
.modal-dialog
'
).
classList
.
contains
(
'
modal-lg
'
)).
toEqual
(
true
);
});
it
(
'
should not add modal size classes when md size is passed
'
,
()
=>
{
vm
=
mountComponent
(
modalComponent
,
{
modalSize
:
'
md
'
,
});
expect
(
vm
.
$el
.
querySelector
(
'
.modal-dialog
'
).
classList
.
contains
(
'
modal-md
'
)).
toEqual
(
false
);
});
it
(
'
should not add modal size classes by default
'
,
()
=>
{
vm
=
mountComponent
(
modalComponent
,
{});
expect
(
vm
.
$el
.
querySelector
(
'
.modal-dialog
'
).
classList
.
contains
(
'
modal-sm
'
)).
toEqual
(
false
);
expect
(
vm
.
$el
.
querySelector
(
'
.modal-dialog
'
).
classList
.
contains
(
'
modal-lg
'
)).
toEqual
(
false
);
});
});
});
});
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