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
4d02fb67
Commit
4d02fb67
authored
Jun 28, 2019
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update label note to support scoped labels notes
- port of EE change
parent
3fd4c77e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
app/models/label_note.rb
app/models/label_note.rb
+13
-5
app/models/resource_label_event.rb
app/models/resource_label_event.rb
+5
-2
No files found.
app/models/label_note.rb
View file @
4d02fb67
...
...
@@ -62,19 +62,27 @@ class LabelNote < Note
end
def
note_text
(
html:
false
)
added
=
labels_str
(
'added'
,
label_refs_by_action
(
'add'
,
html
)
)
removed
=
labels_str
(
'removed'
,
label_refs_by_action
(
'remove'
,
html
)
)
added
=
labels_str
(
label_refs_by_action
(
'add'
,
html
),
prefix:
'added'
,
suffix:
added_suffix
)
removed
=
labels_str
(
label_refs_by_action
(
'remove'
,
html
),
prefix:
removed_prefix
)
[
added
,
removed
].
compact
.
join
(
' and '
)
end
def
removed_prefix
'removed'
end
def
added_suffix
''
end
# returns string containing added/removed labels including
# count of deleted labels:
#
# added ~1 ~2 + 1 deleted label
# added 3 deleted labels
# added ~1 ~2 labels
def
labels_str
(
prefix
,
label_refs
)
def
labels_str
(
label_refs
,
prefix:
''
,
suffix:
''
)
existing_refs
=
label_refs
.
select
{
|
ref
|
ref
.
present?
}.
sort
refs_str
=
existing_refs
.
empty?
?
nil
:
existing_refs
.
join
(
' '
)
...
...
@@ -84,9 +92,9 @@ class LabelNote < Note
return
unless
refs_str
||
deleted_str
label_list_str
=
[
refs_str
,
deleted_str
].
compact
.
join
(
' + '
)
suffix
=
'
label'
.
pluralize
(
deleted
>
0
?
deleted
:
existing_refs
.
count
)
suffix
+=
'
label'
.
pluralize
(
deleted
>
0
?
deleted
:
existing_refs
.
count
)
"
#{
prefix
}
#{
label_list_str
}
#{
suffix
}
"
"
#{
prefix
}
#{
label_list_str
}
#{
suffix
.
squish
}
"
end
def
label_refs_by_action
(
action
,
html
)
...
...
app/models/resource_label_event.rb
View file @
4d02fb67
...
...
@@ -36,10 +36,9 @@ class ResourceLabelEvent < ApplicationRecord
issue
||
merge_request
end
# create same discussion id for all actions with the same user and time
def
discussion_id
(
resource
=
nil
)
strong_memoize
(
:discussion_id
)
do
Digest
::
SHA1
.
hexdigest
(
[
self
.
class
.
name
,
created_at
,
user_id
]
.
join
(
"-"
))
Digest
::
SHA1
.
hexdigest
(
discussion_id_key
.
join
(
"-"
))
end
end
...
...
@@ -121,4 +120,8 @@ class ResourceLabelEvent < ApplicationRecord
def
resource_parent
issuable
.
project
||
issuable
.
group
end
def
discussion_id_key
[
self
.
class
.
name
,
created_at
,
user_id
]
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