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
2d89cf20
Commit
2d89cf20
authored
Nov 23, 2020
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Notifications for Clone quick_action
Adds email notifications for the new Clone quick-action
parent
2d7d9ef3
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
2 deletions
+79
-2
app/helpers/notify_helper.rb
app/helpers/notify_helper.rb
+2
-2
app/mailers/emails/issues.rb
app/mailers/emails/issues.rb
+10
-0
app/services/notification_service.rb
app/services/notification_service.rb
+10
-0
app/views/notify/issue_cloned_email.html.haml
app/views/notify/issue_cloned_email.html.haml
+7
-0
app/views/notify/issue_cloned_email.text.erb
app/views/notify/issue_cloned_email.text.erb
+8
-0
changelogs/unreleased/9421-clone-quickaction-notifications.yml
...elogs/unreleased/9421-clone-quickaction-notifications.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+6
-0
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+31
-0
No files found.
app/helpers/notify_helper.rb
View file @
2d89cf20
...
...
@@ -5,7 +5,7 @@ module NotifyHelper
link_to
(
entity
.
to_reference
,
merge_request_url
(
entity
,
*
args
))
end
def
issue_reference_link
(
entity
,
*
args
)
link_to
(
entity
.
to_reference
,
issue_url
(
entity
,
*
args
))
def
issue_reference_link
(
entity
,
*
args
,
full:
false
)
link_to
(
entity
.
to_reference
(
full:
full
)
,
issue_url
(
entity
,
*
args
))
end
end
app/mailers/emails/issues.rb
View file @
2d89cf20
...
...
@@ -80,6 +80,16 @@ module Emails
mail_answer_thread
(
issue
,
issue_thread_options
(
updated_by_user
.
id
,
recipient
.
id
,
reason
))
end
def
issue_cloned_email
(
recipient
,
issue
,
new_issue
,
updated_by_user
,
reason
=
nil
)
setup_issue_mail
(
issue
.
id
,
recipient
.
id
)
@author
=
updated_by_user
@issue
=
issue
@new_issue
=
new_issue
@can_access_project
=
recipient
.
can?
(
:read_project
,
@new_issue
.
project
)
mail_answer_thread
(
issue
,
issue_thread_options
(
updated_by_user
.
id
,
recipient
.
id
,
reason
))
end
def
import_issues_csv_email
(
user_id
,
project_id
,
results
)
@user
=
User
.
find
(
user_id
)
@project
=
Project
.
find
(
project_id
)
...
...
app/services/notification_service.rb
View file @
2d89cf20
...
...
@@ -504,6 +504,16 @@ class NotificationService
end
end
def
issue_cloned
(
issue
,
new_issue
,
current_user
)
recipients
=
NotificationRecipients
::
BuildService
.
build_recipients
(
issue
,
current_user
,
action:
'cloned'
)
recipients
.
map
do
|
recipient
|
email
=
mailer
.
issue_cloned_email
(
recipient
.
user
,
issue
,
new_issue
,
current_user
,
recipient
.
reason
)
email
.
deliver_later
email
end
end
def
project_exported
(
project
,
current_user
)
return
true
unless
notifiable?
(
current_user
,
:mention
,
project:
project
)
...
...
app/views/notify/issue_cloned_email.html.haml
0 → 100644
View file @
2d89cf20
-
author_link
=
link_to
@author
.
name
,
user_url
(
@author
)
-
if
@can_access_project
-
string
=
_
(
"%{author_link} cloned %{original_issue} to %{new_issue}."
).
html_safe
-
else
-
string
=
_
(
"%{author_link} cloned %{original_issue}. You don't have access to the new project."
).
html_safe
%p
=
string
%
{
author_link:
author_link
,
original_issue:
issue_reference_link
(
@issue
),
new_issue:
issue_reference_link
(
@new_issue
,
full:
true
)
}
app/views/notify/issue_cloned_email.text.erb
0 → 100644
View file @
2d89cf20
Issue was cloned.
<%
if
@can_access_project
%>
New issue location:
<%=
project_issue_url
(
@new_issue
.
project
,
@new_issue
)
%>
<%
else
%>
You don't have access to the project.
<%
end
%>
changelogs/unreleased/9421-clone-quickaction-notifications.yml
0 → 100644
View file @
2d89cf20
---
title
:
Added email notifications when an Issue is cloned
merge_request
:
48534
author
:
type
:
added
locale/gitlab.pot
View file @
2d89cf20
...
...
@@ -359,6 +359,12 @@ msgstr ""
msgid "%{anchorOpen}Learn more%{anchorClose} about how you can customize / disable registration on your instance."
msgstr ""
msgid "%{author_link} cloned %{original_issue} to %{new_issue}."
msgstr ""
msgid "%{author_link} cloned %{original_issue}. You don't have access to the new project."
msgstr ""
msgid "%{author_link} wrote:"
msgstr ""
...
...
spec/services/notification_service_spec.rb
View file @
2d89cf20
...
...
@@ -1549,6 +1549,37 @@ RSpec.describe NotificationService, :mailer do
end
end
describe
'#issue_cloned'
do
let
(
:new_issue
)
{
create
(
:issue
)
}
it
'sends email to issue notification recipients'
do
notification
.
issue_cloned
(
issue
,
new_issue
,
@u_disabled
)
should_email
(
issue
.
assignees
.
first
)
should_email
(
issue
.
author
)
should_email
(
@u_watcher
)
should_email
(
@u_guest_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
should_not_email
(
@u_lazy_participant
)
end
it_behaves_like
'participating notifications'
do
let
(
:participant
)
{
create
(
:user
,
username:
'user-participant'
)
}
let
(
:issuable
)
{
issue
}
let
(
:notification_trigger
)
{
notification
.
issue_cloned
(
issue
,
new_issue
,
@u_disabled
)
}
end
it_behaves_like
'project emails are disabled'
do
let
(
:notification_target
)
{
issue
}
let
(
:notification_trigger
)
{
notification
.
issue_cloned
(
issue
,
new_issue
,
@u_disabled
)
}
end
end
describe
'#issue_due'
do
before
do
issue
.
update!
(
due_date:
Date
.
today
)
...
...
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