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
b44a1bcd
Commit
b44a1bcd
authored
Aug 15, 2017
by
micael.bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rework the contributor badge
- only show in merge-requests - show as a little glyph
parent
45b83ed9
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
30 deletions
+41
-30
app/assets/stylesheets/pages/notes.scss
app/assets/stylesheets/pages/notes.scss
+14
-3
app/controllers/concerns/renders_notes.rb
app/controllers/concerns/renders_notes.rb
+4
-7
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+2
-2
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+5
-4
app/models/merge_request.rb
app/models/merge_request.rb
+5
-0
app/models/note.rb
app/models/note.rb
+5
-0
app/views/projects/notes/_actions.html.haml
app/views/projects/notes/_actions.html.haml
+4
-4
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+2
-10
No files found.
app/assets/stylesheets/pages/notes.scss
View file @
b44a1bcd
...
...
@@ -620,15 +620,26 @@ ul.notes {
.note-role
{
position
:
relative
;
padding
:
0
7px
;
display
:
inline-block
;
color
:
$notes-role-color
;
font-size
:
12px
;
line-height
:
20px
;
&
.note-role-access
{
top
:
-2px
;
padding
:
0
7px
;
border
:
1px
solid
$border-color
;
border-radius
:
$label-border-radius
;
}
&
.note-role-special
{
top
:
-3px
;
text-shadow
:
0
0
15px
white
;
}
}
/**
* Line note button on the side of diffs
*/
...
...
app/controllers/concerns/renders_notes.rb
View file @
b44a1bcd
...
...
@@ -2,7 +2,7 @@ module RendersNotes
def
prepare_notes_for_rendering
(
notes
,
noteable
=
nil
)
preload_noteable_for_regular_notes
(
notes
)
preload_max_access_for_authors
(
notes
,
@project
)
preload_first_time_contribution_for_authors
(
noteable
,
notes
)
if
noteable
.
is_a?
(
Issuable
)
preload_first_time_contribution_for_authors
(
noteable
,
notes
)
Banzai
::
NoteRenderer
.
render
(
notes
,
@project
,
current_user
)
notes
...
...
@@ -21,12 +21,9 @@ module RendersNotes
ActiveRecord
::
Associations
::
Preloader
.
new
.
preload
(
notes
.
reject
(
&
:for_commit?
),
:noteable
)
end
def
preload_first_time_contribution_for_authors
(
issu
able
,
notes
)
return
unless
issu
able
.
first_contribution?
def
preload_first_time_contribution_for_authors
(
note
able
,
notes
)
return
unless
noteable
.
is_a?
(
Issuable
)
&&
note
able
.
first_contribution?
same_author
=
lambda
{
|
n
|
n
.
author_id
==
issuable
.
author_id
}
notes
.
each
do
|
note
|
note
.
specialize!
(
Note
::
SpecialRole
::
FIRST_TIME_CONTRIBUTOR
,
&
same_author
)
end
notes
.
each
{
|
n
|
n
.
specialize_for_first_contribution!
(
noteable
)}
end
end
app/helpers/issuables_helper.rb
View file @
b44a1bcd
...
...
@@ -138,7 +138,7 @@ module IssuablesHelper
end
output
<<
" "
.
html_safe
output
<<
issuable_first_contribution_icon
if
issuable
.
first_contribution?
output
<<
content_tag
(
:span
,
(
issuable_first_contribution_icon
if
issuable
.
first_contribution?
),
class:
'has-tooltip'
,
title:
_
(
'1st contribution!'
))
output
<<
content_tag
(
:span
,
(
issuable
.
task_status
if
issuable
.
tasks?
),
id:
"task_status"
,
class:
"hidden-xs hidden-sm"
)
output
<<
content_tag
(
:span
,
(
issuable
.
task_status_short
if
issuable
.
tasks?
),
id:
"task_status_short"
,
class:
"hidden-md hidden-lg"
)
...
...
@@ -176,7 +176,7 @@ module IssuablesHelper
end
def
issuable_first_contribution_icon
content_tag
(
:span
,
class:
'fa-stack
has-tooltip'
,
title:
_
(
'1st contribution!'
)
)
do
content_tag
(
:span
,
class:
'fa-stack
'
)
do
concat
(
icon
(
'certificate'
,
class:
"fa-stack-2x"
))
concat
(
content_tag
(
:strong
,
'1'
,
class:
'fa-inverse fa-stack-1x'
))
end
...
...
app/models/concerns/issuable.rb
View file @
b44a1bcd
...
...
@@ -335,9 +335,10 @@ module Issuable
metrics
.
record!
end
def
first_contribution?
return
false
if
project
.
team
.
max_member_access
(
author_id
)
>
Gitlab
::
Access
::
GUEST
project
.
merge_requests
.
merged
.
where
(
author_id:
author_id
).
empty?
##
# Override in issuable specialization
#
def
first_contribution?
(
*
)
false
end
end
app/models/merge_request.rb
View file @
b44a1bcd
...
...
@@ -960,6 +960,11 @@ class MergeRequest < ActiveRecord::Base
Projects
::
OpenMergeRequestsCountService
.
new
(
target_project
).
refresh_cache
end
def
first_contribution?
(
*
)
return
false
if
project
.
team
.
max_member_access
(
author_id
)
>
Gitlab
::
Access
::
GUEST
project
.
merge_requests
.
merged
.
where
(
author_id:
author_id
).
empty?
end
private
def
write_ref
...
...
app/models/note.rb
View file @
b44a1bcd
...
...
@@ -237,6 +237,11 @@ class Note < ActiveRecord::Base
self
.
special_role
=
role
if
!
block_given?
||
yield
(
self
)
end
def
specialize_for_first_contribution!
(
noteable
)
return
unless
noteable
.
author_id
==
self
.
author_id
specialize!
(
Note
::
SpecialRole
::
FIRST_TIME_CONTRIBUTOR
)
end
def
editable?
!
system
?
end
...
...
app/views/projects/notes/_actions.html.haml
View file @
b44a1bcd
-
if
note
.
has_special_role?
(
Note
::
SpecialRole
::
FIRST_TIME_CONTRIBUTOR
)
%span
.note-role.has-tooltip
{
title:
_
(
"This user hasn't yet contributed code to this project. Handle with care."
)}
=
_
(
'First-time contributor'
)
-
els
if
access
=
note_max_access_for_user
(
note
)
%span
.note-role
=
Gitlab
::
Access
.
human_access
(
access
)
%span
.note-role.
note-role-special.
has-tooltip
{
title:
_
(
"This user hasn't yet contributed code to this project. Handle with care."
)}
=
issuable_first_contribution_icon
-
if
access
=
note_max_access_for_user
(
note
)
%span
.note-role
.note-role-access
=
Gitlab
::
Access
.
human_access
(
access
)
-
if
note
.
resolvable?
-
can_resolve
=
can?
(
current_user
,
:resolve_note
,
note
)
...
...
spec/models/concerns/issuable_spec.rb
View file @
b44a1bcd
...
...
@@ -539,20 +539,12 @@ describe Issuable do
context
"for issues"
do
let
(
:contributor_issue
)
{
create
(
:issue
,
author:
contributor
,
project:
project
)
}
let
(
:first_time_contributor_issue
)
{
create
(
:issue
,
author:
first_time_contributor
,
project:
project
)
}
let
(
:first_time_contributor_issue_other_project
)
{
create
(
:issue
,
author:
first_time_contributor
,
project:
other_project
)
}
it
"is
true when you don't have any
merged MR"
do
it
"is
false even without
merged MR"
do
expect
(
merged_mr
).
to
be
expect
(
first_time_contributor_issue
).
to
be_first_contribution
expect
(
first_time_contributor_issue
).
not_
to
be_first_contribution
expect
(
contributor_issue
).
not_to
be_first_contribution
end
it
"handles multiple projects separately"
do
expect
(
merged_mr
).
to
be
expect
(
merged_mr_other_project
).
to
be
expect
(
first_time_contributor_issue
).
to
be_first_contribution
expect
(
first_time_contributor_issue_other_project
).
not_to
be_first_contribution
end
end
end
end
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