diff options
author | Thong Kuah <tkuah@gitlab.com> | 2018-11-07 14:06:33 +1300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2018-11-08 23:28:30 +1300 |
commit | b019224ff2bf6c8282a210eff1e98d0225e98a0c (patch) | |
tree | 61cb0f7bcce5fe41354abe68050133c61e3e5fdf | |
parent | 85066afb0ffc2ef973a459c23fbb7afa2f939390 (diff) | |
download | gitlab-ce-b019224ff2bf6c8282a210eff1e98d0225e98a0c.tar.gz |
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.
-rw-r--r-- | app/presenters/clusterable_presenter.rb | 6 | ||||
-rw-r--r-- | app/presenters/group_clusterable_presenter.rb | 16 | ||||
-rw-r--r-- | app/presenters/project_clusterable_presenter.rb | 11 | ||||
-rw-r--r-- | app/views/clusters/clusters/_empty_state.html.haml | 7 | ||||
-rw-r--r-- | app/views/clusters/clusters/_sidebar.html.haml | 13 | ||||
-rw-r--r-- | app/views/groups/clusters/_sidebar.html.haml | 5 | ||||
-rw-r--r-- | app/views/projects/clusters/_sidebar.html.haml | 9 | ||||
-rw-r--r-- | locale/gitlab.pot | 5 |
8 files changed, 48 insertions, 24 deletions
diff --git a/app/presenters/clusterable_presenter.rb b/app/presenters/clusterable_presenter.rb index 6de967a58e9..08ff49a8702 100644 --- a/app/presenters/clusterable_presenter.rb +++ b/app/presenters/clusterable_presenter.rb @@ -44,7 +44,11 @@ class ClusterablePresenter < Gitlab::View::Presenter::Delegated raise NotImplementedError end - def project? + def empty_state_help_text + nil + end + + def learn_more_link raise NotImplementedError end end diff --git a/app/presenters/group_clusterable_presenter.rb b/app/presenters/group_clusterable_presenter.rb index 6da4dbfeaa4..427f3ec047c 100644 --- a/app/presenters/group_clusterable_presenter.rb +++ b/app/presenters/group_clusterable_presenter.rb @@ -1,19 +1,31 @@ # frozen_string_literal: true class GroupClusterablePresenter < ClusterablePresenter + extend ::Gitlab::Utils::Override + include ActionView::Helpers::UrlHelper + + override :cluster_status_cluster_path def cluster_status_cluster_path(cluster, params = {}) cluster_status_group_cluster_path(clusterable, cluster, params) end + override :install_applications_cluster_path def install_applications_cluster_path(cluster, application) install_applications_group_cluster_path(clusterable, cluster, application) end + override :cluster_path def cluster_path(cluster, params = {}) group_cluster_path(clusterable, cluster, params) end - def project? - false + override :empty_state_help_text + 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 diff --git a/app/presenters/project_clusterable_presenter.rb b/app/presenters/project_clusterable_presenter.rb index 2aea31e8bbf..ede8547d210 100644 --- a/app/presenters/project_clusterable_presenter.rb +++ b/app/presenters/project_clusterable_presenter.rb @@ -1,19 +1,26 @@ # frozen_string_literal: true class ProjectClusterablePresenter < ClusterablePresenter + extend ::Gitlab::Utils::Override + include ActionView::Helpers::UrlHelper + + override :cluster_status_cluster_path def cluster_status_cluster_path(cluster, params = {}) cluster_status_project_cluster_path(clusterable, cluster, params) end + override :install_applications_cluster_path def install_applications_cluster_path(cluster, application) install_applications_project_cluster_path(clusterable, cluster, application) end + override :cluster_path def cluster_path(cluster, params = {}) project_cluster_path(clusterable, cluster, params) end - def project? - true + override :learn_more_link + 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 diff --git a/app/views/clusters/clusters/_empty_state.html.haml b/app/views/clusters/clusters/_empty_state.html.haml index 1cbff0a0e23..c926ec258f0 100644 --- a/app/views/clusters/clusters/_empty_state.html.haml +++ b/app/views/clusters/clusters/_empty_state.html.haml @@ -6,11 +6,8 @@ %h4.text-center= s_('ClusterIntegration|Integrate Kubernetes cluster automation') %p = 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? - = link_to(s_('ClusterIntegration|Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') - - 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') + = clusterable.empty_state_help_text + = clusterable.learn_more_link - if clusterable.can_create_cluster? .text-center diff --git a/app/views/clusters/clusters/_sidebar.html.haml b/app/views/clusters/clusters/_sidebar.html.haml deleted file mode 100644 index 66cda3ee83b..00000000000 --- a/app/views/clusters/clusters/_sidebar.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -- 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.') diff --git a/app/views/groups/clusters/_sidebar.html.haml b/app/views/groups/clusters/_sidebar.html.haml new file mode 100644 index 00000000000..39b70de72df --- /dev/null +++ b/app/views/groups/clusters/_sidebar.html.haml @@ -0,0 +1,5 @@ +%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.') diff --git a/app/views/projects/clusters/_sidebar.html.haml b/app/views/projects/clusters/_sidebar.html.haml new file mode 100644 index 00000000000..b44c1df51fd --- /dev/null +++ b/app/views/projects/clusters/_sidebar.html.haml @@ -0,0 +1,9 @@ +- 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 } diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 3ed3fc1baf0..fc2d5a1479e 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -1367,7 +1367,7 @@ msgstr "" msgid "ClusterIntegration|Add a Kubernetes cluster integration" 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 "" msgid "ClusterIntegration|Adding an integration to your group will share the cluster across all your projects." @@ -1703,6 +1703,9 @@ msgstr "" msgid "ClusterIntegration|Token" 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" msgstr "" |