2016-11-04 11:35:22 -04:00
|
|
|
module EnvironmentHelper
|
|
|
|
def environment_for_build(project, build)
|
|
|
|
return unless build.environment
|
|
|
|
|
2016-11-16 18:23:05 -05:00
|
|
|
project.environments.find_by(name: build.expanded_environment_name)
|
2016-11-04 11:35:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def environment_link_for_build(project, build)
|
|
|
|
environment = environment_for_build(project, build)
|
2016-11-16 18:23:05 -05:00
|
|
|
if environment
|
|
|
|
link_to environment.name, namespace_project_environment_path(project.namespace, project, environment)
|
|
|
|
else
|
|
|
|
content_tag :span, build.expanded_environment_name
|
|
|
|
end
|
2016-11-04 11:35:22 -04:00
|
|
|
end
|
|
|
|
|
2016-11-16 18:23:05 -05:00
|
|
|
def deployment_link(deployment)
|
2016-11-04 11:35:22 -04:00
|
|
|
return unless deployment
|
|
|
|
|
2016-11-17 14:33:53 -05:00
|
|
|
link_to "##{deployment.iid}", [deployment.project.namespace.becomes(Namespace), deployment.project, deployment.deployable]
|
2016-11-04 11:35:22 -04:00
|
|
|
end
|
2016-11-16 18:23:05 -05:00
|
|
|
|
|
|
|
def last_deployment_link_for_environment_build(project, build)
|
|
|
|
environment = environment_for_build(project, build)
|
|
|
|
return unless environment
|
|
|
|
|
|
|
|
deployment_link(environment.last_deployment)
|
|
|
|
end
|
2016-11-04 11:35:22 -04:00
|
|
|
end
|