gitlab-org--gitlab-foss/lib/gitlab/chat_commands/presenters/issue_new.rb

51 lines
1.3 KiB
Ruby
Raw Normal View History

2017-01-19 08:22:09 +00:00
module Gitlab
module ChatCommands
module Presenters
2017-01-26 14:30:34 +00:00
class IssueNew < Presenters::Base
include Presenters::IssueBase
2017-01-26 14:30:34 +00:00
2017-01-19 08:22:09 +00:00
def present
2017-01-26 14:30:34 +00:00
in_channel_response(new_issue)
2017-01-19 08:22:09 +00:00
end
private
2017-02-14 14:03:20 +00:00
def new_issue
2017-01-19 08:22:09 +00:00
{
attachments: [
{
title: "#{@resource.title} · #{@resource.to_reference}",
title_link: resource_url,
author_name: author.name,
author_icon: author.avatar_url,
fallback: "New issue #{@resource.to_reference}: #{@resource.title}",
pretext: pretext,
color: color(@resource),
fields: fields,
mrkdwn_in: [
:title,
2017-01-30 11:12:57 +00:00
:pretext,
:text,
:fields
2017-01-19 08:22:09 +00:00
]
}
]
}
end
def pretext
"I created an issue on #{author_profile_link}'s behalf: **#{@resource.to_reference}** in #{project_link}"
2017-01-19 08:22:09 +00:00
end
2017-01-26 14:30:34 +00:00
def project_link
2017-02-14 14:03:20 +00:00
"[#{project.name_with_namespace}](#{project.web_url})"
2017-01-26 14:30:34 +00:00
end
2017-01-19 08:22:09 +00:00
def author_profile_link
"[#{author.to_reference}](#{url_for(author)})"
end
end
end
end
end