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
8eec0924
Commit
8eec0924
authored
Sep 05, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sets callout dissmiss cookie per project using a path
parent
89e5bc5e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
6 deletions
+41
-6
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+4
-4
app/assets/javascripts/user_callout.js
app/assets/javascripts/user_callout.js
+10
-2
app/controllers/projects/application_controller.rb
app/controllers/projects/application_controller.rb
+1
-0
lib/gitlab/gon_helper.rb
lib/gitlab/gon_helper.rb
+4
-0
spec/javascripts/user_callout_spec.js
spec/javascripts/user_callout_spec.js
+22
-0
No files found.
app/assets/javascripts/dispatcher.js
View file @
8eec0924
...
@@ -156,7 +156,7 @@ import initChangesDropdown from './init_changes_dropdown';
...
@@ -156,7 +156,7 @@ import initChangesDropdown from './init_changes_dropdown';
new
UsersSelect
();
new
UsersSelect
();
break
;
break
;
case
'
projects:merge_requests:index
'
:
case
'
projects:merge_requests:index
'
:
new
UserCallout
();
new
UserCallout
(
{
setCalloutPerProject
:
true
}
);
break
;
break
;
case
'
projects:merge_requests:index
'
:
case
'
projects:merge_requests:index
'
:
case
'
projects:issues:index
'
:
case
'
projects:issues:index
'
:
...
@@ -346,7 +346,7 @@ import initChangesDropdown from './init_changes_dropdown';
...
@@ -346,7 +346,7 @@ import initChangesDropdown from './init_changes_dropdown';
case
'
projects:show
'
:
case
'
projects:show
'
:
shortcut_handler
=
new
ShortcutsNavigation
();
shortcut_handler
=
new
ShortcutsNavigation
();
new
NotificationsForm
();
new
NotificationsForm
();
new
UserCallout
();
new
UserCallout
(
{
setCalloutPerProject
:
true
}
);
if
(
$
(
'
#tree-slider
'
).
length
)
new
TreeView
();
if
(
$
(
'
#tree-slider
'
).
length
)
new
TreeView
();
if
(
$
(
'
.blob-viewer
'
).
length
)
new
BlobViewer
();
if
(
$
(
'
.blob-viewer
'
).
length
)
new
BlobViewer
();
...
@@ -367,7 +367,7 @@ import initChangesDropdown from './init_changes_dropdown';
...
@@ -367,7 +367,7 @@ import initChangesDropdown from './init_changes_dropdown';
new
NewBranchForm
(
$
(
'
.js-new-pipeline-form
'
));
new
NewBranchForm
(
$
(
'
.js-new-pipeline-form
'
));
break
;
break
;
case
'
projects:pipelines:index
'
:
case
'
projects:pipelines:index
'
:
new
UserCallout
();
new
UserCallout
(
{
setCalloutPerProject
:
true
}
);
break
;
break
;
case
'
projects:pipelines:builds
'
:
case
'
projects:pipelines:builds
'
:
case
'
projects:pipelines:failures
'
:
case
'
projects:pipelines:failures
'
:
...
@@ -426,7 +426,7 @@ import initChangesDropdown from './init_changes_dropdown';
...
@@ -426,7 +426,7 @@ import initChangesDropdown from './init_changes_dropdown';
new
TreeView
();
new
TreeView
();
new
BlobViewer
();
new
BlobViewer
();
new
NewCommitForm
(
$
(
'
.js-create-dir-form
'
));
new
NewCommitForm
(
$
(
'
.js-create-dir-form
'
));
new
UserCallout
();
new
UserCallout
(
{
setCalloutPerProject
:
true
}
);
$
(
'
#tree-slider
'
).
waitForImages
(
function
()
{
$
(
'
#tree-slider
'
).
waitForImages
(
function
()
{
gl
.
utils
.
ajaxGet
(
document
.
querySelector
(
'
.js-tree-content
'
).
dataset
.
logsPath
);
gl
.
utils
.
ajaxGet
(
document
.
querySelector
(
'
.js-tree-content
'
).
dataset
.
logsPath
);
});
});
...
...
app/assets/javascripts/user_callout.js
View file @
8eec0924
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
'
js-cookie
'
;
export
default
class
UserCallout
{
export
default
class
UserCallout
{
constructor
(
className
=
'
user-callout
'
)
{
constructor
(
options
=
{})
{
this
.
options
=
options
;
const
className
=
this
.
options
.
className
||
'
user-callout
'
;
this
.
userCalloutBody
=
$
(
`.
${
className
}
`
);
this
.
userCalloutBody
=
$
(
`.
${
className
}
`
);
this
.
cookieName
=
this
.
userCalloutBody
.
data
(
'
uid
'
);
this
.
cookieName
=
this
.
userCalloutBody
.
data
(
'
uid
'
);
this
.
isCalloutDismissed
=
Cookies
.
get
(
this
.
cookieName
);
this
.
isCalloutDismissed
=
Cookies
.
get
(
this
.
cookieName
);
...
@@ -17,7 +21,11 @@ export default class UserCallout {
...
@@ -17,7 +21,11 @@ export default class UserCallout {
dismissCallout
(
e
)
{
dismissCallout
(
e
)
{
const
$currentTarget
=
$
(
e
.
currentTarget
);
const
$currentTarget
=
$
(
e
.
currentTarget
);
Cookies
.
set
(
this
.
cookieName
,
'
true
'
,
{
expires
:
365
});
if
(
this
.
options
.
setCalloutPerProject
)
{
Cookies
.
set
(
this
.
cookieName
,
'
true
'
,
{
expires
:
365
,
path
:
gon
.
project_url
});
}
else
{
Cookies
.
set
(
this
.
cookieName
,
'
true
'
,
{
expires
:
365
});
}
if
(
$currentTarget
.
hasClass
(
'
close
'
))
{
if
(
$currentTarget
.
hasClass
(
'
close
'
))
{
this
.
userCalloutBody
.
remove
();
this
.
userCalloutBody
.
remove
();
...
...
app/controllers/projects/application_controller.rb
View file @
8eec0924
...
@@ -5,6 +5,7 @@ class Projects::ApplicationController < ApplicationController
...
@@ -5,6 +5,7 @@ class Projects::ApplicationController < ApplicationController
before_action
:redirect_git_extension
before_action
:redirect_git_extension
before_action
:project
before_action
:project
before_action
:repository
before_action
:repository
before_action
:add_gon_project_variables
layout
'project'
layout
'project'
helper_method
:repository
,
:can_collaborate_with_project?
helper_method
:repository
,
:can_collaborate_with_project?
...
...
lib/gitlab/gon_helper.rb
View file @
8eec0924
...
@@ -28,5 +28,9 @@ module Gitlab
...
@@ -28,5 +28,9 @@ module Gitlab
gon
.
current_user_avatar_url
=
current_user
.
avatar_url
gon
.
current_user_avatar_url
=
current_user
.
avatar_url
end
end
end
end
def
add_gon_project_variables
gon
.
project_url
=
project_url
(
project
)
end
end
end
end
end
spec/javascripts/user_callout_spec.js
View file @
8eec0924
...
@@ -33,4 +33,26 @@ describe('UserCallout', function () {
...
@@ -33,4 +33,26 @@ describe('UserCallout', function () {
this
.
userCalloutBtn
.
click
();
this
.
userCalloutBtn
.
click
();
expect
(
Cookies
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
expect
(
Cookies
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
});
});
describe
(
'
Sets cookie with setCalloutPerProject
'
,
()
=>
{
let
originalGon
;
beforeEach
(()
=>
{
originalGon
=
window
.
gon
;
window
.
gon
=
Object
.
assign
({},
{
project_url
:
'
http://localhost:3000/gitlab-org/gitlab-ce
'
,
});
this
.
userCallout
=
new
UserCallout
({
setCalloutPerProject
:
true
});
});
afterEach
(()
=>
{
window
.
gon
=
originalGon
;
});
it
(
'
sets a cookie when the user clicks the close button
'
,
()
=>
{
this
.
userCalloutBtn
.
click
();
// Note the path of a cookie is not accessible via JS, we can not test for that
// We can test if a cookie is set when an option is provided
expect
(
Cookies
.
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