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
323596f6
Commit
323596f6
authored
Apr 29, 2017
by
blackst0ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add system note on description change of issue/merge request
parent
4faa65d8
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
3 deletions
+47
-3
app/helpers/system_note_helper.rb
app/helpers/system_note_helper.rb
+1
-0
app/models/system_note_metadata.rb
app/models/system_note_metadata.rb
+1
-1
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+8
-0
app/services/system_note_service.rb
app/services/system_note_service.rb
+17
-0
app/views/projects/issues/show.html.haml
app/views/projects/issues/show.html.haml
+1
-1
app/views/projects/merge_requests/show/_mr_box.html.haml
app/views/projects/merge_requests/show/_mr_box.html.haml
+1
-1
changelogs/unreleased/add_system_note_for_editing_issuable.yml
...elogs/unreleased/add_system_note_for_editing_issuable.yml
+4
-0
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+14
-0
No files found.
app/helpers/system_note_helper.rb
View file @
323596f6
module
SystemNoteHelper
module
SystemNoteHelper
ICON_NAMES_BY_ACTION
=
{
ICON_NAMES_BY_ACTION
=
{
'commit'
=>
'icon_commit'
,
'commit'
=>
'icon_commit'
,
'description'
=>
'icon_edit'
,
'merge'
=>
'icon_merge'
,
'merge'
=>
'icon_merge'
,
'merged'
=>
'icon_merged'
,
'merged'
=>
'icon_merged'
,
'opened'
=>
'icon_status_open'
,
'opened'
=>
'icon_status_open'
,
...
...
app/models/system_note_metadata.rb
View file @
323596f6
class
SystemNoteMetadata
<
ActiveRecord
::
Base
class
SystemNoteMetadata
<
ActiveRecord
::
Base
ICON_TYPES
=
%w[
ICON_TYPES
=
%w[
commit merge confidential visible label assignee cross_reference
commit
description
merge confidential visible label assignee cross_reference
title time_tracking branch milestone discussion task moved opened closed merged
title time_tracking branch milestone discussion task moved opened closed merged
]
.
freeze
]
.
freeze
...
...
app/services/issuable_base_service.rb
View file @
323596f6
...
@@ -24,6 +24,10 @@ class IssuableBaseService < BaseService
...
@@ -24,6 +24,10 @@ class IssuableBaseService < BaseService
issuable
,
issuable
.
project
,
current_user
,
old_title
)
issuable
,
issuable
.
project
,
current_user
,
old_title
)
end
end
def
create_description_change_note
(
issuable
)
SystemNoteService
.
change_description
(
issuable
,
issuable
.
project
,
current_user
)
end
def
create_branch_change_note
(
issuable
,
branch_type
,
old_branch
,
new_branch
)
def
create_branch_change_note
(
issuable
,
branch_type
,
old_branch
,
new_branch
)
SystemNoteService
.
change_branch
(
SystemNoteService
.
change_branch
(
issuable
,
issuable
.
project
,
current_user
,
branch_type
,
issuable
,
issuable
.
project
,
current_user
,
branch_type
,
...
@@ -289,6 +293,10 @@ class IssuableBaseService < BaseService
...
@@ -289,6 +293,10 @@ class IssuableBaseService < BaseService
create_title_change_note
(
issuable
,
issuable
.
previous_changes
[
'title'
].
first
)
create_title_change_note
(
issuable
,
issuable
.
previous_changes
[
'title'
].
first
)
end
end
if
issuable
.
previous_changes
.
include?
(
'description'
)
create_description_change_note
(
issuable
)
end
if
issuable
.
previous_changes
.
include?
(
'description'
)
&&
issuable
.
tasks?
if
issuable
.
previous_changes
.
include?
(
'description'
)
&&
issuable
.
tasks?
create_task_status_note
(
issuable
)
create_task_status_note
(
issuable
)
end
end
...
...
app/services/system_note_service.rb
View file @
323596f6
...
@@ -261,6 +261,23 @@ module SystemNoteService
...
@@ -261,6 +261,23 @@ module SystemNoteService
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'title'
))
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'title'
))
end
end
# Called when the description of a Noteable is changed
#
# noteable - Noteable object that responds to `description`
# project - Project owning noteable
# author - User performing the change
#
# Example Note text:
#
# "changed the description"
#
# Returns the created Note object
def
change_description
(
noteable
,
project
,
author
)
body
=
"changed the description"
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'description'
))
end
# Called when the confidentiality changes
# Called when the confidentiality changes
#
#
# issue - Issue object
# issue - Issue object
...
...
app/views/projects/issues/show.html.haml
View file @
323596f6
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
=
markdown_field
(
@issue
,
:description
)
=
markdown_field
(
@issue
,
:description
)
%textarea
.hidden.js-task-list-field
%textarea
.hidden.js-task-list-field
=
@issue
.
description
=
@issue
.
description
=
edited_time_ago_with_tooltip
(
@issue
,
placement:
'bottom'
,
html_class:
'issue_edited_ago'
)
=
edited_time_ago_with_tooltip
(
@issue
,
placement:
'bottom'
,
html_class:
'issue_edited_ago'
,
include_author:
true
)
#merge-requests
{
data:
{
url:
referenced_merge_requests_namespace_project_issue_url
(
@project
.
namespace
,
@project
,
@issue
)
}
}
#merge-requests
{
data:
{
url:
referenced_merge_requests_namespace_project_issue_url
(
@project
.
namespace
,
@project
,
@issue
)
}
}
// This element is filled in using JavaScript.
// This element is filled in using JavaScript.
...
...
app/views/projects/merge_requests/show/_mr_box.html.haml
View file @
323596f6
...
@@ -10,4 +10,4 @@
...
@@ -10,4 +10,4 @@
%textarea
.hidden.js-task-list-field
%textarea
.hidden.js-task-list-field
=
@merge_request
.
description
=
@merge_request
.
description
=
edited_time_ago_with_tooltip
(
@merge_request
,
placement:
'bottom'
)
=
edited_time_ago_with_tooltip
(
@merge_request
,
placement:
'bottom'
,
include_author:
true
)
changelogs/unreleased/add_system_note_for_editing_issuable.yml
0 → 100644
View file @
323596f6
---
title
:
Add system note on description change of issue/merge request
merge_request
:
10392
author
:
blackst0ne
spec/services/system_note_service_spec.rb
View file @
323596f6
...
@@ -292,6 +292,20 @@ describe SystemNoteService, services: true do
...
@@ -292,6 +292,20 @@ describe SystemNoteService, services: true do
end
end
end
end
describe
'.change_description'
do
subject
{
described_class
.
change_description
(
noteable
,
project
,
author
)
}
context
'when noteable responds to `description`'
do
it_behaves_like
'a system note'
do
let
(
:action
)
{
'description'
}
end
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
'changed the description'
end
end
end
describe
'.change_issue_confidentiality'
do
describe
'.change_issue_confidentiality'
do
subject
{
described_class
.
change_issue_confidentiality
(
noteable
,
project
,
author
)
}
subject
{
described_class
.
change_issue_confidentiality
(
noteable
,
project
,
author
)
}
...
...
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