From 857852ce048607a0898a9b40e04fdb0658b6a83d Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 12 Nov 2014 11:59:57 +0100 Subject: Set action on issue/mr creation mail. --- app/helpers/emails_helper.rb | 34 +++++++++++++++++++++++----------- app/views/layouts/notify.html.haml | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) (limited to 'app') diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb index 2ef28922ec1..24d67c21d6b 100644 --- a/app/helpers/emails_helper.rb +++ b/app/helpers/emails_helper.rb @@ -2,19 +2,31 @@ module EmailsHelper # Google Actions # https://developers.google.com/gmail/markup/reference/go-to-action - def email_action(options) - data = { - "@context" => "http://schema.org", - "@type" => "EmailMessage", - "action" => { - "@type" => "ViewAction", - "name" => options[:name], - "url" => options[:url], + def email_action(url) + name = action_title(url) + if name + data = { + "@context" => "http://schema.org", + "@type" => "EmailMessage", + "action" => { + "@type" => "ViewAction", + "name" => name, + "url" => url, + } } - } - content_tag :script, type: 'application/ld+json' do - data.to_json.html_safe + content_tag :script, type: 'application/ld+json' do + data.to_json.html_safe + end + end + end + + def action_title(url) + return unless url + ["merge_requests", "issues", "commit"].each do |action| + if url.split("/").include?(action) + return "View #{action.humanize.singularize}" + end end end end diff --git a/app/views/layouts/notify.html.haml b/app/views/layouts/notify.html.haml index 1236cf00f01..da451961327 100644 --- a/app/views/layouts/notify.html.haml +++ b/app/views/layouts/notify.html.haml @@ -28,4 +28,4 @@ You're receiving this notification because you are a member of the #{link_to_unless @target_url, @project.name_with_namespace, project_url(@project)} project team. - if @target_url #{link_to "View it on GitLab", @target_url} - = email_action name: "View #{@note.noteable_type.underscore.humanize}", url: @target_url + = email_action @target_url -- cgit v1.2.1