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
cbf4c4c6
Commit
cbf4c4c6
authored
Mar 17, 2022
by
John Mason
Committed by
Dylan Griffith
Mar 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track git blame clicks from code search results
Changelog: changed
parent
3235302b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
app/views/search/results/_blob_highlight.html.haml
app/views/search/results/_blob_highlight.html.haml
+7
-1
spec/views/search/_results.html.haml_spec.rb
spec/views/search/_results.html.haml_spec.rb
+25
-0
No files found.
app/views/search/results/_blob_highlight.html.haml
View file @
cbf4c4c6
...
...
@@ -10,7 +10,13 @@
.line-numbers
.gl-display-flex
%span
.diff-line-num.gl-pl-3
%a
.has-tooltip
{
href:
"#{blame_link}#L#{i}"
,
id:
"blame-L#{i}"
,
'data-line-number'
=>
i
,
title:
_
(
'View blame'
)
}
%a
.has-tooltip
{
href:
"#{blame_link}#L#{i}"
,
id:
"blame-L#{i}"
,
data:
{
"line_number"
=>
i
,
"track_action"
=>
'click_link'
,
"track_label"
=>
'git_blame'
,
"track_property"
=>
'search_result'
},
title:
_
(
'View blame'
)
}
=
sprite_icon
(
'git'
)
%span
.diff-line-num.flex-grow-1.gl-pr-3
%a
{
href:
"#{blob_link}#L#{i}"
,
id:
"blob-L#{i}"
,
'data-line-number'
=>
i
,
class:
'gl-display-flex! gl-align-items-center gl-justify-content-end'
}
...
...
spec/views/search/_results.html.haml_spec.rb
View file @
cbf4c4c6
...
...
@@ -96,6 +96,31 @@ RSpec.describe 'search/_results' do
end
end
describe
'git blame click tracking'
do
let
(
:scope
)
{
'blobs'
}
let
(
:search_objects
)
{
Gitlab
::
ProjectSearchResults
.
new
(
user
,
'testing'
,
project:
project
).
objects
(
scope
)
}
context
'when admin mode is enabled'
,
:enable_admin_mode
do
it
'renders the click link event tracking attributes'
do
render
expect
(
rendered
).
to
have_selector
(
'[data-track-action=click_link]'
)
expect
(
rendered
).
to
have_selector
(
'[data-track-label=git_blame]'
)
expect
(
rendered
).
to
have_selector
(
'[data-track-property=search_result]'
)
end
end
context
'when admin mode is disabled'
do
it
'does not render the click link event tracking attributes'
do
render
expect
(
rendered
).
not_to
have_selector
(
'[data-track-action=click_link]'
)
expect
(
rendered
).
not_to
have_selector
(
'[data-track-label=git_blame]'
)
expect
(
rendered
).
not_to
have_selector
(
'[data-track-property=search_result]'
)
end
end
end
%w[blobs notes wiki_blobs milestones]
.
each
do
|
search_scope
|
context
"when scope is
#{
search_scope
}
"
do
let
(
:scope
)
{
search_scope
}
...
...
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