summaryrefslogtreecommitdiff
path: root/app/views/notify
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-03-15 18:14:58 -0600
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-05 17:44:14 +0100
commitf6f6aaf593dc40c79b8e3536f5e2821c96b9dcd3 (patch)
tree2291c4c92889f11e1bdbabe640205debb1e88029 /app/views/notify
parent76aa0bedd7ed3aaaeab9402b78261917df66de10 (diff)
downloadgitlab-ce-f6f6aaf593dc40c79b8e3536f5e2821c96b9dcd3.tar.gz
Better notification emails for notes and (diff) discussions
Diffstat (limited to 'app/views/notify')
-rw-r--r--app/views/notify/_note_email.html.haml36
-rw-r--r--app/views/notify/_note_email.text.erb25
-rw-r--r--app/views/notify/_note_message.html.haml5
-rw-r--r--app/views/notify/_note_message.text.erb5
-rw-r--r--app/views/notify/_note_mr_or_commit_email.html.haml18
-rw-r--r--app/views/notify/_note_mr_or_commit_email.text.erb8
-rw-r--r--app/views/notify/_simple_diff.text.erb3
-rw-r--r--app/views/notify/note_commit_email.html.haml3
-rw-r--r--app/views/notify/note_commit_email.text.erb3
-rw-r--r--app/views/notify/note_issue_email.html.haml2
-rw-r--r--app/views/notify/note_issue_email.text.erb10
-rw-r--r--app/views/notify/note_merge_request_email.html.haml3
-rw-r--r--app/views/notify/note_merge_request_email.text.erb3
-rw-r--r--app/views/notify/note_personal_snippet_email.html.haml2
-rw-r--r--app/views/notify/note_personal_snippet_email.text.erb9
-rw-r--r--app/views/notify/note_snippet_email.html.haml2
-rw-r--r--app/views/notify/note_snippet_email.text.erb9
17 files changed, 71 insertions, 75 deletions
diff --git a/app/views/notify/_note_email.html.haml b/app/views/notify/_note_email.html.haml
new file mode 100644
index 00000000000..8b139a150b7
--- /dev/null
+++ b/app/views/notify/_note_email.html.haml
@@ -0,0 +1,36 @@
+- if @discussion
+ %p.details
+ = succeed ':' do
+ = link_to @note.author_name, user_url(@note.author)
+
+ - if @discussion.diff_discussion?
+ - if @discussion.new_discussion?
+ started a new discussion
+ - else
+ commented on a discussion
+
+ on #{link_to @discussion.file_path, @target_url}
+ - else
+ - if @discussion.new_discussion?
+ started a new discussion
+ - else
+ commented on a #{link_to 'discussion', @target_url}
+
+- elsif current_application_settings.email_author_in_body
+ %p.details
+ #{link_to @note.author_name, user_url(@note.author)} commented:
+
+- if @discussion&.diff_discussion?
+ = content_for :head do
+ = stylesheet_link_tag 'mailers/highlighted_diff_email'
+
+ %table
+ = render partial: "projects/diffs/line",
+ collection: @discussion.truncated_diff_lines,
+ as: :line,
+ locals: { diff_file: @discussion.diff_file,
+ plain: true,
+ email: true }
+
+%div
+ = markdown(@note.note, pipeline: :email, author: @note.author)
diff --git a/app/views/notify/_note_email.text.erb b/app/views/notify/_note_email.text.erb
new file mode 100644
index 00000000000..f2db321859f
--- /dev/null
+++ b/app/views/notify/_note_email.text.erb
@@ -0,0 +1,25 @@
+<% if @discussion -%>
+<%= @note.author_name -%>
+<% if @discussion.new_discussion? -%>
+<%= " started a new discussion" -%>
+<% else -%>
+<%= " commented on a discussion" -%>
+<% end -%>
+<% if @discussion.diff_discussion? -%>
+<%= " on #{@discussion.file_path}" -%>
+<% end -%>
+<%= ":" -%>
+
+
+<% elsif current_application_settings.email_author_in_body -%>
+<%= "#{@note.author_name} commented:" -%>
+
+
+<% end -%>
+<% if @discussion&.diff_discussion? -%>
+<% @discussion.truncated_diff_lines(highlight: false).each do |line| -%>
+<%= "> #{line.text}\n" -%>
+<% end -%>
+
+<% end -%>
+<%= @note.note -%>
diff --git a/app/views/notify/_note_message.html.haml b/app/views/notify/_note_message.html.haml
deleted file mode 100644
index e9c66170877..00000000000
--- a/app/views/notify/_note_message.html.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-- if current_application_settings.email_author_in_body
- %div
- #{link_to @note.author_name, user_url(@note.author)} wrote:
-%div
- = markdown(@note.note, pipeline: :email, author: @note.author)
diff --git a/app/views/notify/_note_message.text.erb b/app/views/notify/_note_message.text.erb
deleted file mode 100644
index f82cbc9a3fc..00000000000
--- a/app/views/notify/_note_message.text.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<% if current_application_settings.email_author_in_body %>
- <%= @note.author_name %> wrote:
-<% end -%>
-
-<%= @note.note %>
diff --git a/app/views/notify/_note_mr_or_commit_email.html.haml b/app/views/notify/_note_mr_or_commit_email.html.haml
deleted file mode 100644
index edf8dfe7e9e..00000000000
--- a/app/views/notify/_note_mr_or_commit_email.html.haml
+++ /dev/null
@@ -1,18 +0,0 @@
-= content_for :head do
- = stylesheet_link_tag 'mailers/highlighted_diff_email'
-
-New comment
-
-- if @discussion && @discussion.diff_file
- on
- = link_to @note.diff_file.file_path, @target_url, class: 'details'
- \:
- %table
- = render partial: "projects/diffs/line",
- collection: @discussion.truncated_diff_lines,
- as: :line,
- locals: { diff_file: @note.diff_file,
- plain: true,
- email: true }
-
-= render 'note_message'
diff --git a/app/views/notify/_note_mr_or_commit_email.text.erb b/app/views/notify/_note_mr_or_commit_email.text.erb
deleted file mode 100644
index b4fcdf6b1e9..00000000000
--- a/app/views/notify/_note_mr_or_commit_email.text.erb
+++ /dev/null
@@ -1,8 +0,0 @@
-<% if @discussion && @discussion.diff_file -%>
- on <%= @note.diff_file.file_path -%>
-<% end -%>:
-
-<%= url %>
-
-<%= render 'simple_diff' if @discussion -%>
-<%= render 'note_message' %>
diff --git a/app/views/notify/_simple_diff.text.erb b/app/views/notify/_simple_diff.text.erb
deleted file mode 100644
index c28d1cc34d3..00000000000
--- a/app/views/notify/_simple_diff.text.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<% @discussion.truncated_diff_lines(highlight: false).each do |line| %>
-> <%= line.text %>
-<% end %>
diff --git a/app/views/notify/note_commit_email.html.haml b/app/views/notify/note_commit_email.html.haml
index 0a650e3b2ca..5e69f01a486 100644
--- a/app/views/notify/note_commit_email.html.haml
+++ b/app/views/notify/note_commit_email.html.haml
@@ -1,2 +1 @@
-%p.details
- = render 'note_mr_or_commit_email'
+= render 'note_email'
diff --git a/app/views/notify/note_commit_email.text.erb b/app/views/notify/note_commit_email.text.erb
index 6aa085a172e..5585e7c3ee8 100644
--- a/app/views/notify/note_commit_email.text.erb
+++ b/app/views/notify/note_commit_email.text.erb
@@ -1,2 +1 @@
-New comment for Commit <%= @commit.short_id -%>
-<%= render partial: 'note_mr_or_commit_email', locals: { url: @target_url } %>
+<%= render partial: 'note_email' %>
diff --git a/app/views/notify/note_issue_email.html.haml b/app/views/notify/note_issue_email.html.haml
index 2fa2f784661..5e69f01a486 100644
--- a/app/views/notify/note_issue_email.html.haml
+++ b/app/views/notify/note_issue_email.html.haml
@@ -1 +1 @@
-= render 'note_message'
+= render 'note_email'
diff --git a/app/views/notify/note_issue_email.text.erb b/app/views/notify/note_issue_email.text.erb
index e33cbcd70f2..5585e7c3ee8 100644
--- a/app/views/notify/note_issue_email.text.erb
+++ b/app/views/notify/note_issue_email.text.erb
@@ -1,9 +1 @@
-New comment for Issue <%= @issue.iid %>
-
-<%= url_for(namespace_project_issue_url(@issue.project.namespace, @issue.project, @issue, anchor: "note_#{@note.id}")) %>
-
-
-Author: <%= @note.author_name %>
-
-<%= @note.note %>
-
+<%= render partial: 'note_email' %>
diff --git a/app/views/notify/note_merge_request_email.html.haml b/app/views/notify/note_merge_request_email.html.haml
index 0a650e3b2ca..5e69f01a486 100644
--- a/app/views/notify/note_merge_request_email.html.haml
+++ b/app/views/notify/note_merge_request_email.html.haml
@@ -1,2 +1 @@
-%p.details
- = render 'note_mr_or_commit_email'
+= render 'note_email'
diff --git a/app/views/notify/note_merge_request_email.text.erb b/app/views/notify/note_merge_request_email.text.erb
index 2ce64c494cf..381f0366971 100644
--- a/app/views/notify/note_merge_request_email.text.erb
+++ b/app/views/notify/note_merge_request_email.text.erb
@@ -1,2 +1 @@
-New comment for Merge Request <%= @merge_request.to_reference -%>
-<%= render partial: 'note_mr_or_commit_email', locals: { url: @target_url }%>
+<%= render partial: 'note_email'%>
diff --git a/app/views/notify/note_personal_snippet_email.html.haml b/app/views/notify/note_personal_snippet_email.html.haml
index 2fa2f784661..5e69f01a486 100644
--- a/app/views/notify/note_personal_snippet_email.html.haml
+++ b/app/views/notify/note_personal_snippet_email.html.haml
@@ -1 +1 @@
-= render 'note_message'
+= render 'note_email'
diff --git a/app/views/notify/note_personal_snippet_email.text.erb b/app/views/notify/note_personal_snippet_email.text.erb
index b2a8809a23b..5585e7c3ee8 100644
--- a/app/views/notify/note_personal_snippet_email.text.erb
+++ b/app/views/notify/note_personal_snippet_email.text.erb
@@ -1,8 +1 @@
-New comment for Snippet <%= @snippet.id %>
-
-<%= url_for(snippet_url(@snippet, anchor: "note_#{@note.id}")) %>
-
-
-Author: <%= @note.author_name %>
-
-<%= @note.note %>
+<%= render partial: 'note_email' %>
diff --git a/app/views/notify/note_snippet_email.html.haml b/app/views/notify/note_snippet_email.html.haml
index 2fa2f784661..5e69f01a486 100644
--- a/app/views/notify/note_snippet_email.html.haml
+++ b/app/views/notify/note_snippet_email.html.haml
@@ -1 +1 @@
-= render 'note_message'
+= render 'note_email'
diff --git a/app/views/notify/note_snippet_email.text.erb b/app/views/notify/note_snippet_email.text.erb
index 4d5a406f4b0..5585e7c3ee8 100644
--- a/app/views/notify/note_snippet_email.text.erb
+++ b/app/views/notify/note_snippet_email.text.erb
@@ -1,8 +1 @@
-New comment for Snippet <%= @snippet.id %>
-
-<%= url_for(namespace_project_snippet_url(@snippet.project.namespace, @snippet.project, @snippet, anchor: "note_#{@note.id}")) %>
-
-
-Author: <%= @note.author_name %>
-
-<%= @note.note %>
+<%= render partial: 'note_email' %>