Commit b019224f authored by Thong Kuah's avatar Thong Kuah

Refactor to use presenter

Refacotr project or group specific `if` logic to be contained within
each presenter instead.

Also add :override to ensure super method exists.
parent 85066afb
...@@ -44,7 +44,11 @@ class ClusterablePresenter < Gitlab::View::Presenter::Delegated ...@@ -44,7 +44,11 @@ class ClusterablePresenter < Gitlab::View::Presenter::Delegated
raise NotImplementedError raise NotImplementedError
end end
def project? def empty_state_help_text
nil
end
def learn_more_link
raise NotImplementedError raise NotImplementedError
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
class GroupClusterablePresenter < ClusterablePresenter class GroupClusterablePresenter < ClusterablePresenter
extend ::Gitlab::Utils::Override
include ActionView::Helpers::UrlHelper
override :cluster_status_cluster_path
def cluster_status_cluster_path(cluster, params = {}) def cluster_status_cluster_path(cluster, params = {})
cluster_status_group_cluster_path(clusterable, cluster, params) cluster_status_group_cluster_path(clusterable, cluster, params)
end end
override :install_applications_cluster_path
def install_applications_cluster_path(cluster, application) def install_applications_cluster_path(cluster, application)
install_applications_group_cluster_path(clusterable, cluster, application) install_applications_group_cluster_path(clusterable, cluster, application)
end end
override :cluster_path
def cluster_path(cluster, params = {}) def cluster_path(cluster, params = {})
group_cluster_path(clusterable, cluster, params) group_cluster_path(clusterable, cluster, params)
end end
def project? override :empty_state_help_text
false def empty_state_help_text
s_('ClusterIntegration|Adding an integration to your group will share the cluster across all your projects.')
end
override :learn_more_link
def learn_more_link
link_to(s_('ClusterIntegration|Learn more about group Kubernetes clusters'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer')
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
class ProjectClusterablePresenter < ClusterablePresenter class ProjectClusterablePresenter < ClusterablePresenter
extend ::Gitlab::Utils::Override
include ActionView::Helpers::UrlHelper
override :cluster_status_cluster_path
def cluster_status_cluster_path(cluster, params = {}) def cluster_status_cluster_path(cluster, params = {})
cluster_status_project_cluster_path(clusterable, cluster, params) cluster_status_project_cluster_path(clusterable, cluster, params)
end end
override :install_applications_cluster_path
def install_applications_cluster_path(cluster, application) def install_applications_cluster_path(cluster, application)
install_applications_project_cluster_path(clusterable, cluster, application) install_applications_project_cluster_path(clusterable, cluster, application)
end end
override :cluster_path
def cluster_path(cluster, params = {}) def cluster_path(cluster, params = {})
project_cluster_path(clusterable, cluster, params) project_cluster_path(clusterable, cluster, params)
end end
def project? override :learn_more_link
true def learn_more_link
link_to(s_('ClusterIntegration|Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer')
end end
end end
...@@ -6,11 +6,8 @@ ...@@ -6,11 +6,8 @@
%h4.text-center= s_('ClusterIntegration|Integrate Kubernetes cluster automation') %h4.text-center= s_('ClusterIntegration|Integrate Kubernetes cluster automation')
%p %p
= s_('ClusterIntegration|Kubernetes clusters allow you to use review apps, deploy your applications, run your pipelines, and much more in an easy way.') = s_('ClusterIntegration|Kubernetes clusters allow you to use review apps, deploy your applications, run your pipelines, and much more in an easy way.')
- if clusterable.project? = clusterable.empty_state_help_text
= link_to(s_('ClusterIntegration|Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') = clusterable.learn_more_link
- else
= s_('ClusterIntegration|Adding an integration to your group will share the cluster across all your projects.')
= link_to(s_('ClusterIntegration|Learn more about group Kubernetes clusters'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer')
- if clusterable.can_create_cluster? - if clusterable.can_create_cluster?
.text-center .text-center
......
- clusters_help_url = help_page_path('user/project/clusters/index.md')
- help_link_start = "<a href=\"%{url}\" target=\"_blank\" rel=\"noopener noreferrer\">".html_safe
- help_link_end = '</a>'.html_safe
%h4.prepend-top-0
= s_('ClusterIntegration|Add a Kubernetes cluster integration')
- if clusterable.project?
%p
= s_('ClusterIntegration|With a Kubernetes cluster associated to this project, you can use review apps, deploy your applications, run your pipelines, and much more in an easy way.')
%p
= s_('ClusterIntegration|Learn more about %{help_link_start}Kubernetes%{help_link_end}.').html_safe % { help_link_start: help_link_start % { url: clusters_help_url }, help_link_end: help_link_end }
- else
%p
= s_('ClusterIntegration|Adding a Kubernetes cluster to your group will automatically share the cluster across all your projects. Use review apps, deploy your applications, and easily run your pipelines for all projects using the same cluster.')
%h4.prepend-top-0
= s_('ClusterIntegration|Add a Kubernetes cluster integration')
%p
= s_('ClusterIntegration|Adding a Kubernetes cluster to your group will automatically share the cluster across all your projects.')
= s_('ClusterIntegration|Use review apps, deploy your applications, and easily run your pipelines for all projects using the same cluster.')
- clusters_help_url = help_page_path('user/project/clusters/index.md')
- help_link_start = "<a href=\"%{url}\" target=\"_blank\" rel=\"noopener noreferrer\">".html_safe
- help_link_end = '</a>'.html_safe
%h4.prepend-top-0
= s_('ClusterIntegration|Add a Kubernetes cluster integration')
%p
= s_('ClusterIntegration|With a Kubernetes cluster associated to this project, you can use review apps, deploy your applications, run your pipelines, and much more in an easy way.')
%p
= s_('ClusterIntegration|Learn more about %{help_link_start}Kubernetes%{help_link_end}.').html_safe % { help_link_start: help_link_start % { url: clusters_help_url }, help_link_end: help_link_end }
...@@ -1367,7 +1367,7 @@ msgstr "" ...@@ -1367,7 +1367,7 @@ msgstr ""
msgid "ClusterIntegration|Add a Kubernetes cluster integration" msgid "ClusterIntegration|Add a Kubernetes cluster integration"
msgstr "" msgstr ""
msgid "ClusterIntegration|Adding a Kubernetes cluster to your group will automatically share the cluster across all your projects. Use review apps, deploy your applications, and easily run your pipelines for all projects using the same cluster." msgid "ClusterIntegration|Adding a Kubernetes cluster to your group will automatically share the cluster across all your projects."
msgstr "" msgstr ""
msgid "ClusterIntegration|Adding an integration to your group will share the cluster across all your projects." msgid "ClusterIntegration|Adding an integration to your group will share the cluster across all your projects."
...@@ -1703,6 +1703,9 @@ msgstr "" ...@@ -1703,6 +1703,9 @@ msgstr ""
msgid "ClusterIntegration|Token" msgid "ClusterIntegration|Token"
msgstr "" msgstr ""
msgid "ClusterIntegration|Use review apps, deploy your applications, and easily run your pipelines for all projects using the same cluster."
msgstr ""
msgid "ClusterIntegration|Validating project billing status" msgid "ClusterIntegration|Validating project billing status"
msgstr "" msgstr ""
......
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