2018-10-30 06:33:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ClusterablePresenter < Gitlab::View::Presenter::Delegated
|
|
|
|
presents :clusterable
|
|
|
|
|
|
|
|
def self.fabricate(clusterable, **attributes)
|
|
|
|
presenter_class = "#{clusterable.class.name}ClusterablePresenter".constantize
|
|
|
|
attributes_with_presenter_class = attributes.merge(presenter_class: presenter_class)
|
|
|
|
|
|
|
|
Gitlab::View::Presenter::Factory
|
2020-10-12 20:08:42 -04:00
|
|
|
.new(clusterable, **attributes_with_presenter_class)
|
2018-10-30 06:33:43 -04:00
|
|
|
.fabricate!
|
|
|
|
end
|
|
|
|
|
2018-12-04 16:38:15 -05:00
|
|
|
def can_add_cluster?
|
2020-07-08 08:09:33 -04:00
|
|
|
can?(current_user, :add_cluster, clusterable)
|
2018-12-04 16:38:15 -05:00
|
|
|
end
|
|
|
|
|
2018-10-30 06:33:43 -04:00
|
|
|
def can_create_cluster?
|
|
|
|
can?(current_user, :create_cluster, clusterable)
|
|
|
|
end
|
|
|
|
|
2020-05-12 05:09:31 -04:00
|
|
|
def index_path(options = {})
|
|
|
|
polymorphic_path([clusterable, :clusters], options)
|
2018-10-30 06:33:43 -04:00
|
|
|
end
|
|
|
|
|
2019-09-09 16:27:51 -04:00
|
|
|
def new_path(options = {})
|
|
|
|
new_polymorphic_path([clusterable, :cluster], options)
|
2018-10-30 06:33:43 -04:00
|
|
|
end
|
2018-11-01 16:48:38 -04:00
|
|
|
|
2019-11-08 01:06:24 -05:00
|
|
|
def authorize_aws_role_path
|
|
|
|
polymorphic_path([clusterable, :clusters], action: :authorize_aws_role)
|
|
|
|
end
|
|
|
|
|
2018-11-01 16:48:38 -04:00
|
|
|
def create_user_clusters_path
|
2018-11-01 17:41:53 -04:00
|
|
|
polymorphic_path([clusterable, :clusters], action: :create_user)
|
2018-11-01 16:48:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def create_gcp_clusters_path
|
2018-11-01 17:41:53 -04:00
|
|
|
polymorphic_path([clusterable, :clusters], action: :create_gcp)
|
2018-11-01 16:48:38 -04:00
|
|
|
end
|
|
|
|
|
2019-11-13 01:06:38 -05:00
|
|
|
def create_aws_clusters_path
|
|
|
|
polymorphic_path([clusterable, :clusters], action: :create_aws)
|
|
|
|
end
|
|
|
|
|
2018-11-01 16:48:38 -04:00
|
|
|
def cluster_status_cluster_path(cluster, params = {})
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2019-11-26 04:08:36 -05:00
|
|
|
def clear_cluster_cache_path(cluster)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2018-11-01 16:48:38 -04:00
|
|
|
def cluster_path(cluster, params = {})
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
2018-11-06 15:26:30 -05:00
|
|
|
|
2020-07-13 11:09:08 -04:00
|
|
|
def metrics_dashboard_path(cluster)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2020-07-08 02:09:13 -04:00
|
|
|
# Will be overridden in EE
|
2019-09-02 04:15:15 -04:00
|
|
|
def environments_cluster_path(cluster)
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2018-11-06 20:06:33 -05:00
|
|
|
def empty_state_help_text
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2018-11-07 03:07:28 -05:00
|
|
|
def sidebar_text
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2018-11-06 20:06:33 -05:00
|
|
|
def learn_more_link
|
2018-11-06 15:26:30 -05:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
2018-10-30 06:33:43 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
ClusterablePresenter.prepend_mod_with('ClusterablePresenter')
|