2018-11-19 21:01:13 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-19 03:22:09 -05:00
|
|
|
module Gitlab
|
2017-05-31 01:50:53 -04:00
|
|
|
module SlashCommands
|
2017-01-19 03:22:09 -05:00
|
|
|
module Presenters
|
2017-01-26 09:30:34 -05:00
|
|
|
class IssueNew < Presenters::Base
|
2017-02-08 10:42:27 -05:00
|
|
|
include Presenters::IssueBase
|
2017-01-26 09:30:34 -05:00
|
|
|
|
2017-01-19 03:22:09 -05:00
|
|
|
def present
|
2017-01-26 09:30:34 -05:00
|
|
|
in_channel_response(new_issue)
|
2017-01-19 03:22:09 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-02-14 09:03:20 -05:00
|
|
|
def new_issue
|
2017-01-19 03:22:09 -05: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 06:12:57 -05:00
|
|
|
:pretext,
|
|
|
|
:text,
|
|
|
|
:fields
|
2017-01-19 03:22:09 -05:00
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def pretext
|
2017-01-31 06:00:43 -05:00
|
|
|
"I created an issue on #{author_profile_link}'s behalf: **#{@resource.to_reference}** in #{project_link}"
|
2017-01-19 03:22:09 -05:00
|
|
|
end
|
|
|
|
|
2017-01-26 09:30:34 -05:00
|
|
|
def project_link
|
2018-03-07 09:07:09 -05:00
|
|
|
"[#{project.full_name}](#{project.web_url})"
|
2017-01-26 09:30:34 -05:00
|
|
|
end
|
|
|
|
|
2017-01-19 03:22:09 -05:00
|
|
|
def author_profile_link
|
|
|
|
"[#{author.to_reference}](#{url_for(author)})"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|