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
fcd842b5
Commit
fcd842b5
authored
Oct 05, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed notes specs
changed how the container class is added onto the text element more specs
parent
cbfc97b1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
13 deletions
+33
-13
app/assets/javascripts/flash.js
app/assets/javascripts/flash.js
+6
-8
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+4
-4
spec/javascripts/flash_spec.js
spec/javascripts/flash_spec.js
+23
-1
No files found.
app/assets/javascripts/flash.js
View file @
fcd842b5
...
...
@@ -12,6 +12,7 @@ const hideFlash = (flashEl, fadeTransition = true) => {
flashEl
.
remove
();
},
{
once
:
true
,
passive
:
true
,
});
if
(
!
fadeTransition
)
flashEl
.
dispatchEvent
(
new
Event
(
'
transitionend
'
));
...
...
@@ -27,12 +28,12 @@ const createAction = config => `
</a>
`
;
const
createFlashEl
=
(
message
,
type
)
=>
`
const
createFlashEl
=
(
message
,
type
,
isInContentWrapper
=
false
)
=>
`
<div
class="flash-
${
type
}
"
>
<div
class="flash-text"
class="flash-text
${
isInContentWrapper
?
'
container-fluid container-limited
'
:
''
}
"
>
${
_
.
escape
(
message
)}
</div>
...
...
@@ -64,7 +65,9 @@ const createFlash = function createFlash(
if
(
!
flashContainer
)
return
null
;
flashContainer
.
innerHTML
=
createFlashEl
(
message
,
type
);
const
isInContentWrapper
=
flashContainer
.
parentNode
.
classList
.
contains
(
'
content-wrapper
'
);
flashContainer
.
innerHTML
=
createFlashEl
(
message
,
type
,
isInContentWrapper
);
const
flashEl
=
flashContainer
.
querySelector
(
`.flash-
${
type
}
`
);
flashEl
.
addEventListener
(
'
click
'
,
()
=>
hideFlash
(
flashEl
,
fadeTransition
));
...
...
@@ -77,11 +80,6 @@ const createFlash = function createFlash(
}
}
if
(
flashContainer
.
parentNode
.
classList
.
contains
(
'
content-wrapper
'
))
{
const
flashText
=
flashEl
.
querySelector
(
'
.flash-text
'
);
flashText
.
className
=
`
${
flashText
.
className
}
container-fluid container-limited`
;
}
flashContainer
.
style
.
display
=
'
block
'
;
return
flashContainer
;
...
...
app/assets/javascripts/notes.js
View file @
fcd842b5
...
...
@@ -1213,13 +1213,13 @@ export default class Notes {
}
addFlash
(...
flashParams
)
{
this
.
flash
Instance
=
new
Flash
(...
flashParams
);
this
.
flash
Container
=
new
Flash
(...
flashParams
);
}
clearFlash
()
{
if
(
this
.
flash
Instance
&&
this
.
flashInstance
.
flash
Container
)
{
this
.
flash
Instance
.
flashContainer
.
hide
()
;
this
.
flash
Instance
=
null
;
if
(
this
.
flashContainer
)
{
this
.
flash
Container
.
style
.
display
=
'
none
'
;
this
.
flash
Container
=
null
;
}
}
...
...
spec/javascripts/flash_spec.js
View file @
fcd842b5
...
...
@@ -31,6 +31,17 @@ describe('Flash', () => {
el
.
querySelector
(
'
.flash-text
'
).
textContent
.
trim
(),
).
toBe
(
'
<script>alert("a");</script>
'
);
});
it
(
'
adds container classes when inside content wrapper
'
,
()
=>
{
el
.
innerHTML
=
createFlashEl
(
'
testing
'
,
'
alert
'
,
true
);
expect
(
el
.
querySelector
(
'
.flash-text
'
).
classList
.
contains
(
'
container-fluid
'
),
).
toBeTruthy
();
expect
(
el
.
querySelector
(
'
.flash-text
'
).
classList
.
contains
(
'
container-limited
'
),
).
toBeTruthy
();
});
});
describe
(
'
hideFlash
'
,
()
=>
{
...
...
@@ -57,6 +68,17 @@ describe('Flash', () => {
).
toBe
(
'
0
'
);
});
it
(
'
does not set styles when fadeTransition is false
'
,
()
=>
{
hideFlash
(
el
,
false
);
expect
(
el
.
style
.
opacity
,
).
toBe
(
''
);
expect
(
el
.
style
.
transition
,
).
toBe
(
''
);
});
it
(
'
removes element after transitionend
'
,
()
=>
{
document
.
body
.
appendChild
(
el
);
...
...
@@ -192,7 +214,7 @@ describe('Flash', () => {
flash
(
'
test
'
);
expect
(
document
.
querySelector
(
'
.flash-text
'
).
className
,
document
.
querySelector
(
'
.flash-text
'
).
className
.
trim
()
,
).
toBe
(
'
flash-text
'
);
});
...
...
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