summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2018-11-02 10:41:53 +1300
committerThong Kuah <tkuah@gitlab.com>2018-11-02 10:41:53 +1300
commitfec21f5542b4b50cb1e49a6c50c8b4d57fa9f62e (patch)
tree37d427d9450431363de36ba90c5c4ea1efe068c3
parent2c6a3f6a1a90fb4eb780e081a6673fd2e90c7dc1 (diff)
downloadgitlab-ce-top_level_clusters_controller.tar.gz
Use polymorphic_paths where we cantop_level_clusters_controller
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.
-rw-r--r--app/presenters/clusterable_presenter.rb12
-rw-r--r--app/presenters/project_clusterable_presenter.rb20
2 files changed, 4 insertions, 28 deletions
diff --git a/app/presenters/clusterable_presenter.rb b/app/presenters/clusterable_presenter.rb
index 61e00b31185..cff0e74d6ea 100644
--- a/app/presenters/clusterable_presenter.rb
+++ b/app/presenters/clusterable_presenter.rb
@@ -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 = {})
diff --git a/app/presenters/project_clusterable_presenter.rb b/app/presenters/project_clusterable_presenter.rb
index bd149cdcc70..12077b2e735 100644
--- a/app/presenters/project_clusterable_presenter.rb
+++ b/app/presenters/project_clusterable_presenter.rb
@@ -1,22 +1,6 @@
# 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