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

53 lines
1.3 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-01-19 03:22:09 -05:00
module Gitlab
module SlashCommands
2017-01-19 03:22:09 -05:00
module Presenters
2017-01-26 09:30:34 -05:00
class IssueNew < Presenters::Base
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
"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
"[#{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