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
fc828b40
Commit
fc828b40
authored
Oct 13, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed server rendered flash not being removed on click
parent
fe3ec2d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
+34
-2
app/assets/javascripts/flash.js
app/assets/javascripts/flash.js
+6
-1
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+7
-1
spec/javascripts/flash_spec.js
spec/javascripts/flash_spec.js
+21
-0
No files found.
app/assets/javascripts/flash.js
View file @
fc828b40
...
@@ -40,6 +40,10 @@ const createFlashEl = (message, type, isInContentWrapper = false) => `
...
@@ -40,6 +40,10 @@ const createFlashEl = (message, type, isInContentWrapper = false) => `
</div>
</div>
`
;
`
;
const
removeFlashClickListener
=
(
flashEl
,
fadeTransition
)
=>
{
flashEl
.
parentNode
.
addEventListener
(
'
click
'
,
()
=>
hideFlash
(
flashEl
,
fadeTransition
));
};
/*
/*
* Flash banner supports different types of Flash configurations
* Flash banner supports different types of Flash configurations
* along with ability to provide actionConfig which can be used to show
* along with ability to provide actionConfig which can be used to show
...
@@ -70,7 +74,7 @@ const createFlash = function createFlash(
...
@@ -70,7 +74,7 @@ const createFlash = function createFlash(
flashContainer
.
innerHTML
=
createFlashEl
(
message
,
type
,
isInContentWrapper
);
flashContainer
.
innerHTML
=
createFlashEl
(
message
,
type
,
isInContentWrapper
);
const
flashEl
=
flashContainer
.
querySelector
(
`.flash-
${
type
}
`
);
const
flashEl
=
flashContainer
.
querySelector
(
`.flash-
${
type
}
`
);
flashEl
.
addEventListener
(
'
click
'
,
()
=>
hideFlash
(
flashEl
,
fadeTransition
)
);
removeFlashClickListener
(
flashEl
,
fadeTransition
);
if
(
actionConfig
)
{
if
(
actionConfig
)
{
flashEl
.
innerHTML
+=
createAction
(
actionConfig
);
flashEl
.
innerHTML
+=
createAction
(
actionConfig
);
...
@@ -90,5 +94,6 @@ export {
...
@@ -90,5 +94,6 @@ export {
createFlashEl
,
createFlashEl
,
createAction
,
createAction
,
hideFlash
,
hideFlash
,
removeFlashClickListener
,
};
};
window
.
Flash
=
createFlash
;
window
.
Flash
=
createFlash
;
app/assets/javascripts/main.js
View file @
fc828b40
...
@@ -64,7 +64,7 @@ import './diff';
...
@@ -64,7 +64,7 @@ import './diff';
import
'
./dropzone_input
'
;
import
'
./dropzone_input
'
;
import
'
./due_date_select
'
;
import
'
./due_date_select
'
;
import
'
./files_comment_button
'
;
import
'
./files_comment_button
'
;
import
Flash
from
'
./flash
'
;
import
Flash
,
{
removeFlashClickListener
}
from
'
./flash
'
;
import
'
./gl_dropdown
'
;
import
'
./gl_dropdown
'
;
import
'
./gl_field_error
'
;
import
'
./gl_field_error
'
;
import
'
./gl_field_errors
'
;
import
'
./gl_field_errors
'
;
...
@@ -339,4 +339,10 @@ $(function () {
...
@@ -339,4 +339,10 @@ $(function () {
event
.
preventDefault
();
event
.
preventDefault
();
gl
.
utils
.
visitUrl
(
`
${
action
}${
$
(
this
).
serialize
()}
`
);
gl
.
utils
.
visitUrl
(
`
${
action
}${
$
(
this
).
serialize
()}
`
);
});
});
const
flashContainer
=
document
.
querySelector
(
'
.flash-container
'
);
if
(
flashContainer
&&
flashContainer
.
children
.
length
)
{
removeFlashClickListener
(
flashContainer
.
children
[
0
]);
}
});
});
spec/javascripts/flash_spec.js
View file @
fc828b40
...
@@ -2,6 +2,7 @@ import flash, {
...
@@ -2,6 +2,7 @@ import flash, {
createFlashEl
,
createFlashEl
,
createAction
,
createAction
,
hideFlash
,
hideFlash
,
removeFlashClickListener
,
}
from
'
~/flash
'
;
}
from
'
~/flash
'
;
describe
(
'
Flash
'
,
()
=>
{
describe
(
'
Flash
'
,
()
=>
{
...
@@ -266,4 +267,24 @@ describe('Flash', () => {
...
@@ -266,4 +267,24 @@ describe('Flash', () => {
});
});
});
});
});
});
describe
(
'
removeFlashClickListener
'
,
()
=>
{
beforeEach
(()
=>
{
document
.
body
.
innerHTML
+=
'
<div class="flash-container"><div class="flash"></div></div>
'
;
});
it
(
'
removes global flash on click
'
,
(
done
)
=>
{
const
flashEl
=
document
.
querySelector
(
'
.flash
'
);
removeFlashClickListener
(
flashEl
,
false
);
flashEl
.
parentNode
.
click
();
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.flash
'
)).
toBeNull
();
done
();
});
});
});
});
});
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