debian-mirror-gitlab/app/presenters/clusterable_presenter.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
1.7 KiB
Ruby
Raw Permalink Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
class ClusterablePresenter < Gitlab::View::Presenter::Delegated
2021-11-18 22:05:49 +05:30
presents ::Project, ::Group, ::Clusters::Instance, as: :clusterable
2018-12-13 13:39:08 +05:30
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
2021-01-03 14:25:43 +05:30
.new(clusterable, **attributes_with_presenter_class)
2018-12-13 13:39:08 +05:30
.fabricate!
end
2019-02-15 15:39:39 +05:30
def can_add_cluster?
2020-07-28 23:09:34 +05:30
can?(current_user, :add_cluster, clusterable)
2019-02-15 15:39:39 +05:30
end
2022-04-04 11:22:00 +05:30
def can_admin_cluster?
can?(current_user, :admin_cluster, clusterable)
end
2018-12-13 13:39:08 +05:30
def can_create_cluster?
can?(current_user, :create_cluster, clusterable)
end
2020-05-24 23:13:21 +05:30
def index_path(options = {})
polymorphic_path([clusterable, :clusters], options)
2018-12-13 13:39:08 +05:30
end
2022-05-07 20:08:51 +05:30
def connect_path
polymorphic_path([clusterable, :clusters], action: :connect)
end
2022-06-21 17:19:12 +05:30
def new_cluster_docs_path
polymorphic_path([clusterable, :clusters], action: :new_cluster_docs)
end
2018-12-13 13:39:08 +05:30
def create_user_clusters_path
polymorphic_path([clusterable, :clusters], action: :create_user)
end
def cluster_status_cluster_path(cluster, params = {})
raise NotImplementedError
end
2020-01-01 13:55:28 +05:30
def clear_cluster_cache_path(cluster)
raise NotImplementedError
end
2018-12-13 13:39:08 +05:30
def cluster_path(cluster, params = {})
raise NotImplementedError
end
2019-02-15 15:39:39 +05:30
2020-07-28 23:09:34 +05:30
def metrics_dashboard_path(cluster)
raise NotImplementedError
end
# Will be overridden in EE
2019-12-04 20:38:33 +05:30
def environments_cluster_path(cluster)
nil
end
2019-02-15 15:39:39 +05:30
def empty_state_help_text
nil
end
def sidebar_text
raise NotImplementedError
end
def learn_more_link
raise NotImplementedError
end
2018-12-13 13:39:08 +05:30
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
ClusterablePresenter.prepend_mod_with('ClusterablePresenter')