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
Jérome Perrin
gitlab-ce
Commits
2f681138
Commit
2f681138
authored
Feb 23, 2017
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified the user_callout behaviour
Now it appends a template instead of relying in a partial to show it.
parent
621bfdaa
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
45 deletions
+44
-45
app/assets/javascripts/user_callout.js
app/assets/javascripts/user_callout.js
+35
-10
app/assets/stylesheets/pages/profile.scss
app/assets/stylesheets/pages/profile.scss
+0
-1
app/views/dashboard/projects/index.html.haml
app/views/dashboard/projects/index.html.haml
+1
-1
app/views/shared/_user_callout.html.haml
app/views/shared/_user_callout.html.haml
+0
-14
app/views/users/show.html.haml
app/views/users/show.html.haml
+2
-2
spec/javascripts/fixtures/user_callout.html.haml
spec/javascripts/fixtures/user_callout.html.haml
+2
-13
spec/javascripts/user_callout_spec.js
spec/javascripts/user_callout_spec.js
+4
-4
No files found.
app/assets/javascripts/user_callout.js
View file @
2f681138
...
@@ -4,29 +4,54 @@
...
@@ -4,29 +4,54 @@
const
userCalloutElementName
=
'
.user-callout
'
;
const
userCalloutElementName
=
'
.user-callout
'
;
const
closeButton
=
'
.close-user-callout
'
;
const
closeButton
=
'
.close-user-callout
'
;
const
userCalloutBtn
=
'
.user-callout-btn
'
;
const
userCalloutBtn
=
'
.user-callout-btn
'
;
const
userCalloutSvgAttrName
=
'
callout-svg
'
;
const
USER_CALLOUT_COOKIE
=
'
user_callout_dismissed
'
;
const
USER_CALLOUT_COOKIE
=
'
user_callout_dismissed
'
;
const
USER_CALLOUT_TEMPLATE
=
`
<div class="bordered-box landing content-block">
<button class="btn btn-default close close-user-callout" type="button">
<i class="fa fa-times dismiss-icon"></i>
</button>
<div class="row">
<div class="col-sm-3 col-xs-12 svg-container">
</div>
<div class="col-sm-8 col-xs-12 inner-content">
<h4>
Customize your experience
</h4>
<p>
Change syntax themes, default project pages, and more in preferences.
</p>
<a class="btn user-callout-btn" href="/profile/preferences">Check it out</a>
</div>
</div>
</div>`
;
class
UserCallout
{
class
UserCallout
{
constructor
()
{
constructor
()
{
this
.
isCalloutDismissed
=
Cookies
.
get
(
USER_CALLOUT_COOKIE
);
this
.
isCalloutDismissed
=
Cookies
.
get
(
USER_CALLOUT_COOKIE
);
this
.
userCalloutBody
=
$
(
userCalloutElementName
);
this
.
userCalloutSvg
=
$
(
userCalloutElementName
).
attr
(
userCalloutSvgAttrName
);
$
(
userCalloutElementName
).
removeAttr
(
userCalloutSvgAttrName
);
this
.
init
();
this
.
init
();
this
.
toggleUserCallout
();
}
}
init
()
{
init
()
{
$
(
document
)
const
$template
=
$
(
USER_CALLOUT_TEMPLATE
);
.
on
(
'
click
'
,
closeButton
,
()
=>
this
.
dismissCallout
())
if
(
!
this
.
isCalloutDismissed
||
this
.
isCalloutDismissed
===
'
false
'
)
{
.
on
(
'
click
'
,
userCalloutBtn
,
()
=>
this
.
dismissCallout
());
$template
.
find
(
'
.svg-container
'
).
append
(
this
.
userCalloutSvg
);
this
.
userCalloutBody
.
append
(
$template
);
$template
.
find
(
closeButton
).
on
(
'
click
'
,
e
=>
this
.
dismissCallout
(
e
));
$template
.
find
(
userCalloutBtn
).
on
(
'
click
'
,
e
=>
this
.
dismissCallout
(
e
));
}
}
}
dismissCallout
()
{
dismissCallout
(
e
)
{
Cookies
.
set
(
USER_CALLOUT_COOKIE
,
'
true
'
);
Cookies
.
set
(
USER_CALLOUT_COOKIE
,
'
true
'
);
}
const
$currentTarget
=
$
(
e
.
currentTarget
);
if
(
$currentTarget
.
hasClass
(
'
close-user-callout
'
))
{
toggleUserCallout
()
{
this
.
userCalloutBody
.
empty
();
if
(
!
this
.
isCalloutDismissed
)
{
$
(
userCalloutElementName
).
show
();
}
}
}
}
}
}
...
...
app/assets/stylesheets/pages/profile.scss
View file @
2f681138
...
@@ -279,7 +279,6 @@ table.u2f-registrations {
...
@@ -279,7 +279,6 @@ table.u2f-registrations {
}
}
.user-callout
{
.user-callout
{
display
:
none
;
margin
:
24px
auto
0
;
margin
:
24px
auto
0
;
.bordered-box
{
.bordered-box
{
...
...
app/views/dashboard/projects/index.html.haml
View file @
2f681138
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
-
page_title
"Projects"
-
page_title
"Projects"
-
header_title
"Projects"
,
dashboard_projects_path
-
header_title
"Projects"
,
dashboard_projects_path
=
render
partial:
'shared/user_callout'
.user-callout
{
'callout-svg'
=>
custom_icon
(
'icon_customization'
)
}
-
if
@projects
.
any?
||
params
[
:filter_projects
]
-
if
@projects
.
any?
||
params
[
:filter_projects
]
=
render
'dashboard/projects_head'
=
render
'dashboard/projects_head'
...
...
app/views/shared/_user_callout.html.haml
deleted
100644 → 0
View file @
621bfdaa
.user-callout
.bordered-box.landing.content-block
%button
.btn.btn-default.close.close-user-callout
{
type:
"button"
}
=
icon
(
"times"
,
class:
"dismiss-icon"
)
.row
.col-sm-3.col-xs-12.svg-container
=
custom_icon
(
'icon_customization'
)
.col-sm-8.col-xs-12.inner-content
%h4
Customize your experience
%p
Change syntax themes, default project pages, and more in preferences.
=
link_to
"Check it out"
,
profile_preferences_path
,
class:
'btn user-callout-btn'
app/views/users/show.html.haml
View file @
2f681138
...
@@ -96,9 +96,9 @@
...
@@ -96,9 +96,9 @@
%li
.js-snippets-tab
%li
.js-snippets-tab
=
link_to
user_snippets_path
,
data:
{
target:
'div#snippets'
,
action:
'snippets'
,
toggle:
'tab'
}
do
=
link_to
user_snippets_path
,
data:
{
target:
'div#snippets'
,
action:
'snippets'
,
toggle:
'tab'
}
do
Snippets
Snippets
%div
{
class:
container_class
}
%div
{
class:
container_class
}
=
render
partial:
'shared/user_callout'
.user-callout
{
'callout-svg'
=>
custom_icon
(
'icon_customization'
)
}
.tab-content
.tab-content
#activity
.tab-pane
#activity
.tab-pane
.row-content-block.calender-block.white.second-block.hidden-xs
.row-content-block.calender-block.white.second-block.hidden-xs
...
...
spec/javascripts/fixtures/user_callout.html.haml
View file @
2f681138
.user-callout
.user-callout
{
'callout-svg'
=>
custom_icon
(
'icon_customization'
)
}
.bordered-box.landing.content-block
%button
.btn.btn-default.close.close-user-callout
{
type:
"button"
}
%i
.fa.fa-times.dismiss-icon
.row
.col-sm-3.col-xs-12.svg-container
.col-sm-8.col-xs-12.inner-content
%h4
Customize your experience
%p
Change syntax themes, default project pages, and more in preferences.
%a
{
href:
'foo'
,
class
:'user-callout-btn'
}
Check it out
spec/javascripts/user_callout_spec.js
View file @
2f681138
...
@@ -11,22 +11,22 @@ describe('UserCallout', function () {
...
@@ -11,22 +11,22 @@ describe('UserCallout', function () {
loadFixtures
(
fixtureName
);
loadFixtures
(
fixtureName
);
this
.
userCallout
=
new
UserCallout
();
this
.
userCallout
=
new
UserCallout
();
this
.
closeButton
=
$
(
'
.close-user-callout
'
);
this
.
closeButton
=
$
(
'
.close-user-callout
'
);
this
.
userCalloutContainer
=
$
(
'
.user-callout
'
);
this
.
userCalloutBtn
=
$
(
'
.user-callout-btn
'
);
this
.
userCalloutBtn
=
$
(
'
.user-callout-btn
'
);
this
.
userCalloutContainer
=
$
(
'
.user-callout
'
);
Cookie
.
set
(
USER_CALLOUT_COOKIE
,
'
false
'
);
Cookie
.
set
(
USER_CALLOUT_COOKIE
,
'
false
'
);
});
});
it
(
'
shows when cookie is set to false
'
,
()
=>
{
f
it
(
'
shows when cookie is set to false
'
,
()
=>
{
expect
(
Cookie
.
get
(
USER_CALLOUT_COOKIE
)).
toBeDefined
();
expect
(
Cookie
.
get
(
USER_CALLOUT_COOKIE
)).
toBeDefined
();
expect
(
this
.
userCalloutContainer
.
is
(
'
:visible
'
)).
toBe
(
true
);
expect
(
this
.
userCalloutContainer
.
is
(
'
:visible
'
)).
toBe
(
true
);
});
});
it
(
'
hides when user clicks on the dismiss-icon
'
,
()
=>
{
f
it
(
'
hides when user clicks on the dismiss-icon
'
,
()
=>
{
this
.
closeButton
.
click
();
this
.
closeButton
.
click
();
expect
(
Cookie
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
expect
(
Cookie
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
});
});
it
(
'
hides when user clicks on the "check it out" button
'
,
()
=>
{
f
it
(
'
hides when user clicks on the "check it out" button
'
,
()
=>
{
this
.
userCalloutBtn
.
click
();
this
.
userCalloutBtn
.
click
();
expect
(
Cookie
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
expect
(
Cookie
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
});
});
...
...
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