2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-18 08:13:57 -05:00
|
|
|
module ClustersHelper
|
2018-10-18 21:42:30 -04:00
|
|
|
# EE overrides this
|
|
|
|
def has_multiple_clusters?
|
2017-12-18 08:35:08 -05:00
|
|
|
false
|
2017-12-18 08:13:57 -05:00
|
|
|
end
|
2018-05-07 14:06:02 -04:00
|
|
|
|
2018-10-18 21:42:30 -04:00
|
|
|
def clusterable
|
|
|
|
@project
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_create_cluster?
|
|
|
|
can?(current_user, :create_cluster, clusterable)
|
|
|
|
end
|
|
|
|
|
2018-05-07 14:06:02 -04:00
|
|
|
def render_gcp_signup_offer
|
2018-07-10 09:20:05 -04:00
|
|
|
return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers?
|
2018-05-07 14:06:02 -04:00
|
|
|
return unless show_gcp_signup_offer?
|
|
|
|
|
|
|
|
content_tag :section, class: 'no-animate expanded' do
|
2018-10-14 23:37:51 -04:00
|
|
|
render 'clusters/gcp_signup_offer_banner'
|
2018-05-07 14:06:02 -04:00
|
|
|
end
|
|
|
|
end
|
2018-10-18 21:42:30 -04:00
|
|
|
|
|
|
|
def hidden_clusterable_fields
|
|
|
|
clusterable_params.map do |key, value|
|
|
|
|
hidden_field_tag(key, value)
|
|
|
|
end.reduce(&:safe_concat)
|
|
|
|
end
|
|
|
|
|
|
|
|
def clusterable_params
|
|
|
|
case clusterable
|
|
|
|
when Project
|
|
|
|
{ project_id: clusterable.to_param, namespace_id: clusterable.namespace.to_param }
|
|
|
|
else
|
|
|
|
{}
|
|
|
|
end
|
|
|
|
end
|
2017-12-18 08:13:57 -05:00
|
|
|
end
|