2017-07-25 05:35:45 -04:00
|
|
|
module API
|
|
|
|
module Helpers
|
|
|
|
module RelatedResourcesHelpers
|
|
|
|
include GrapeRouteHelpers::NamedRouteMatcher
|
|
|
|
|
|
|
|
def issues_available?(project, options)
|
|
|
|
available?(:issues, project, options[:current_user])
|
|
|
|
end
|
|
|
|
|
|
|
|
def mrs_available?(project, options)
|
|
|
|
available?(:merge_requests, project, options[:current_user])
|
|
|
|
end
|
|
|
|
|
|
|
|
def expose_url(path)
|
2017-07-27 05:15:57 -04:00
|
|
|
url_options = Gitlab::Application.routes.default_url_options
|
2017-07-25 05:35:45 -04:00
|
|
|
protocol, host, port = url_options.slice(:protocol, :host, :port).values
|
|
|
|
|
|
|
|
URI::HTTP.build(scheme: protocol, host: host, port: port, path: path).to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def available?(feature, project, current_user)
|
|
|
|
project.feature_available?(feature, current_user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|