From 70b51cc4b25e0e4c7b44f9bc0947fe8dca73472b Mon Sep 17 00:00:00 2001
From: Mayra Cabrera <mcabrera@gitlab.com>
Date: Mon, 14 Jan 2019 15:54:33 -0600
Subject: [PATCH] Changes environment scope UI on clusters page

Modifies clusters form to display a disabled text field for environment
scope.

This changes is needed for https://gitlab.com/gitlab-org/gitlab-ce/issues/52363
---
 .../clusters/_integration_form.html.haml      | 20 +++++++++----------
 ...nvironment-scope-field-on-cluster-page.yml |  5 +++++
 locale/gitlab.pot                             |  3 +++
 3 files changed, 18 insertions(+), 10 deletions(-)
 create mode 100644 changelogs/unreleased/52363-modifies-environment-scope-field-on-cluster-page.yml

diff --git a/app/views/clusters/clusters/_integration_form.html.haml b/app/views/clusters/clusters/_integration_form.html.haml
index b5b8ef14fe2..4620e005575 100644
--- a/app/views/clusters/clusters/_integration_form.html.haml
+++ b/app/views/clusters/clusters/_integration_form.html.haml
@@ -13,19 +13,19 @@
           = sprite_icon('status_failed_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-unchecked')
       .form-text.text-muted= s_('ClusterIntegration|Enable or disable GitLab\'s connection to your Kubernetes cluster.')
 
-  - if has_multiple_clusters?
-    .form-group
-      %h5= s_('ClusterIntegration|Environment scope')
+  .form-group
+    %h5= s_('ClusterIntegration|Environment scope')
+    - if has_multiple_clusters?
       = field.text_field :environment_scope, class: 'col-md-6 form-control js-select-on-focus', placeholder: s_('ClusterIntegration|Environment scope')
       .form-text.text-muted= s_("ClusterIntegration|Choose which of your environments will use this cluster.")
+    - else
+      = text_field_tag :environment_scope, '*', class: 'col-md-6 form-control disabled', placeholder: s_('ClusterIntegration|Environment scope'), disabled: true
+      - environment_scope_url = 'https://docs.gitlab.com/ee/user/project/clusters/#setting-the-environment-scope-premium'
+      - environment_scope_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: environment_scope_url }
+      .form-text.text-muted
+        %code *
+        = s_("ClusterIntegration| is the default environment scope for this cluster. This means that all jobs, regardless of their environment, will use this cluster. %{environment_scope_start}More information%{environment_scope_end}").html_safe % { environment_scope_start: environment_scope_start, environment_scope_end: '</a>'.html_safe }
 
   - if can?(current_user, :update_cluster, @cluster)
     .form-group
       = field.submit _('Save changes'), class: 'btn btn-success'
-
-  - unless has_multiple_clusters?
-    %h5= s_('ClusterIntegration|Environment scope')
-    %p
-      %code *
-      is the default environment scope for this cluster. This means that all jobs, regardless of their environment, will use this cluster.
-      = link_to 'More information', ('https://docs.gitlab.com/ee/user/project/clusters/#setting-the-environment-scope')
diff --git a/changelogs/unreleased/52363-modifies-environment-scope-field-on-cluster-page.yml b/changelogs/unreleased/52363-modifies-environment-scope-field-on-cluster-page.yml
new file mode 100644
index 00000000000..07cb35e6529
--- /dev/null
+++ b/changelogs/unreleased/52363-modifies-environment-scope-field-on-cluster-page.yml
@@ -0,0 +1,5 @@
+---
+title: Modifies environment scope UI on cluster page
+merge_request: 24376
+author:
+type: other
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 64eeec3ffe0..40c27dfbeb6 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -1852,6 +1852,9 @@ msgstr ""
 msgid "Closed issues"
 msgstr ""
 
+msgid "ClusterIntegration| is the default environment scope for this cluster. This means that all jobs, regardless of their environment, will use this cluster. %{environment_scope_start}More information%{environment_scope_end}"
+msgstr ""
+
 msgid "ClusterIntegration|%{appList} was successfully installed on your Kubernetes cluster"
 msgstr ""
 
-- 
2.30.9