Commit fec21f55 authored by Thong Kuah's avatar Thong Kuah

Use polymorphic_paths where we can

To reduce the number of abstract methods, use polymorphic_paths for
collection routes. Unfortunately for member routes, polymorphic_paths
does not support namespaced classes, so still continue to override
methods.
parent 2c6a3f6a
......@@ -17,23 +17,19 @@ class ClusterablePresenter < Gitlab::View::Presenter::Delegated
end
def index_path
raise NotImplementedError
polymorphic_path([clusterable, :clusters])
end
def new_path
raise NotImplementedError
end
def clusterable_params
raise NotImplementedError
new_polymorphic_path([clusterable, :cluster])
end
def create_user_clusters_path
raise NotImplementedError
polymorphic_path([clusterable, :clusters], action: :create_user)
end
def create_gcp_clusters_path
raise NotImplementedError
polymorphic_path([clusterable, :clusters], action: :create_gcp)
end
def cluster_status_cluster_path(cluster, params = {})
......
# frozen_string_literal: true
class ProjectClusterablePresenter < ClusterablePresenter
def index_path
project_clusters_path(clusterable)
end
def new_path
new_project_cluster_path(clusterable)
end
def create_user_clusters_path
create_user_project_clusters_path(clusterable)
end
def create_gcp_clusters_path
create_gcp_project_clusters_path(clusterable)
end
def cluster_status_cluster_path(cluster, params = {})
cluster_status_project_cluster_path(clusterable, cluster, params)
end
......@@ -28,8 +12,4 @@ class ProjectClusterablePresenter < ClusterablePresenter
def cluster_path(cluster, params = {})
project_cluster_path(clusterable, cluster, params)
end
def clusterable_params
{ project_id: clusterable.to_param, namespace_id: clusterable.namespace.to_param }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment