From 5b3c096c9e0c9e8e7e1cb35c1b9e347995b948f5 Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Mon, 15 Oct 2018 16:37:51 +1300 Subject: Convert clusters to use a top-level controller In preparation so that we can create both cluster attached to project and cluster attached to group. - Move ClustersController to top level - Move Clusters::ApplicationsController to top-level too - Creates a Clusters::BaseController to share common functions - Do not rely on @project ivar. Anything could set the ivar. - Fix Vue page components due to new data-page value Because of the controller change we have gone from `projects:clusters:new` to `clusters:new`, so we need to update the file location of the page components. There is somewhere a function that will convert data-page to a file location. On that note, projects/clusters/gcp/new/, translate to Projects::Clusters::Gcp#new doesn't exist so replace that with clusters/create_gcp/ and clusters/create_user/ --- app/views/clusters/_advanced_settings.html.haml | 15 +++++ app/views/clusters/_banner.html.haml | 15 +++++ app/views/clusters/_cluster.html.haml | 24 +++++++ app/views/clusters/_empty_state.html.haml | 12 ++++ .../clusters/_gcp_signup_offer_banner.html.haml | 12 ++++ app/views/clusters/_integration_form.html.haml | 31 +++++++++ app/views/clusters/_sidebar.html.haml | 9 +++ app/views/clusters/gcp/_form.html.haml | 74 ++++++++++++++++++++++ app/views/clusters/gcp/_header.html.haml | 14 ++++ app/views/clusters/gcp/_show.html.haml | 49 ++++++++++++++ app/views/clusters/index.html.haml | 24 +++++++ app/views/clusters/new.html.haml | 36 +++++++++++ app/views/clusters/show.html.haml | 52 +++++++++++++++ app/views/clusters/user/_form.html.haml | 38 +++++++++++ app/views/clusters/user/_header.html.haml | 5 ++ app/views/clusters/user/_show.html.haml | 38 +++++++++++ 16 files changed, 448 insertions(+) create mode 100644 app/views/clusters/_advanced_settings.html.haml create mode 100644 app/views/clusters/_banner.html.haml create mode 100644 app/views/clusters/_cluster.html.haml create mode 100644 app/views/clusters/_empty_state.html.haml create mode 100644 app/views/clusters/_gcp_signup_offer_banner.html.haml create mode 100644 app/views/clusters/_integration_form.html.haml create mode 100644 app/views/clusters/_sidebar.html.haml create mode 100644 app/views/clusters/gcp/_form.html.haml create mode 100644 app/views/clusters/gcp/_header.html.haml create mode 100644 app/views/clusters/gcp/_show.html.haml create mode 100644 app/views/clusters/index.html.haml create mode 100644 app/views/clusters/new.html.haml create mode 100644 app/views/clusters/show.html.haml create mode 100644 app/views/clusters/user/_form.html.haml create mode 100644 app/views/clusters/user/_header.html.haml create mode 100644 app/views/clusters/user/_show.html.haml (limited to 'app/views/clusters') diff --git a/app/views/clusters/_advanced_settings.html.haml b/app/views/clusters/_advanced_settings.html.haml new file mode 100644 index 00000000000..243e8cd9ba0 --- /dev/null +++ b/app/views/clusters/_advanced_settings.html.haml @@ -0,0 +1,15 @@ +- if can?(current_user, :admin_cluster, @cluster) + - if @cluster.managed? + .append-bottom-20 + %label.append-bottom-10 + = s_('ClusterIntegration|Google Kubernetes Engine') + %p + - link_gke = link_to(s_('ClusterIntegration|Google Kubernetes Engine'), @cluster.gke_cluster_url, target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|Manage your Kubernetes cluster by visiting %{link_gke}').html_safe % { link_gke: link_gke } + + .sub-section.form-group + %h4.text-danger + = s_('ClusterIntegration|Remove Kubernetes cluster integration') + %p + = s_("ClusterIntegration|Remove this Kubernetes cluster's configuration from this project. This will not delete your actual Kubernetes cluster.") + = link_to(s_('ClusterIntegration|Remove integration'), namespace_project_cluster_path(@project.namespace, @project, @cluster.id), method: :delete, class: 'btn btn-danger', data: { confirm: s_("ClusterIntegration|Are you sure you want to remove this Kubernetes cluster's integration? This will not delete your actual Kubernetes cluster.")}) diff --git a/app/views/clusters/_banner.html.haml b/app/views/clusters/_banner.html.haml new file mode 100644 index 00000000000..73cfea0ef92 --- /dev/null +++ b/app/views/clusters/_banner.html.haml @@ -0,0 +1,15 @@ +.hidden.js-cluster-error.bs-callout.bs-callout-danger{ role: 'alert' } + = s_('ClusterIntegration|Something went wrong while creating your Kubernetes cluster on Google Kubernetes Engine') + %p.js-error-reason + +.hidden.js-cluster-creating.bs-callout.bs-callout-info{ role: 'alert' } + = s_('ClusterIntegration|Kubernetes cluster is being created on Google Kubernetes Engine...') + +.hidden.js-cluster-success.bs-callout.bs-callout-success{ role: 'alert' } + = s_("ClusterIntegration|Kubernetes cluster was successfully created on Google Kubernetes Engine. Refresh the page to see Kubernetes cluster's details") + +- if show_cluster_security_warning? + .js-cluster-security-warning.alert.alert-block.alert-dismissable.bs-callout.bs-callout-warning + %button.close{ type: "button", data: { feature_id: UserCalloutsHelper::CLUSTER_SECURITY_WARNING, dismiss_endpoint: user_callouts_path } } × + = s_("ClusterIntegration|The default cluster configuration grants access to many functionalities needed to successfully build and deploy a containerised application.") + = link_to s_("More information"), help_page_path('user/project/clusters/index.md', anchor: 'security-implications') diff --git a/app/views/clusters/_cluster.html.haml b/app/views/clusters/_cluster.html.haml new file mode 100644 index 00000000000..2d7f7c6b1fb --- /dev/null +++ b/app/views/clusters/_cluster.html.haml @@ -0,0 +1,24 @@ +.gl-responsive-table-row + .table-section.section-30 + .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Kubernetes cluster") + .table-mobile-content + = link_to cluster.name, namespace_project_cluster_path(@project.namespace, @project, cluster) + .table-section.section-30 + .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Environment scope") + .table-mobile-content= cluster.environment_scope + .table-section.section-30 + .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Project namespace") + .table-mobile-content= cluster.platform_kubernetes&.actual_namespace + .table-section.section-10 + .table-mobile-header{ role: "rowheader" } + .table-mobile-content + %button.js-project-feature-toggle.project-feature-toggle{ type: "button", + class: "#{'is-checked' if cluster.enabled?} #{'is-disabled' if !cluster.can_toggle_cluster?}", + "aria-label": s_("ClusterIntegration|Toggle Kubernetes Cluster"), + disabled: !cluster.can_toggle_cluster?, + data: { endpoint: namespace_project_cluster_path(@project.namespace, @project, cluster, format: :json) } } + %input.js-project-feature-toggle-input{ type: "hidden", value: cluster.enabled? } + = icon("spinner spin", class: "loading-icon") + %span.toggle-icon + = sprite_icon('status_success_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-checked') + = sprite_icon('status_failed_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-unchecked') diff --git a/app/views/clusters/_empty_state.html.haml b/app/views/clusters/_empty_state.html.haml new file mode 100644 index 00000000000..b8a3556a206 --- /dev/null +++ b/app/views/clusters/_empty_state.html.haml @@ -0,0 +1,12 @@ +.row.empty-state + .col-12 + .svg-content= image_tag 'illustrations/clusters_empty.svg' + .col-12 + .text-content + %h4.text-center= s_('ClusterIntegration|Integrate Kubernetes cluster automation') + - link_to_help_page = link_to(_('Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') + %p= s_('ClusterIntegration|Kubernetes clusters allow you to use review apps, deploy your applications, run your pipelines, and much more in an easy way. %{link_to_help_page}').html_safe % { link_to_help_page: link_to_help_page} + + - if can?(current_user, :create_cluster, @project) + .text-center + = link_to s_('ClusterIntegration|Add Kubernetes cluster'), new_project_cluster_path(@project), class: 'btn btn-success' diff --git a/app/views/clusters/_gcp_signup_offer_banner.html.haml b/app/views/clusters/_gcp_signup_offer_banner.html.haml new file mode 100644 index 00000000000..73b11d509d3 --- /dev/null +++ b/app/views/clusters/_gcp_signup_offer_banner.html.haml @@ -0,0 +1,12 @@ +- link = link_to(s_('ClusterIntegration|sign up'), 'https://console.cloud.google.com/freetrial?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') +.bs-callout.gcp-signup-offer.alert.alert-block.alert-dismissable.prepend-top-default.append-bottom-default{ role: 'alert' } + %button.close{ type: "button", data: { feature_id: UserCalloutsHelper::GCP_SIGNUP_OFFER, dismiss_endpoint: user_callouts_path } } × + .gcp-signup-offer--content + .gcp-signup-offer--icon.append-right-8 + = sprite_icon("information", size: 16) + .gcp-signup-offer--copy + %h4= s_('ClusterIntegration|Did you know?') + %p= s_('ClusterIntegration|Every new Google Cloud Platform (GCP) account receives $300 in credit upon %{sign_up_link}. In partnership with Google, GitLab is able to offer an additional $200 for both new and existing GCP accounts to get started with GitLab\'s Google Kubernetes Engine Integration.').html_safe % { sign_up_link: link } + %a.btn.btn-default{ href: 'https://goo.gl/AaJzRW', target: '_blank', rel: 'noopener noreferrer' } + Apply for credit + diff --git a/app/views/clusters/_integration_form.html.haml b/app/views/clusters/_integration_form.html.haml new file mode 100644 index 00000000000..d0a553e3414 --- /dev/null +++ b/app/views/clusters/_integration_form.html.haml @@ -0,0 +1,31 @@ += form_for @cluster, url: namespace_project_cluster_path(@project.namespace, @project, @cluster), as: :cluster do |field| + = form_errors(@cluster) + .form-group + %h5= s_('ClusterIntegration|Integration status') + %label.append-bottom-0.js-cluster-enable-toggle-area + %button{ type: 'button', + class: "js-project-feature-toggle project-feature-toggle #{'is-checked' if @cluster.enabled?} #{'is-disabled' unless can?(current_user, :update_cluster, @cluster)}", + "aria-label": s_("ClusterIntegration|Toggle Kubernetes cluster"), + disabled: !can?(current_user, :update_cluster, @cluster) } + = field.hidden_field :enabled, { class: 'js-project-feature-toggle-input'} + %span.toggle-icon + = sprite_icon('status_success_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-checked') + = 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?(@project) + .form-group + %h5= s_('ClusterIntegration|Environment scope') + = 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.") + + - if can?(current_user, :update_cluster, @cluster) + .form-group + = field.submit _('Save changes'), class: 'btn btn-success' + + - unless has_multiple_clusters?(@project) + %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/app/views/clusters/_sidebar.html.haml b/app/views/clusters/_sidebar.html.haml new file mode 100644 index 00000000000..3d10348212f --- /dev/null +++ b/app/views/clusters/_sidebar.html.haml @@ -0,0 +1,9 @@ +- clusters_help_url = help_page_path('user/project/clusters/index.md') +- help_link_start = "".html_safe +- help_link_end = ''.html_safe +%h4.prepend-top-0 + = s_('ClusterIntegration|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/app/views/clusters/gcp/_form.html.haml b/app/views/clusters/gcp/_form.html.haml new file mode 100644 index 00000000000..171ceeceb68 --- /dev/null +++ b/app/views/clusters/gcp/_form.html.haml @@ -0,0 +1,74 @@ += javascript_include_tag 'https://apis.google.com/js/api.js' +- external_link_icon = icon('external-link') +- zones_link_url = 'https://cloud.google.com/compute/docs/regions-zones/regions-zones' +- machine_type_link_url = 'https://cloud.google.com/compute/docs/machine-types' +- pricing_link_url = 'https://cloud.google.com/compute/pricing#machinetype' +- help_link_start = ''.html_safe +- help_link_end = ' %{external_link_icon}'.html_safe % { external_link_icon: external_link_icon } + +%p + - link_to_help_page = link_to(s_('ClusterIntegration|help page'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|Read our %{link_to_help_page} on Kubernetes cluster integration.').html_safe % { link_to_help_page: link_to_help_page} + +%p= link_to('Select a different Google account', @authorize_url) + += form_for @gcp_cluster, html: { class: 'js-gke-cluster-creation prepend-top-20', data: { token: token_in_session } }, url: create_gcp_namespace_project_clusters_path(@project.namespace, @project), as: :cluster do |field| + = form_errors(@gcp_cluster) + .form-group + = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' + = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') + .form-group + = field.label :environment_scope, s_('ClusterIntegration|Environment scope'), class: 'label-bold' + = field.text_field :environment_scope, class: 'form-control', readonly: !has_multiple_clusters?(@project), placeholder: s_('ClusterIntegration|Environment scope') + + = field.fields_for :provider_gcp, @gcp_cluster.provider_gcp do |provider_gcp_field| + .form-group + = provider_gcp_field.label :gcp_project_id, s_('ClusterIntegration|Google Cloud Platform project'), class: 'label-bold' + .js-gcp-project-id-dropdown-entry-point{ data: { docsUrl: 'https://console.cloud.google.com/home/dashboard' } } + = provider_gcp_field.hidden_field :gcp_project_id + .dropdown + %button.dropdown-menu-toggle.dropdown-menu-full-width{ type: 'button', disabled: true } + %span.dropdown-toggle-text + = _('Select project') + = icon('chevron-down') + %span.form-text.text-muted   + + .form-group + = provider_gcp_field.label :zone, s_('ClusterIntegration|Zone'), class: 'label-bold' + .js-gcp-zone-dropdown-entry-point + = provider_gcp_field.hidden_field :zone + .dropdown + %button.dropdown-menu-toggle.dropdown-menu-full-width{ type: 'button', disabled: true } + %span.dropdown-toggle-text + = _('Select project to choose zone') + = icon('chevron-down') + %p.form-text.text-muted + = s_('ClusterIntegration|Learn more about %{help_link_start}zones%{help_link_end}.').html_safe % { help_link_start: help_link_start % { url: zones_link_url }, help_link_end: help_link_end } + + .form-group + = provider_gcp_field.label :num_nodes, s_('ClusterIntegration|Number of nodes'), class: 'label-bold' + = provider_gcp_field.text_field :num_nodes, class: 'form-control', placeholder: '3' + + .form-group + = provider_gcp_field.label :machine_type, s_('ClusterIntegration|Machine type'), class: 'label-bold' + .js-gcp-machine-type-dropdown-entry-point + = provider_gcp_field.hidden_field :machine_type + .dropdown + %button.dropdown-menu-toggle.dropdown-menu-full-width{ type: 'button', disabled: true } + %span.dropdown-toggle-text + = _('Select project and zone to choose machine type') + = icon('chevron-down') + %p.form-text.text-muted + = s_('ClusterIntegration|Learn more about %{help_link_start_machine_type}machine types%{help_link_end} and %{help_link_start_pricing}pricing%{help_link_end}.').html_safe % { help_link_start_machine_type: help_link_start % { url: machine_type_link_url }, help_link_start_pricing: help_link_start % { url: pricing_link_url }, help_link_end: help_link_end } + + .form-group + .form-check + = provider_gcp_field.check_box :legacy_abac, { class: 'form-check-input' }, false, true + = provider_gcp_field.label :legacy_abac, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' + .form-text.text-muted + = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') + = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') + = link_to _('More information'), help_page_path('user/project/clusters/index.md', anchor: 'role-based-access-control-rbac-core-only'), target: '_blank' + + .form-group + = field.submit s_('ClusterIntegration|Create Kubernetes cluster'), class: 'js-gke-cluster-creation-submit btn btn-success', disabled: true diff --git a/app/views/clusters/gcp/_header.html.haml b/app/views/clusters/gcp/_header.html.haml new file mode 100644 index 00000000000..a2ad3cd64df --- /dev/null +++ b/app/views/clusters/gcp/_header.html.haml @@ -0,0 +1,14 @@ +%h4 + = s_('ClusterIntegration|Enter the details for your Kubernetes cluster') +%p + = s_('ClusterIntegration|Please make sure that your Google account meets the following requirements:') +%ul + %li + - link_to_kubernetes_engine = link_to(s_('ClusterIntegration|access to Google Kubernetes Engine'), 'https://console.cloud.google.com/freetrial?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|Your account must have %{link_to_kubernetes_engine}').html_safe % { link_to_kubernetes_engine: link_to_kubernetes_engine } + %li + - link_to_requirements = link_to(s_('ClusterIntegration|meets the requirements'), 'https://cloud.google.com/kubernetes-engine/docs/quickstart?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|Make sure your account %{link_to_requirements} to create Kubernetes clusters').html_safe % { link_to_requirements: link_to_requirements } + %li + - link_to_container_project = link_to(s_('ClusterIntegration|Google Kubernetes Engine project'), 'https://console.cloud.google.com/home/dashboard?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|This account must have permissions to create a Kubernetes cluster in the %{link_to_container_project} specified below').html_safe % { link_to_container_project: link_to_container_project } diff --git a/app/views/clusters/gcp/_show.html.haml b/app/views/clusters/gcp/_show.html.haml new file mode 100644 index 00000000000..779c9c245c1 --- /dev/null +++ b/app/views/clusters/gcp/_show.html.haml @@ -0,0 +1,49 @@ +.form-group + %label.append-bottom-10{ for: 'cluster-name' } + = s_('ClusterIntegration|Kubernetes cluster name') + .input-group + %input.form-control.cluster-name.js-select-on-focus{ value: @cluster.name, readonly: true } + %span.input-group-append + = clipboard_button(text: @cluster.name, title: s_('ClusterIntegration|Copy Kubernetes cluster name'), class: 'input-group-text btn-default') + += form_for @cluster, url: namespace_project_cluster_path(@project.namespace, @project, @cluster), as: :cluster do |field| + = form_errors(@cluster) + + = field.fields_for :platform_kubernetes, @cluster.platform_kubernetes do |platform_kubernetes_field| + .form-group + = platform_kubernetes_field.label :api_url, s_('ClusterIntegration|API URL') + .input-group + = platform_kubernetes_field.text_field :api_url, class: 'form-control js-select-on-focus', placeholder: s_('ClusterIntegration|API URL'), readonly: true + %span.input-group-append + = clipboard_button(text: @cluster.platform_kubernetes.api_url, title: s_('ClusterIntegration|Copy API URL'), class: 'input-group-text btn-default') + + .form-group + = platform_kubernetes_field.label :ca_cert, s_('ClusterIntegration|CA Certificate') + .input-group + = platform_kubernetes_field.text_area :ca_cert, class: 'form-control js-select-on-focus', placeholder: s_('ClusterIntegration|Certificate Authority bundle (PEM format)'), readonly: true + %span.input-group-append.clipboard-addon + = clipboard_button(text: @cluster.platform_kubernetes.ca_cert, title: s_('ClusterIntegration|Copy CA Certificate'), class: 'input-group-text btn-blank') + + .form-group + = platform_kubernetes_field.label :token, s_('ClusterIntegration|Token') + .input-group + = platform_kubernetes_field.text_field :token, class: 'form-control js-cluster-token js-select-on-focus', type: 'password', placeholder: s_('ClusterIntegration|Token'), readonly: true + %span.input-group-append + %button.btn.btn-default.input-group-text.js-show-cluster-token{ type: 'button' } + = s_('ClusterIntegration|Show') + = clipboard_button(text: @cluster.platform_kubernetes.token, title: s_('ClusterIntegration|Copy Token'), class: 'btn-default') + + .form-group + = platform_kubernetes_field.label :namespace, s_('ClusterIntegration|Project namespace (optional, unique)') + = platform_kubernetes_field.text_field :namespace, class: 'form-control', placeholder: s_('ClusterIntegration|Project namespace') + + .form-group + .form-check + = platform_kubernetes_field.check_box :authorization_type, { class: 'form-check-input', disabled: true }, 'rbac', 'abac' + = platform_kubernetes_field.label :authorization_type, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' + .form-text.text-muted + = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') + = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') + + .form-group + = field.submit s_('ClusterIntegration|Save changes'), class: 'btn btn-success' diff --git a/app/views/clusters/index.html.haml b/app/views/clusters/index.html.haml new file mode 100644 index 00000000000..a55de84b5cd --- /dev/null +++ b/app/views/clusters/index.html.haml @@ -0,0 +1,24 @@ +- breadcrumb_title 'Kubernetes' +- page_title "Kubernetes Clusters" + += render_gcp_signup_offer + +.clusters-container + - if @clusters.empty? + = render "empty_state" + - else + .top-area.adjust + .nav-text + = s_("ClusterIntegration|Kubernetes clusters can be used to deploy applications and to provide Review Apps for this project") + .ci-table.js-clusters-list + .gl-responsive-table-row.table-row-header{ role: "row" } + .table-section.section-30{ role: "rowheader" } + = s_("ClusterIntegration|Kubernetes cluster") + .table-section.section-30{ role: "rowheader" } + = s_("ClusterIntegration|Environment scope") + .table-section.section-30{ role: "rowheader" } + = s_("ClusterIntegration|Project namespace") + .table-section.section-10{ role: "rowheader" } + - @clusters.each do |cluster| + = render "cluster", cluster: cluster.present(current_user: current_user) + = paginate @clusters, theme: "gitlab" diff --git a/app/views/clusters/new.html.haml b/app/views/clusters/new.html.haml new file mode 100644 index 00000000000..57cdbcd2d38 --- /dev/null +++ b/app/views/clusters/new.html.haml @@ -0,0 +1,36 @@ +- breadcrumb_title 'Kubernetes' +- page_title _("Kubernetes Cluster") +- active_tab = local_assigns.fetch(:active_tab, 'gcp') += javascript_include_tag 'https://apis.google.com/js/api.js' + += render_gcp_signup_offer + +.row.prepend-top-default + .col-md-3 + = render 'sidebar' + .col-md-9.js-toggle-container + %ul.nav-links.nav-tabs.gitlab-tabs.nav{ role: 'tablist' } + %li.nav-item{ role: 'presentation' } + %a.nav-link{ href: '#create-gcp-cluster-pane', id: 'create-gcp-cluster-tab', class: active_when(active_tab == 'gcp'), data: { toggle: 'tab' }, role: 'tab' } + %span Create new Cluster on GKE + %li.nav-item{ role: 'presentation' } + %a.nav-link{ href: '#add-user-cluster-pane', id: 'add-user-cluster-tab', class: active_when(active_tab == 'user'), data: { toggle: 'tab' }, role: 'tab' } + %span Add existing cluster + + .tab-content.gitlab-tab-content + .tab-pane{ id: 'create-gcp-cluster-pane', class: active_when(active_tab == 'gcp'), role: 'tabpanel' } + = render 'clusters/gcp/header' + - if @valid_gcp_token + = render 'clusters/gcp/form' + - elsif @authorize_url + .signin-with-google + = link_to(image_tag('auth_buttons/signin_with_google.png', width: '191px'), @authorize_url) + = _('or') + = link_to('create a new Google account', 'https://accounts.google.com/SignUpWithoutGmail?service=cloudconsole&continue=https%3A%2F%2Fconsole.cloud.google.com%2Ffreetrial%3Futm_campaign%3D2018_cpanel%26utm_source%3Dgitlab%26utm_medium%3Dreferral', target: '_blank', rel: 'noopener noreferrer') + - else + - link = link_to(s_('ClusterIntegration|properly configured'), help_page_path("integration/google"), target: '_blank', rel: 'noopener noreferrer') + = s_('Google authentication is not %{link_to_documentation}. Ask your GitLab administrator if you want to use this service.').html_safe % { link_to_documentation: link } + + .tab-pane{ id: 'add-user-cluster-pane', class: active_when(active_tab == 'user'), role: 'tabpanel' } + = render 'clusters/user/header' + = render 'clusters/user/form' diff --git a/app/views/clusters/show.html.haml b/app/views/clusters/show.html.haml new file mode 100644 index 00000000000..14416303827 --- /dev/null +++ b/app/views/clusters/show.html.haml @@ -0,0 +1,52 @@ +- @content_class = "limit-container-width" unless fluid_layout +- add_to_breadcrumbs "Kubernetes Clusters", project_clusters_path(@project) +- breadcrumb_title @cluster.name +- page_title _("Kubernetes Cluster") + +- expanded = Rails.env.test? + +- status_path = status_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster.id, format: :json) if can?(current_user, :admin_cluster, @cluster) +.edit-cluster-form.js-edit-cluster-form{ data: { status_path: status_path, + install_helm_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :helm), + install_ingress_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :ingress), + install_prometheus_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :prometheus), + install_runner_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :runner), + install_jupyter_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :jupyter), + toggle_status: @cluster.enabled? ? 'true': 'false', + cluster_status: @cluster.status_name, + cluster_status_reason: @cluster.status_reason, + help_path: help_page_path('user/project/clusters/index.md', anchor: 'installing-applications'), + ingress_help_path: help_page_path('user/project/clusters/index.md', anchor: 'getting-the-external-ip-address'), + ingress_dns_help_path: help_page_path('topics/autodevops/quick_start_guide.md', anchor: 'point-dns-at-cluster-ip'), + manage_prometheus_path: edit_project_service_path(@cluster.project, 'prometheus') } } + + .js-cluster-application-notice + .flash-container + + %section#cluster-integration + %h4= @cluster.name + = render 'banner' + = render 'integration_form' + + .cluster-applications-table#js-cluster-applications + + %section.settings#js-cluster-details{ class: ('expanded' if expanded) } + .settings-header + %h4= s_('ClusterIntegration|Kubernetes cluster details') + %button.btn.js-settings-toggle{ type: 'button' } + = expanded ? 'Collapse' : 'Expand' + %p= s_('ClusterIntegration|See and edit the details for your Kubernetes cluster') + .settings-content + - if @cluster.managed? + = render 'clusters/gcp/show' + - else + = render 'clusters/user/show' + + %section.settings.no-animate#js-cluster-advanced-settings{ class: ('expanded' if expanded) } + .settings-header + %h4= _('Advanced settings') + %button.btn.js-settings-toggle{ type: 'button' } + = expanded ? 'Collapse' : 'Expand' + %p= s_("ClusterIntegration|Advanced options on this Kubernetes cluster's integration") + .settings-content + = render 'advanced_settings' diff --git a/app/views/clusters/user/_form.html.haml b/app/views/clusters/user/_form.html.haml new file mode 100644 index 00000000000..54a6e685bb0 --- /dev/null +++ b/app/views/clusters/user/_form.html.haml @@ -0,0 +1,38 @@ += form_for @user_cluster, url: create_user_namespace_project_clusters_path(@project.namespace, @project), as: :cluster do |field| + = form_errors(@user_cluster) + .form-group + = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' + = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') + - if has_multiple_clusters?(@project) + .form-group + = field.label :environment_scope, s_('ClusterIntegration|Environment scope'), class: 'label-bold' + = field.text_field :environment_scope, class: 'form-control', placeholder: s_('ClusterIntegration|Environment scope') + + = field.fields_for :platform_kubernetes, @user_cluster.platform_kubernetes do |platform_kubernetes_field| + .form-group + = platform_kubernetes_field.label :api_url, s_('ClusterIntegration|API URL'), class: 'label-bold' + = platform_kubernetes_field.text_field :api_url, class: 'form-control', placeholder: s_('ClusterIntegration|API URL') + + .form-group + = platform_kubernetes_field.label :ca_cert, s_('ClusterIntegration|CA Certificate'), class: 'label-bold' + = platform_kubernetes_field.text_area :ca_cert, class: 'form-control', placeholder: s_('ClusterIntegration|Certificate Authority bundle (PEM format)') + + .form-group + = platform_kubernetes_field.label :token, s_('ClusterIntegration|Token'), class: 'label-bold' + = platform_kubernetes_field.text_field :token, class: 'form-control', placeholder: s_('ClusterIntegration|Service token'), autocomplete: 'off' + + .form-group + = platform_kubernetes_field.label :namespace, s_('ClusterIntegration|Project namespace (optional, unique)'), class: 'label-bold' + = platform_kubernetes_field.text_field :namespace, class: 'form-control', placeholder: s_('ClusterIntegration|Project namespace') + + .form-group + .form-check + = platform_kubernetes_field.check_box :authorization_type, { class: 'form-check-input qa-rbac-checkbox' }, 'rbac', 'abac' + = platform_kubernetes_field.label :authorization_type, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' + .form-text.text-muted + = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') + = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') + = link_to _('More information'), help_page_path('user/project/clusters/index.md', anchor: 'role-based-access-control-rbac-core-only'), target: '_blank' + + .form-group + = field.submit s_('ClusterIntegration|Add Kubernetes cluster'), class: 'btn btn-success' diff --git a/app/views/clusters/user/_header.html.haml b/app/views/clusters/user/_header.html.haml new file mode 100644 index 00000000000..749177fa6c1 --- /dev/null +++ b/app/views/clusters/user/_header.html.haml @@ -0,0 +1,5 @@ +%h4 + = s_('ClusterIntegration|Enter the details for your Kubernetes cluster') +%p + - link_to_help_page = link_to(s_('ClusterIntegration|documentation'), help_page_path('user/project/clusters/index', anchor: 'adding-an-existing-kubernetes-cluster'), target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|Please enter access information for your Kubernetes cluster. If you need help, you can read our %{link_to_help_page} on Kubernetes').html_safe % { link_to_help_page: link_to_help_page } diff --git a/app/views/clusters/user/_show.html.haml b/app/views/clusters/user/_show.html.haml new file mode 100644 index 00000000000..5b57f7ceb7d --- /dev/null +++ b/app/views/clusters/user/_show.html.haml @@ -0,0 +1,38 @@ += form_for @cluster, url: namespace_project_cluster_path(@project.namespace, @project, @cluster), as: :cluster do |field| + = form_errors(@cluster) + .form-group + = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' + = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') + + = field.fields_for :platform_kubernetes, @cluster.platform_kubernetes do |platform_kubernetes_field| + .form-group + = platform_kubernetes_field.label :api_url, s_('ClusterIntegration|API URL'), class: 'label-bold' + = platform_kubernetes_field.text_field :api_url, class: 'form-control', placeholder: s_('ClusterIntegration|API URL') + + .form-group + = platform_kubernetes_field.label :ca_cert, s_('ClusterIntegration|CA Certificate'), class: 'label-bold' + = platform_kubernetes_field.text_area :ca_cert, class: 'form-control', placeholder: s_('ClusterIntegration|Certificate Authority bundle (PEM format)') + + .form-group + = platform_kubernetes_field.label :token, s_('ClusterIntegration|Token'), class: 'label-bold' + .input-group + = platform_kubernetes_field.text_field :token, class: 'form-control js-cluster-token', type: 'password', placeholder: s_('ClusterIntegration|Token'), autocomplete: 'off' + %span.input-group-append.clipboard-addon + .input-group-text + %button.js-show-cluster-token.btn-blank{ type: 'button' } + = s_('ClusterIntegration|Show') + + .form-group + = platform_kubernetes_field.label :namespace, s_('ClusterIntegration|Project namespace (optional, unique)'), class: 'label-bold' + = platform_kubernetes_field.text_field :namespace, class: 'form-control', placeholder: s_('ClusterIntegration|Project namespace') + + .form-group + .form-check + = platform_kubernetes_field.check_box :authorization_type, { class: 'form-check-input', disabled: true }, 'rbac', 'abac' + = platform_kubernetes_field.label :authorization_type, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' + .form-text.text-muted + = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') + = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') + + .form-group + = field.submit s_('ClusterIntegration|Save changes'), class: 'btn btn-success' -- cgit v1.2.1 From 88800abcd8741b07114c2850e00b74fbecfbf90e Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Fri, 19 Oct 2018 14:42:30 +1300 Subject: Abstract out project out of ClustersController To the extent possible swap out `project` with `clusterable` - Abstract paths for showing cluster or clusters. This will allow us to swap in alternative paths for group level cluster - Push :project_id and :namespace_id params from the URL to the POST body. - Create a nice helper for to generate links for the destroy action For some reason, spec :project_id and :namespace_id param are not going through `to_param` for a JSON format. Manually call `to_param` to fix specs. - Move :layout to BaseController --- app/views/clusters/_advanced_settings.html.haml | 2 +- app/views/clusters/_cluster.html.haml | 4 ++-- app/views/clusters/_empty_state.html.haml | 4 ++-- app/views/clusters/_integration_form.html.haml | 7 ++++--- app/views/clusters/gcp/_form.html.haml | 5 +++-- app/views/clusters/gcp/_show.html.haml | 3 ++- app/views/clusters/show.html.haml | 17 +++++++++-------- app/views/clusters/user/_form.html.haml | 5 +++-- app/views/clusters/user/_show.html.haml | 3 ++- 9 files changed, 28 insertions(+), 22 deletions(-) (limited to 'app/views/clusters') diff --git a/app/views/clusters/_advanced_settings.html.haml b/app/views/clusters/_advanced_settings.html.haml index 243e8cd9ba0..c91202d9359 100644 --- a/app/views/clusters/_advanced_settings.html.haml +++ b/app/views/clusters/_advanced_settings.html.haml @@ -12,4 +12,4 @@ = s_('ClusterIntegration|Remove Kubernetes cluster integration') %p = s_("ClusterIntegration|Remove this Kubernetes cluster's configuration from this project. This will not delete your actual Kubernetes cluster.") - = link_to(s_('ClusterIntegration|Remove integration'), namespace_project_cluster_path(@project.namespace, @project, @cluster.id), method: :delete, class: 'btn btn-danger', data: { confirm: s_("ClusterIntegration|Are you sure you want to remove this Kubernetes cluster's integration? This will not delete your actual Kubernetes cluster.")}) + = link_to(s_('ClusterIntegration|Remove integration'), cluster_path(@cluster, clusterable_params), method: :delete, class: 'btn btn-danger', data: { confirm: s_("ClusterIntegration|Are you sure you want to remove this Kubernetes cluster's integration? This will not delete your actual Kubernetes cluster.")}) diff --git a/app/views/clusters/_cluster.html.haml b/app/views/clusters/_cluster.html.haml index 2d7f7c6b1fb..a3dcbc25399 100644 --- a/app/views/clusters/_cluster.html.haml +++ b/app/views/clusters/_cluster.html.haml @@ -2,7 +2,7 @@ .table-section.section-30 .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Kubernetes cluster") .table-mobile-content - = link_to cluster.name, namespace_project_cluster_path(@project.namespace, @project, cluster) + = link_to cluster.name, cluster_page_path(cluster) .table-section.section-30 .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Environment scope") .table-mobile-content= cluster.environment_scope @@ -16,7 +16,7 @@ class: "#{'is-checked' if cluster.enabled?} #{'is-disabled' if !cluster.can_toggle_cluster?}", "aria-label": s_("ClusterIntegration|Toggle Kubernetes Cluster"), disabled: !cluster.can_toggle_cluster?, - data: { endpoint: namespace_project_cluster_path(@project.namespace, @project, cluster, format: :json) } } + data: { endpoint: cluster_path(cluster, clusterable_params.merge(format: :json)) } } %input.js-project-feature-toggle-input{ type: "hidden", value: cluster.enabled? } = icon("spinner spin", class: "loading-icon") %span.toggle-icon diff --git a/app/views/clusters/_empty_state.html.haml b/app/views/clusters/_empty_state.html.haml index b8a3556a206..200c19e45b1 100644 --- a/app/views/clusters/_empty_state.html.haml +++ b/app/views/clusters/_empty_state.html.haml @@ -7,6 +7,6 @@ - link_to_help_page = link_to(_('Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') %p= s_('ClusterIntegration|Kubernetes clusters allow you to use review apps, deploy your applications, run your pipelines, and much more in an easy way. %{link_to_help_page}').html_safe % { link_to_help_page: link_to_help_page} - - if can?(current_user, :create_cluster, @project) + - if can_create_cluster? .text-center - = link_to s_('ClusterIntegration|Add Kubernetes cluster'), new_project_cluster_path(@project), class: 'btn btn-success' + = link_to s_('ClusterIntegration|Add Kubernetes cluster'), new_cluster_page_path, class: 'btn btn-success' diff --git a/app/views/clusters/_integration_form.html.haml b/app/views/clusters/_integration_form.html.haml index d0a553e3414..4b259f02abb 100644 --- a/app/views/clusters/_integration_form.html.haml +++ b/app/views/clusters/_integration_form.html.haml @@ -1,5 +1,6 @@ -= form_for @cluster, url: namespace_project_cluster_path(@project.namespace, @project, @cluster), as: :cluster do |field| += form_for @cluster, url: cluster_path(@cluster), as: :cluster do |field| = form_errors(@cluster) + = hidden_clusterable_fields .form-group %h5= s_('ClusterIntegration|Integration status') %label.append-bottom-0.js-cluster-enable-toggle-area @@ -13,7 +14,7 @@ = 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?(@project) + - if has_multiple_clusters? .form-group %h5= s_('ClusterIntegration|Environment scope') = field.text_field :environment_scope, class: 'col-md-6 form-control js-select-on-focus', placeholder: s_('ClusterIntegration|Environment scope') @@ -23,7 +24,7 @@ .form-group = field.submit _('Save changes'), class: 'btn btn-success' - - unless has_multiple_clusters?(@project) + - unless has_multiple_clusters? %h5= s_('ClusterIntegration|Environment scope') %p %code * diff --git a/app/views/clusters/gcp/_form.html.haml b/app/views/clusters/gcp/_form.html.haml index 171ceeceb68..56a5eb630cf 100644 --- a/app/views/clusters/gcp/_form.html.haml +++ b/app/views/clusters/gcp/_form.html.haml @@ -12,14 +12,15 @@ %p= link_to('Select a different Google account', @authorize_url) -= form_for @gcp_cluster, html: { class: 'js-gke-cluster-creation prepend-top-20', data: { token: token_in_session } }, url: create_gcp_namespace_project_clusters_path(@project.namespace, @project), as: :cluster do |field| += form_for @gcp_cluster, html: { class: 'js-gke-cluster-creation prepend-top-20', data: { token: token_in_session } }, url: create_gcp_clusters_path, as: :cluster do |field| = form_errors(@gcp_cluster) + = hidden_clusterable_fields .form-group = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') .form-group = field.label :environment_scope, s_('ClusterIntegration|Environment scope'), class: 'label-bold' - = field.text_field :environment_scope, class: 'form-control', readonly: !has_multiple_clusters?(@project), placeholder: s_('ClusterIntegration|Environment scope') + = field.text_field :environment_scope, class: 'form-control', readonly: !has_multiple_clusters?, placeholder: s_('ClusterIntegration|Environment scope') = field.fields_for :provider_gcp, @gcp_cluster.provider_gcp do |provider_gcp_field| .form-group diff --git a/app/views/clusters/gcp/_show.html.haml b/app/views/clusters/gcp/_show.html.haml index 779c9c245c1..d5f9ec8ee66 100644 --- a/app/views/clusters/gcp/_show.html.haml +++ b/app/views/clusters/gcp/_show.html.haml @@ -6,8 +6,9 @@ %span.input-group-append = clipboard_button(text: @cluster.name, title: s_('ClusterIntegration|Copy Kubernetes cluster name'), class: 'input-group-text btn-default') -= form_for @cluster, url: namespace_project_cluster_path(@project.namespace, @project, @cluster), as: :cluster do |field| += form_for @cluster, url: cluster_path(@cluster), as: :cluster do |field| = form_errors(@cluster) + = hidden_clusterable_fields = field.fields_for :platform_kubernetes, @cluster.platform_kubernetes do |platform_kubernetes_field| .form-group diff --git a/app/views/clusters/show.html.haml b/app/views/clusters/show.html.haml index 14416303827..dd48ffb8ef7 100644 --- a/app/views/clusters/show.html.haml +++ b/app/views/clusters/show.html.haml @@ -1,24 +1,25 @@ - @content_class = "limit-container-width" unless fluid_layout -- add_to_breadcrumbs "Kubernetes Clusters", project_clusters_path(@project) +- add_to_breadcrumbs "Kubernetes Clusters", clusters_page_path - breadcrumb_title @cluster.name - page_title _("Kubernetes Cluster") +- manage_prometheus_path = edit_project_service_path(@cluster.project, 'prometheus') if @project - expanded = Rails.env.test? -- status_path = status_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster.id, format: :json) if can?(current_user, :admin_cluster, @cluster) +- status_path = status_cluster_path(@cluster.id, clusterable_params.merge(format: :json)) if can?(current_user, :admin_cluster, @cluster) .edit-cluster-form.js-edit-cluster-form{ data: { status_path: status_path, - install_helm_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :helm), - install_ingress_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :ingress), - install_prometheus_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :prometheus), - install_runner_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :runner), - install_jupyter_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :jupyter), + install_helm_path: install_applications_cluster_path(@cluster, :helm, clusterable_params), + install_ingress_path: install_applications_cluster_path(@cluster, :ingress, clusterable_params), + install_prometheus_path: install_applications_cluster_path(@cluster, :prometheus, clusterable_params), + install_runner_path: install_applications_cluster_path(@cluster, :runner, clusterable_params), + install_jupyter_path: install_applications_cluster_path(@cluster, :jupyter, clusterable_params), toggle_status: @cluster.enabled? ? 'true': 'false', cluster_status: @cluster.status_name, cluster_status_reason: @cluster.status_reason, help_path: help_page_path('user/project/clusters/index.md', anchor: 'installing-applications'), ingress_help_path: help_page_path('user/project/clusters/index.md', anchor: 'getting-the-external-ip-address'), ingress_dns_help_path: help_page_path('topics/autodevops/quick_start_guide.md', anchor: 'point-dns-at-cluster-ip'), - manage_prometheus_path: edit_project_service_path(@cluster.project, 'prometheus') } } + manage_prometheus_path: manage_prometheus_path } } .js-cluster-application-notice .flash-container diff --git a/app/views/clusters/user/_form.html.haml b/app/views/clusters/user/_form.html.haml index 54a6e685bb0..05462d27b99 100644 --- a/app/views/clusters/user/_form.html.haml +++ b/app/views/clusters/user/_form.html.haml @@ -1,9 +1,10 @@ -= form_for @user_cluster, url: create_user_namespace_project_clusters_path(@project.namespace, @project), as: :cluster do |field| += form_for @user_cluster, url: create_user_clusters_path, as: :cluster do |field| = form_errors(@user_cluster) + = hidden_clusterable_fields .form-group = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') - - if has_multiple_clusters?(@project) + - if has_multiple_clusters? .form-group = field.label :environment_scope, s_('ClusterIntegration|Environment scope'), class: 'label-bold' = field.text_field :environment_scope, class: 'form-control', placeholder: s_('ClusterIntegration|Environment scope') diff --git a/app/views/clusters/user/_show.html.haml b/app/views/clusters/user/_show.html.haml index 5b57f7ceb7d..57f6cd1f43d 100644 --- a/app/views/clusters/user/_show.html.haml +++ b/app/views/clusters/user/_show.html.haml @@ -1,5 +1,6 @@ -= form_for @cluster, url: namespace_project_cluster_path(@project.namespace, @project, @cluster), as: :cluster do |field| += form_for @cluster, url: cluster_path(@cluster), as: :cluster do |field| = form_errors(@cluster) + = hidden_clusterable_fields .form-group = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') -- cgit v1.2.1 From 1163b235391668d53ae0cea80bc22d40b365e0a7 Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Tue, 30 Oct 2018 23:33:43 +1300 Subject: Move view and path concerns to presenters - Move show path for cluster to ClusterPresenter - Create ClusterablePresenter to encapsulate logic. Consolidates scattered methods from BaseController and ClustersHelper into an object. --- app/views/clusters/_advanced_settings.html.haml | 2 +- app/views/clusters/_cluster.html.haml | 4 ++-- app/views/clusters/_empty_state.html.haml | 4 ++-- app/views/clusters/show.html.haml | 14 +++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'app/views/clusters') diff --git a/app/views/clusters/_advanced_settings.html.haml b/app/views/clusters/_advanced_settings.html.haml index c91202d9359..e25076248d2 100644 --- a/app/views/clusters/_advanced_settings.html.haml +++ b/app/views/clusters/_advanced_settings.html.haml @@ -12,4 +12,4 @@ = s_('ClusterIntegration|Remove Kubernetes cluster integration') %p = s_("ClusterIntegration|Remove this Kubernetes cluster's configuration from this project. This will not delete your actual Kubernetes cluster.") - = link_to(s_('ClusterIntegration|Remove integration'), cluster_path(@cluster, clusterable_params), method: :delete, class: 'btn btn-danger', data: { confirm: s_("ClusterIntegration|Are you sure you want to remove this Kubernetes cluster's integration? This will not delete your actual Kubernetes cluster.")}) + = link_to(s_('ClusterIntegration|Remove integration'), cluster_path(@cluster, clusterable.clusterable_params), method: :delete, class: 'btn btn-danger', data: { confirm: s_("ClusterIntegration|Are you sure you want to remove this Kubernetes cluster's integration? This will not delete your actual Kubernetes cluster.")}) diff --git a/app/views/clusters/_cluster.html.haml b/app/views/clusters/_cluster.html.haml index a3dcbc25399..709d6711f33 100644 --- a/app/views/clusters/_cluster.html.haml +++ b/app/views/clusters/_cluster.html.haml @@ -2,7 +2,7 @@ .table-section.section-30 .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Kubernetes cluster") .table-mobile-content - = link_to cluster.name, cluster_page_path(cluster) + = link_to cluster.name, cluster.show_path .table-section.section-30 .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Environment scope") .table-mobile-content= cluster.environment_scope @@ -16,7 +16,7 @@ class: "#{'is-checked' if cluster.enabled?} #{'is-disabled' if !cluster.can_toggle_cluster?}", "aria-label": s_("ClusterIntegration|Toggle Kubernetes Cluster"), disabled: !cluster.can_toggle_cluster?, - data: { endpoint: cluster_path(cluster, clusterable_params.merge(format: :json)) } } + data: { endpoint: cluster_path(cluster, clusterable.clusterable_params.merge(format: :json)) } } %input.js-project-feature-toggle-input{ type: "hidden", value: cluster.enabled? } = icon("spinner spin", class: "loading-icon") %span.toggle-icon diff --git a/app/views/clusters/_empty_state.html.haml b/app/views/clusters/_empty_state.html.haml index 200c19e45b1..800e76d92ef 100644 --- a/app/views/clusters/_empty_state.html.haml +++ b/app/views/clusters/_empty_state.html.haml @@ -7,6 +7,6 @@ - link_to_help_page = link_to(_('Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') %p= s_('ClusterIntegration|Kubernetes clusters allow you to use review apps, deploy your applications, run your pipelines, and much more in an easy way. %{link_to_help_page}').html_safe % { link_to_help_page: link_to_help_page} - - if can_create_cluster? + - if clusterable.can_create_cluster? .text-center - = link_to s_('ClusterIntegration|Add Kubernetes cluster'), new_cluster_page_path, class: 'btn btn-success' + = link_to s_('ClusterIntegration|Add Kubernetes cluster'), clusterable.new_path, class: 'btn btn-success' diff --git a/app/views/clusters/show.html.haml b/app/views/clusters/show.html.haml index dd48ffb8ef7..c0169fbf5a2 100644 --- a/app/views/clusters/show.html.haml +++ b/app/views/clusters/show.html.haml @@ -1,18 +1,18 @@ - @content_class = "limit-container-width" unless fluid_layout -- add_to_breadcrumbs "Kubernetes Clusters", clusters_page_path +- add_to_breadcrumbs "Kubernetes Clusters", clusterable.index_path - breadcrumb_title @cluster.name - page_title _("Kubernetes Cluster") - manage_prometheus_path = edit_project_service_path(@cluster.project, 'prometheus') if @project - expanded = Rails.env.test? -- status_path = status_cluster_path(@cluster.id, clusterable_params.merge(format: :json)) if can?(current_user, :admin_cluster, @cluster) +- status_path = status_cluster_path(@cluster.id, clusterable.clusterable_params.merge(format: :json)) if can?(current_user, :admin_cluster, @cluster) .edit-cluster-form.js-edit-cluster-form{ data: { status_path: status_path, - install_helm_path: install_applications_cluster_path(@cluster, :helm, clusterable_params), - install_ingress_path: install_applications_cluster_path(@cluster, :ingress, clusterable_params), - install_prometheus_path: install_applications_cluster_path(@cluster, :prometheus, clusterable_params), - install_runner_path: install_applications_cluster_path(@cluster, :runner, clusterable_params), - install_jupyter_path: install_applications_cluster_path(@cluster, :jupyter, clusterable_params), + install_helm_path: install_applications_cluster_path(@cluster, :helm, clusterable.clusterable_params), + install_ingress_path: install_applications_cluster_path(@cluster, :ingress, clusterable.clusterable_params), + install_prometheus_path: install_applications_cluster_path(@cluster, :prometheus, clusterable.clusterable_params), + install_runner_path: install_applications_cluster_path(@cluster, :runner, clusterable.clusterable_params), + install_jupyter_path: install_applications_cluster_path(@cluster, :jupyter, clusterable.clusterable_params), toggle_status: @cluster.enabled? ? 'true': 'false', cluster_status: @cluster.status_name, cluster_status_reason: @cluster.status_reason, -- cgit v1.2.1 From 1a1fdf8efe1923ba781e978e858c009264020e72 Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Thu, 1 Nov 2018 13:39:01 +1300 Subject: Resolve controller sharing concern Use ClustersController as base while having Projects::ClustersController to inform what `clusterable` is. Thanks @ayufan for the great suggestion ! - View changes to work with new approach - Fix javascript for new approach - Fix feature specs for new approach - Fix QA --- app/views/clusters/_advanced_settings.html.haml | 15 ----- app/views/clusters/_banner.html.haml | 15 ----- app/views/clusters/_cluster.html.haml | 24 ------- app/views/clusters/_empty_state.html.haml | 12 ---- .../clusters/_gcp_signup_offer_banner.html.haml | 12 ---- app/views/clusters/_integration_form.html.haml | 32 --------- app/views/clusters/_sidebar.html.haml | 9 --- .../clusters/clusters/_advanced_settings.html.haml | 15 +++++ app/views/clusters/clusters/_banner.html.haml | 15 +++++ app/views/clusters/clusters/_cluster.html.haml | 24 +++++++ app/views/clusters/clusters/_empty_state.html.haml | 12 ++++ .../clusters/_gcp_signup_offer_banner.html.haml | 12 ++++ .../clusters/clusters/_integration_form.html.haml | 32 +++++++++ app/views/clusters/clusters/_sidebar.html.haml | 9 +++ app/views/clusters/clusters/gcp/_form.html.haml | 75 ++++++++++++++++++++++ app/views/clusters/clusters/gcp/_header.html.haml | 14 ++++ app/views/clusters/clusters/gcp/_show.html.haml | 50 +++++++++++++++ app/views/clusters/clusters/index.html.haml | 24 +++++++ app/views/clusters/clusters/new.html.haml | 36 +++++++++++ app/views/clusters/clusters/show.html.haml | 53 +++++++++++++++ app/views/clusters/clusters/user/_form.html.haml | 39 +++++++++++ app/views/clusters/clusters/user/_header.html.haml | 5 ++ app/views/clusters/clusters/user/_show.html.haml | 39 +++++++++++ app/views/clusters/gcp/_form.html.haml | 75 ---------------------- app/views/clusters/gcp/_header.html.haml | 14 ---- app/views/clusters/gcp/_show.html.haml | 50 --------------- app/views/clusters/index.html.haml | 24 ------- app/views/clusters/new.html.haml | 36 ----------- app/views/clusters/show.html.haml | 53 --------------- app/views/clusters/user/_form.html.haml | 39 ----------- app/views/clusters/user/_header.html.haml | 5 -- app/views/clusters/user/_show.html.haml | 39 ----------- 32 files changed, 454 insertions(+), 454 deletions(-) delete mode 100644 app/views/clusters/_advanced_settings.html.haml delete mode 100644 app/views/clusters/_banner.html.haml delete mode 100644 app/views/clusters/_cluster.html.haml delete mode 100644 app/views/clusters/_empty_state.html.haml delete mode 100644 app/views/clusters/_gcp_signup_offer_banner.html.haml delete mode 100644 app/views/clusters/_integration_form.html.haml delete mode 100644 app/views/clusters/_sidebar.html.haml create mode 100644 app/views/clusters/clusters/_advanced_settings.html.haml create mode 100644 app/views/clusters/clusters/_banner.html.haml create mode 100644 app/views/clusters/clusters/_cluster.html.haml create mode 100644 app/views/clusters/clusters/_empty_state.html.haml create mode 100644 app/views/clusters/clusters/_gcp_signup_offer_banner.html.haml create mode 100644 app/views/clusters/clusters/_integration_form.html.haml create mode 100644 app/views/clusters/clusters/_sidebar.html.haml create mode 100644 app/views/clusters/clusters/gcp/_form.html.haml create mode 100644 app/views/clusters/clusters/gcp/_header.html.haml create mode 100644 app/views/clusters/clusters/gcp/_show.html.haml create mode 100644 app/views/clusters/clusters/index.html.haml create mode 100644 app/views/clusters/clusters/new.html.haml create mode 100644 app/views/clusters/clusters/show.html.haml create mode 100644 app/views/clusters/clusters/user/_form.html.haml create mode 100644 app/views/clusters/clusters/user/_header.html.haml create mode 100644 app/views/clusters/clusters/user/_show.html.haml delete mode 100644 app/views/clusters/gcp/_form.html.haml delete mode 100644 app/views/clusters/gcp/_header.html.haml delete mode 100644 app/views/clusters/gcp/_show.html.haml delete mode 100644 app/views/clusters/index.html.haml delete mode 100644 app/views/clusters/new.html.haml delete mode 100644 app/views/clusters/show.html.haml delete mode 100644 app/views/clusters/user/_form.html.haml delete mode 100644 app/views/clusters/user/_header.html.haml delete mode 100644 app/views/clusters/user/_show.html.haml (limited to 'app/views/clusters') diff --git a/app/views/clusters/_advanced_settings.html.haml b/app/views/clusters/_advanced_settings.html.haml deleted file mode 100644 index e25076248d2..00000000000 --- a/app/views/clusters/_advanced_settings.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -- if can?(current_user, :admin_cluster, @cluster) - - if @cluster.managed? - .append-bottom-20 - %label.append-bottom-10 - = s_('ClusterIntegration|Google Kubernetes Engine') - %p - - link_gke = link_to(s_('ClusterIntegration|Google Kubernetes Engine'), @cluster.gke_cluster_url, target: '_blank', rel: 'noopener noreferrer') - = s_('ClusterIntegration|Manage your Kubernetes cluster by visiting %{link_gke}').html_safe % { link_gke: link_gke } - - .sub-section.form-group - %h4.text-danger - = s_('ClusterIntegration|Remove Kubernetes cluster integration') - %p - = s_("ClusterIntegration|Remove this Kubernetes cluster's configuration from this project. This will not delete your actual Kubernetes cluster.") - = link_to(s_('ClusterIntegration|Remove integration'), cluster_path(@cluster, clusterable.clusterable_params), method: :delete, class: 'btn btn-danger', data: { confirm: s_("ClusterIntegration|Are you sure you want to remove this Kubernetes cluster's integration? This will not delete your actual Kubernetes cluster.")}) diff --git a/app/views/clusters/_banner.html.haml b/app/views/clusters/_banner.html.haml deleted file mode 100644 index 73cfea0ef92..00000000000 --- a/app/views/clusters/_banner.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -.hidden.js-cluster-error.bs-callout.bs-callout-danger{ role: 'alert' } - = s_('ClusterIntegration|Something went wrong while creating your Kubernetes cluster on Google Kubernetes Engine') - %p.js-error-reason - -.hidden.js-cluster-creating.bs-callout.bs-callout-info{ role: 'alert' } - = s_('ClusterIntegration|Kubernetes cluster is being created on Google Kubernetes Engine...') - -.hidden.js-cluster-success.bs-callout.bs-callout-success{ role: 'alert' } - = s_("ClusterIntegration|Kubernetes cluster was successfully created on Google Kubernetes Engine. Refresh the page to see Kubernetes cluster's details") - -- if show_cluster_security_warning? - .js-cluster-security-warning.alert.alert-block.alert-dismissable.bs-callout.bs-callout-warning - %button.close{ type: "button", data: { feature_id: UserCalloutsHelper::CLUSTER_SECURITY_WARNING, dismiss_endpoint: user_callouts_path } } × - = s_("ClusterIntegration|The default cluster configuration grants access to many functionalities needed to successfully build and deploy a containerised application.") - = link_to s_("More information"), help_page_path('user/project/clusters/index.md', anchor: 'security-implications') diff --git a/app/views/clusters/_cluster.html.haml b/app/views/clusters/_cluster.html.haml deleted file mode 100644 index 709d6711f33..00000000000 --- a/app/views/clusters/_cluster.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -.gl-responsive-table-row - .table-section.section-30 - .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Kubernetes cluster") - .table-mobile-content - = link_to cluster.name, cluster.show_path - .table-section.section-30 - .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Environment scope") - .table-mobile-content= cluster.environment_scope - .table-section.section-30 - .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Project namespace") - .table-mobile-content= cluster.platform_kubernetes&.actual_namespace - .table-section.section-10 - .table-mobile-header{ role: "rowheader" } - .table-mobile-content - %button.js-project-feature-toggle.project-feature-toggle{ type: "button", - class: "#{'is-checked' if cluster.enabled?} #{'is-disabled' if !cluster.can_toggle_cluster?}", - "aria-label": s_("ClusterIntegration|Toggle Kubernetes Cluster"), - disabled: !cluster.can_toggle_cluster?, - data: { endpoint: cluster_path(cluster, clusterable.clusterable_params.merge(format: :json)) } } - %input.js-project-feature-toggle-input{ type: "hidden", value: cluster.enabled? } - = icon("spinner spin", class: "loading-icon") - %span.toggle-icon - = sprite_icon('status_success_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-checked') - = sprite_icon('status_failed_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-unchecked') diff --git a/app/views/clusters/_empty_state.html.haml b/app/views/clusters/_empty_state.html.haml deleted file mode 100644 index 800e76d92ef..00000000000 --- a/app/views/clusters/_empty_state.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -.row.empty-state - .col-12 - .svg-content= image_tag 'illustrations/clusters_empty.svg' - .col-12 - .text-content - %h4.text-center= s_('ClusterIntegration|Integrate Kubernetes cluster automation') - - link_to_help_page = link_to(_('Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') - %p= s_('ClusterIntegration|Kubernetes clusters allow you to use review apps, deploy your applications, run your pipelines, and much more in an easy way. %{link_to_help_page}').html_safe % { link_to_help_page: link_to_help_page} - - - if clusterable.can_create_cluster? - .text-center - = link_to s_('ClusterIntegration|Add Kubernetes cluster'), clusterable.new_path, class: 'btn btn-success' diff --git a/app/views/clusters/_gcp_signup_offer_banner.html.haml b/app/views/clusters/_gcp_signup_offer_banner.html.haml deleted file mode 100644 index 73b11d509d3..00000000000 --- a/app/views/clusters/_gcp_signup_offer_banner.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -- link = link_to(s_('ClusterIntegration|sign up'), 'https://console.cloud.google.com/freetrial?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') -.bs-callout.gcp-signup-offer.alert.alert-block.alert-dismissable.prepend-top-default.append-bottom-default{ role: 'alert' } - %button.close{ type: "button", data: { feature_id: UserCalloutsHelper::GCP_SIGNUP_OFFER, dismiss_endpoint: user_callouts_path } } × - .gcp-signup-offer--content - .gcp-signup-offer--icon.append-right-8 - = sprite_icon("information", size: 16) - .gcp-signup-offer--copy - %h4= s_('ClusterIntegration|Did you know?') - %p= s_('ClusterIntegration|Every new Google Cloud Platform (GCP) account receives $300 in credit upon %{sign_up_link}. In partnership with Google, GitLab is able to offer an additional $200 for both new and existing GCP accounts to get started with GitLab\'s Google Kubernetes Engine Integration.').html_safe % { sign_up_link: link } - %a.btn.btn-default{ href: 'https://goo.gl/AaJzRW', target: '_blank', rel: 'noopener noreferrer' } - Apply for credit - diff --git a/app/views/clusters/_integration_form.html.haml b/app/views/clusters/_integration_form.html.haml deleted file mode 100644 index 4b259f02abb..00000000000 --- a/app/views/clusters/_integration_form.html.haml +++ /dev/null @@ -1,32 +0,0 @@ -= form_for @cluster, url: cluster_path(@cluster), as: :cluster do |field| - = form_errors(@cluster) - = hidden_clusterable_fields - .form-group - %h5= s_('ClusterIntegration|Integration status') - %label.append-bottom-0.js-cluster-enable-toggle-area - %button{ type: 'button', - class: "js-project-feature-toggle project-feature-toggle #{'is-checked' if @cluster.enabled?} #{'is-disabled' unless can?(current_user, :update_cluster, @cluster)}", - "aria-label": s_("ClusterIntegration|Toggle Kubernetes cluster"), - disabled: !can?(current_user, :update_cluster, @cluster) } - = field.hidden_field :enabled, { class: 'js-project-feature-toggle-input'} - %span.toggle-icon - = sprite_icon('status_success_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-checked') - = 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') - = 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.") - - - 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/app/views/clusters/_sidebar.html.haml b/app/views/clusters/_sidebar.html.haml deleted file mode 100644 index 3d10348212f..00000000000 --- a/app/views/clusters/_sidebar.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -- clusters_help_url = help_page_path('user/project/clusters/index.md') -- help_link_start = "".html_safe -- help_link_end = ''.html_safe -%h4.prepend-top-0 - = s_('ClusterIntegration|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/app/views/clusters/clusters/_advanced_settings.html.haml b/app/views/clusters/clusters/_advanced_settings.html.haml new file mode 100644 index 00000000000..7037c80aa6b --- /dev/null +++ b/app/views/clusters/clusters/_advanced_settings.html.haml @@ -0,0 +1,15 @@ +- if can?(current_user, :admin_cluster, @cluster) + - if @cluster.managed? + .append-bottom-20 + %label.append-bottom-10 + = s_('ClusterIntegration|Google Kubernetes Engine') + %p + - link_gke = link_to(s_('ClusterIntegration|Google Kubernetes Engine'), @cluster.gke_cluster_url, target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|Manage your Kubernetes cluster by visiting %{link_gke}').html_safe % { link_gke: link_gke } + + .sub-section.form-group + %h4.text-danger + = s_('ClusterIntegration|Remove Kubernetes cluster integration') + %p + = s_("ClusterIntegration|Remove this Kubernetes cluster's configuration from this project. This will not delete your actual Kubernetes cluster.") + = link_to(s_('ClusterIntegration|Remove integration'), clusterable.cluster_path(@cluster), method: :delete, class: 'btn btn-danger', data: { confirm: s_("ClusterIntegration|Are you sure you want to remove this Kubernetes cluster's integration? This will not delete your actual Kubernetes cluster.")}) diff --git a/app/views/clusters/clusters/_banner.html.haml b/app/views/clusters/clusters/_banner.html.haml new file mode 100644 index 00000000000..73cfea0ef92 --- /dev/null +++ b/app/views/clusters/clusters/_banner.html.haml @@ -0,0 +1,15 @@ +.hidden.js-cluster-error.bs-callout.bs-callout-danger{ role: 'alert' } + = s_('ClusterIntegration|Something went wrong while creating your Kubernetes cluster on Google Kubernetes Engine') + %p.js-error-reason + +.hidden.js-cluster-creating.bs-callout.bs-callout-info{ role: 'alert' } + = s_('ClusterIntegration|Kubernetes cluster is being created on Google Kubernetes Engine...') + +.hidden.js-cluster-success.bs-callout.bs-callout-success{ role: 'alert' } + = s_("ClusterIntegration|Kubernetes cluster was successfully created on Google Kubernetes Engine. Refresh the page to see Kubernetes cluster's details") + +- if show_cluster_security_warning? + .js-cluster-security-warning.alert.alert-block.alert-dismissable.bs-callout.bs-callout-warning + %button.close{ type: "button", data: { feature_id: UserCalloutsHelper::CLUSTER_SECURITY_WARNING, dismiss_endpoint: user_callouts_path } } × + = s_("ClusterIntegration|The default cluster configuration grants access to many functionalities needed to successfully build and deploy a containerised application.") + = link_to s_("More information"), help_page_path('user/project/clusters/index.md', anchor: 'security-implications') diff --git a/app/views/clusters/clusters/_cluster.html.haml b/app/views/clusters/clusters/_cluster.html.haml new file mode 100644 index 00000000000..facbcb7fc59 --- /dev/null +++ b/app/views/clusters/clusters/_cluster.html.haml @@ -0,0 +1,24 @@ +.gl-responsive-table-row + .table-section.section-30 + .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Kubernetes cluster") + .table-mobile-content + = link_to cluster.name, cluster.show_path + .table-section.section-30 + .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Environment scope") + .table-mobile-content= cluster.environment_scope + .table-section.section-30 + .table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Project namespace") + .table-mobile-content= cluster.platform_kubernetes&.actual_namespace + .table-section.section-10 + .table-mobile-header{ role: "rowheader" } + .table-mobile-content + %button.js-project-feature-toggle.project-feature-toggle{ type: "button", + class: "#{'is-checked' if cluster.enabled?} #{'is-disabled' if !cluster.can_toggle_cluster?}", + "aria-label": s_("ClusterIntegration|Toggle Kubernetes Cluster"), + disabled: !cluster.can_toggle_cluster?, + data: { endpoint: clusterable.cluster_path(cluster, format: :json) } } + %input.js-project-feature-toggle-input{ type: "hidden", value: cluster.enabled? } + = icon("spinner spin", class: "loading-icon") + %span.toggle-icon + = sprite_icon('status_success_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-checked') + = sprite_icon('status_failed_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-unchecked') diff --git a/app/views/clusters/clusters/_empty_state.html.haml b/app/views/clusters/clusters/_empty_state.html.haml new file mode 100644 index 00000000000..800e76d92ef --- /dev/null +++ b/app/views/clusters/clusters/_empty_state.html.haml @@ -0,0 +1,12 @@ +.row.empty-state + .col-12 + .svg-content= image_tag 'illustrations/clusters_empty.svg' + .col-12 + .text-content + %h4.text-center= s_('ClusterIntegration|Integrate Kubernetes cluster automation') + - link_to_help_page = link_to(_('Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') + %p= s_('ClusterIntegration|Kubernetes clusters allow you to use review apps, deploy your applications, run your pipelines, and much more in an easy way. %{link_to_help_page}').html_safe % { link_to_help_page: link_to_help_page} + + - if clusterable.can_create_cluster? + .text-center + = link_to s_('ClusterIntegration|Add Kubernetes cluster'), clusterable.new_path, class: 'btn btn-success' diff --git a/app/views/clusters/clusters/_gcp_signup_offer_banner.html.haml b/app/views/clusters/clusters/_gcp_signup_offer_banner.html.haml new file mode 100644 index 00000000000..73b11d509d3 --- /dev/null +++ b/app/views/clusters/clusters/_gcp_signup_offer_banner.html.haml @@ -0,0 +1,12 @@ +- link = link_to(s_('ClusterIntegration|sign up'), 'https://console.cloud.google.com/freetrial?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') +.bs-callout.gcp-signup-offer.alert.alert-block.alert-dismissable.prepend-top-default.append-bottom-default{ role: 'alert' } + %button.close{ type: "button", data: { feature_id: UserCalloutsHelper::GCP_SIGNUP_OFFER, dismiss_endpoint: user_callouts_path } } × + .gcp-signup-offer--content + .gcp-signup-offer--icon.append-right-8 + = sprite_icon("information", size: 16) + .gcp-signup-offer--copy + %h4= s_('ClusterIntegration|Did you know?') + %p= s_('ClusterIntegration|Every new Google Cloud Platform (GCP) account receives $300 in credit upon %{sign_up_link}. In partnership with Google, GitLab is able to offer an additional $200 for both new and existing GCP accounts to get started with GitLab\'s Google Kubernetes Engine Integration.').html_safe % { sign_up_link: link } + %a.btn.btn-default{ href: 'https://goo.gl/AaJzRW', target: '_blank', rel: 'noopener noreferrer' } + Apply for credit + diff --git a/app/views/clusters/clusters/_integration_form.html.haml b/app/views/clusters/clusters/_integration_form.html.haml new file mode 100644 index 00000000000..0792ad0085c --- /dev/null +++ b/app/views/clusters/clusters/_integration_form.html.haml @@ -0,0 +1,32 @@ += form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster do |field| + = form_errors(@cluster) + = hidden_clusterable_fields + .form-group + %h5= s_('ClusterIntegration|Integration status') + %label.append-bottom-0.js-cluster-enable-toggle-area + %button{ type: 'button', + class: "js-project-feature-toggle project-feature-toggle #{'is-checked' if @cluster.enabled?} #{'is-disabled' unless can?(current_user, :update_cluster, @cluster)}", + "aria-label": s_("ClusterIntegration|Toggle Kubernetes cluster"), + disabled: !can?(current_user, :update_cluster, @cluster) } + = field.hidden_field :enabled, { class: 'js-project-feature-toggle-input'} + %span.toggle-icon + = sprite_icon('status_success_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-checked') + = 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') + = 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.") + + - 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/app/views/clusters/clusters/_sidebar.html.haml b/app/views/clusters/clusters/_sidebar.html.haml new file mode 100644 index 00000000000..3d10348212f --- /dev/null +++ b/app/views/clusters/clusters/_sidebar.html.haml @@ -0,0 +1,9 @@ +- clusters_help_url = help_page_path('user/project/clusters/index.md') +- help_link_start = "".html_safe +- help_link_end = ''.html_safe +%h4.prepend-top-0 + = s_('ClusterIntegration|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/app/views/clusters/clusters/gcp/_form.html.haml b/app/views/clusters/clusters/gcp/_form.html.haml new file mode 100644 index 00000000000..cff5cf335dc --- /dev/null +++ b/app/views/clusters/clusters/gcp/_form.html.haml @@ -0,0 +1,75 @@ += javascript_include_tag 'https://apis.google.com/js/api.js' +- external_link_icon = icon('external-link') +- zones_link_url = 'https://cloud.google.com/compute/docs/regions-zones/regions-zones' +- machine_type_link_url = 'https://cloud.google.com/compute/docs/machine-types' +- pricing_link_url = 'https://cloud.google.com/compute/pricing#machinetype' +- help_link_start = ''.html_safe +- help_link_end = ' %{external_link_icon}'.html_safe % { external_link_icon: external_link_icon } + +%p + - link_to_help_page = link_to(s_('ClusterIntegration|help page'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|Read our %{link_to_help_page} on Kubernetes cluster integration.').html_safe % { link_to_help_page: link_to_help_page} + +%p= link_to('Select a different Google account', @authorize_url) + += form_for @gcp_cluster, html: { class: 'js-gke-cluster-creation prepend-top-20', data: { token: token_in_session } }, url: clusterable.create_gcp_clusters_path, as: :cluster do |field| + = form_errors(@gcp_cluster) + = hidden_clusterable_fields + .form-group + = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' + = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') + .form-group + = field.label :environment_scope, s_('ClusterIntegration|Environment scope'), class: 'label-bold' + = field.text_field :environment_scope, class: 'form-control', readonly: !has_multiple_clusters?, placeholder: s_('ClusterIntegration|Environment scope') + + = field.fields_for :provider_gcp, @gcp_cluster.provider_gcp do |provider_gcp_field| + .form-group + = provider_gcp_field.label :gcp_project_id, s_('ClusterIntegration|Google Cloud Platform project'), class: 'label-bold' + .js-gcp-project-id-dropdown-entry-point{ data: { docsUrl: 'https://console.cloud.google.com/home/dashboard' } } + = provider_gcp_field.hidden_field :gcp_project_id + .dropdown + %button.dropdown-menu-toggle.dropdown-menu-full-width{ type: 'button', disabled: true } + %span.dropdown-toggle-text + = _('Select project') + = icon('chevron-down') + %span.form-text.text-muted   + + .form-group + = provider_gcp_field.label :zone, s_('ClusterIntegration|Zone'), class: 'label-bold' + .js-gcp-zone-dropdown-entry-point + = provider_gcp_field.hidden_field :zone + .dropdown + %button.dropdown-menu-toggle.dropdown-menu-full-width{ type: 'button', disabled: true } + %span.dropdown-toggle-text + = _('Select project to choose zone') + = icon('chevron-down') + %p.form-text.text-muted + = s_('ClusterIntegration|Learn more about %{help_link_start}zones%{help_link_end}.').html_safe % { help_link_start: help_link_start % { url: zones_link_url }, help_link_end: help_link_end } + + .form-group + = provider_gcp_field.label :num_nodes, s_('ClusterIntegration|Number of nodes'), class: 'label-bold' + = provider_gcp_field.text_field :num_nodes, class: 'form-control', placeholder: '3' + + .form-group + = provider_gcp_field.label :machine_type, s_('ClusterIntegration|Machine type'), class: 'label-bold' + .js-gcp-machine-type-dropdown-entry-point + = provider_gcp_field.hidden_field :machine_type + .dropdown + %button.dropdown-menu-toggle.dropdown-menu-full-width{ type: 'button', disabled: true } + %span.dropdown-toggle-text + = _('Select project and zone to choose machine type') + = icon('chevron-down') + %p.form-text.text-muted + = s_('ClusterIntegration|Learn more about %{help_link_start_machine_type}machine types%{help_link_end} and %{help_link_start_pricing}pricing%{help_link_end}.').html_safe % { help_link_start_machine_type: help_link_start % { url: machine_type_link_url }, help_link_start_pricing: help_link_start % { url: pricing_link_url }, help_link_end: help_link_end } + + .form-group + .form-check + = provider_gcp_field.check_box :legacy_abac, { class: 'form-check-input' }, false, true + = provider_gcp_field.label :legacy_abac, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' + .form-text.text-muted + = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') + = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') + = link_to _('More information'), help_page_path('user/project/clusters/index.md', anchor: 'role-based-access-control-rbac-core-only'), target: '_blank' + + .form-group + = field.submit s_('ClusterIntegration|Create Kubernetes cluster'), class: 'js-gke-cluster-creation-submit btn btn-success', disabled: true diff --git a/app/views/clusters/clusters/gcp/_header.html.haml b/app/views/clusters/clusters/gcp/_header.html.haml new file mode 100644 index 00000000000..a2ad3cd64df --- /dev/null +++ b/app/views/clusters/clusters/gcp/_header.html.haml @@ -0,0 +1,14 @@ +%h4 + = s_('ClusterIntegration|Enter the details for your Kubernetes cluster') +%p + = s_('ClusterIntegration|Please make sure that your Google account meets the following requirements:') +%ul + %li + - link_to_kubernetes_engine = link_to(s_('ClusterIntegration|access to Google Kubernetes Engine'), 'https://console.cloud.google.com/freetrial?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|Your account must have %{link_to_kubernetes_engine}').html_safe % { link_to_kubernetes_engine: link_to_kubernetes_engine } + %li + - link_to_requirements = link_to(s_('ClusterIntegration|meets the requirements'), 'https://cloud.google.com/kubernetes-engine/docs/quickstart?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|Make sure your account %{link_to_requirements} to create Kubernetes clusters').html_safe % { link_to_requirements: link_to_requirements } + %li + - link_to_container_project = link_to(s_('ClusterIntegration|Google Kubernetes Engine project'), 'https://console.cloud.google.com/home/dashboard?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|This account must have permissions to create a Kubernetes cluster in the %{link_to_container_project} specified below').html_safe % { link_to_container_project: link_to_container_project } diff --git a/app/views/clusters/clusters/gcp/_show.html.haml b/app/views/clusters/clusters/gcp/_show.html.haml new file mode 100644 index 00000000000..e0159cee4a3 --- /dev/null +++ b/app/views/clusters/clusters/gcp/_show.html.haml @@ -0,0 +1,50 @@ +.form-group + %label.append-bottom-10{ for: 'cluster-name' } + = s_('ClusterIntegration|Kubernetes cluster name') + .input-group + %input.form-control.cluster-name.js-select-on-focus{ value: @cluster.name, readonly: true } + %span.input-group-append + = clipboard_button(text: @cluster.name, title: s_('ClusterIntegration|Copy Kubernetes cluster name'), class: 'input-group-text btn-default') + += form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster do |field| + = form_errors(@cluster) + = hidden_clusterable_fields + + = field.fields_for :platform_kubernetes, @cluster.platform_kubernetes do |platform_kubernetes_field| + .form-group + = platform_kubernetes_field.label :api_url, s_('ClusterIntegration|API URL') + .input-group + = platform_kubernetes_field.text_field :api_url, class: 'form-control js-select-on-focus', placeholder: s_('ClusterIntegration|API URL'), readonly: true + %span.input-group-append + = clipboard_button(text: @cluster.platform_kubernetes.api_url, title: s_('ClusterIntegration|Copy API URL'), class: 'input-group-text btn-default') + + .form-group + = platform_kubernetes_field.label :ca_cert, s_('ClusterIntegration|CA Certificate') + .input-group + = platform_kubernetes_field.text_area :ca_cert, class: 'form-control js-select-on-focus', placeholder: s_('ClusterIntegration|Certificate Authority bundle (PEM format)'), readonly: true + %span.input-group-append.clipboard-addon + = clipboard_button(text: @cluster.platform_kubernetes.ca_cert, title: s_('ClusterIntegration|Copy CA Certificate'), class: 'input-group-text btn-blank') + + .form-group + = platform_kubernetes_field.label :token, s_('ClusterIntegration|Token') + .input-group + = platform_kubernetes_field.text_field :token, class: 'form-control js-cluster-token js-select-on-focus', type: 'password', placeholder: s_('ClusterIntegration|Token'), readonly: true + %span.input-group-append + %button.btn.btn-default.input-group-text.js-show-cluster-token{ type: 'button' } + = s_('ClusterIntegration|Show') + = clipboard_button(text: @cluster.platform_kubernetes.token, title: s_('ClusterIntegration|Copy Token'), class: 'btn-default') + + .form-group + = platform_kubernetes_field.label :namespace, s_('ClusterIntegration|Project namespace (optional, unique)') + = platform_kubernetes_field.text_field :namespace, class: 'form-control', placeholder: s_('ClusterIntegration|Project namespace') + + .form-group + .form-check + = platform_kubernetes_field.check_box :authorization_type, { class: 'form-check-input', disabled: true }, 'rbac', 'abac' + = platform_kubernetes_field.label :authorization_type, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' + .form-text.text-muted + = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') + = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') + + .form-group + = field.submit s_('ClusterIntegration|Save changes'), class: 'btn btn-success' diff --git a/app/views/clusters/clusters/index.html.haml b/app/views/clusters/clusters/index.html.haml new file mode 100644 index 00000000000..a55de84b5cd --- /dev/null +++ b/app/views/clusters/clusters/index.html.haml @@ -0,0 +1,24 @@ +- breadcrumb_title 'Kubernetes' +- page_title "Kubernetes Clusters" + += render_gcp_signup_offer + +.clusters-container + - if @clusters.empty? + = render "empty_state" + - else + .top-area.adjust + .nav-text + = s_("ClusterIntegration|Kubernetes clusters can be used to deploy applications and to provide Review Apps for this project") + .ci-table.js-clusters-list + .gl-responsive-table-row.table-row-header{ role: "row" } + .table-section.section-30{ role: "rowheader" } + = s_("ClusterIntegration|Kubernetes cluster") + .table-section.section-30{ role: "rowheader" } + = s_("ClusterIntegration|Environment scope") + .table-section.section-30{ role: "rowheader" } + = s_("ClusterIntegration|Project namespace") + .table-section.section-10{ role: "rowheader" } + - @clusters.each do |cluster| + = render "cluster", cluster: cluster.present(current_user: current_user) + = paginate @clusters, theme: "gitlab" diff --git a/app/views/clusters/clusters/new.html.haml b/app/views/clusters/clusters/new.html.haml new file mode 100644 index 00000000000..eeeef6bd824 --- /dev/null +++ b/app/views/clusters/clusters/new.html.haml @@ -0,0 +1,36 @@ +- breadcrumb_title 'Kubernetes' +- page_title _("Kubernetes Cluster") +- active_tab = local_assigns.fetch(:active_tab, 'gcp') += javascript_include_tag 'https://apis.google.com/js/api.js' + += render_gcp_signup_offer + +.row.prepend-top-default + .col-md-3 + = render 'sidebar' + .col-md-9.js-toggle-container + %ul.nav-links.nav-tabs.gitlab-tabs.nav{ role: 'tablist' } + %li.nav-item{ role: 'presentation' } + %a.nav-link{ href: '#create-gcp-cluster-pane', id: 'create-gcp-cluster-tab', class: active_when(active_tab == 'gcp'), data: { toggle: 'tab' }, role: 'tab' } + %span Create new Cluster on GKE + %li.nav-item{ role: 'presentation' } + %a.nav-link{ href: '#add-user-cluster-pane', id: 'add-user-cluster-tab', class: active_when(active_tab == 'user'), data: { toggle: 'tab' }, role: 'tab' } + %span Add existing cluster + + .tab-content.gitlab-tab-content + .tab-pane{ id: 'create-gcp-cluster-pane', class: active_when(active_tab == 'gcp'), role: 'tabpanel' } + = render 'clusters/clusters/gcp/header' + - if @valid_gcp_token + = render 'clusters/clusters/gcp/form' + - elsif @authorize_url + .signin-with-google + = link_to(image_tag('auth_buttons/signin_with_google.png', width: '191px'), @authorize_url) + = _('or') + = link_to('create a new Google account', 'https://accounts.google.com/SignUpWithoutGmail?service=cloudconsole&continue=https%3A%2F%2Fconsole.cloud.google.com%2Ffreetrial%3Futm_campaign%3D2018_cpanel%26utm_source%3Dgitlab%26utm_medium%3Dreferral', target: '_blank', rel: 'noopener noreferrer') + - else + - link = link_to(s_('ClusterIntegration|properly configured'), help_page_path("integration/google"), target: '_blank', rel: 'noopener noreferrer') + = s_('Google authentication is not %{link_to_documentation}. Ask your GitLab administrator if you want to use this service.').html_safe % { link_to_documentation: link } + + .tab-pane{ id: 'add-user-cluster-pane', class: active_when(active_tab == 'user'), role: 'tabpanel' } + = render 'clusters/clusters/user/header' + = render 'clusters/clusters/user/form' diff --git a/app/views/clusters/clusters/show.html.haml b/app/views/clusters/clusters/show.html.haml new file mode 100644 index 00000000000..1e1157c34bd --- /dev/null +++ b/app/views/clusters/clusters/show.html.haml @@ -0,0 +1,53 @@ +- @content_class = "limit-container-width" unless fluid_layout +- add_to_breadcrumbs "Kubernetes Clusters", clusterable.index_path +- breadcrumb_title @cluster.name +- page_title _("Kubernetes Cluster") +- manage_prometheus_path = edit_project_service_path(@cluster.project, 'prometheus') if @project + +- expanded = Rails.env.test? + +- status_path = clusterable.cluster_status_cluster_path(@cluster.id, format: :json) if can?(current_user, :admin_cluster, @cluster) +.edit-cluster-form.js-edit-cluster-form{ data: { status_path: status_path, + install_helm_path: clusterable.install_applications_cluster_path(@cluster, :helm), + install_ingress_path: clusterable.install_applications_cluster_path(@cluster, :ingress), + install_prometheus_path: clusterable.install_applications_cluster_path(@cluster, :prometheus), + install_runner_path: clusterable.install_applications_cluster_path(@cluster, :runner), + install_jupyter_path: clusterable.install_applications_cluster_path(@cluster, :jupyter), + toggle_status: @cluster.enabled? ? 'true': 'false', + cluster_status: @cluster.status_name, + cluster_status_reason: @cluster.status_reason, + help_path: help_page_path('user/project/clusters/index.md', anchor: 'installing-applications'), + ingress_help_path: help_page_path('user/project/clusters/index.md', anchor: 'getting-the-external-ip-address'), + ingress_dns_help_path: help_page_path('topics/autodevops/quick_start_guide.md', anchor: 'point-dns-at-cluster-ip'), + manage_prometheus_path: manage_prometheus_path } } + + .js-cluster-application-notice + .flash-container + + %section#cluster-integration + %h4= @cluster.name + = render 'banner' + = render 'integration_form' + + .cluster-applications-table#js-cluster-applications + + %section.settings#js-cluster-details{ class: ('expanded' if expanded) } + .settings-header + %h4= s_('ClusterIntegration|Kubernetes cluster details') + %button.btn.js-settings-toggle{ type: 'button' } + = expanded ? 'Collapse' : 'Expand' + %p= s_('ClusterIntegration|See and edit the details for your Kubernetes cluster') + .settings-content + - if @cluster.managed? + = render 'clusters/clusters/gcp/show' + - else + = render 'clusters/clusters/user/show' + + %section.settings.no-animate#js-cluster-advanced-settings{ class: ('expanded' if expanded) } + .settings-header + %h4= _('Advanced settings') + %button.btn.js-settings-toggle{ type: 'button' } + = expanded ? 'Collapse' : 'Expand' + %p= s_("ClusterIntegration|Advanced options on this Kubernetes cluster's integration") + .settings-content + = render 'advanced_settings' diff --git a/app/views/clusters/clusters/user/_form.html.haml b/app/views/clusters/clusters/user/_form.html.haml new file mode 100644 index 00000000000..43c15274180 --- /dev/null +++ b/app/views/clusters/clusters/user/_form.html.haml @@ -0,0 +1,39 @@ += form_for @user_cluster, url: clusterable.create_user_clusters_path, as: :cluster do |field| + = form_errors(@user_cluster) + = hidden_clusterable_fields + .form-group + = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' + = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') + - if has_multiple_clusters? + .form-group + = field.label :environment_scope, s_('ClusterIntegration|Environment scope'), class: 'label-bold' + = field.text_field :environment_scope, class: 'form-control', placeholder: s_('ClusterIntegration|Environment scope') + + = field.fields_for :platform_kubernetes, @user_cluster.platform_kubernetes do |platform_kubernetes_field| + .form-group + = platform_kubernetes_field.label :api_url, s_('ClusterIntegration|API URL'), class: 'label-bold' + = platform_kubernetes_field.text_field :api_url, class: 'form-control', placeholder: s_('ClusterIntegration|API URL') + + .form-group + = platform_kubernetes_field.label :ca_cert, s_('ClusterIntegration|CA Certificate'), class: 'label-bold' + = platform_kubernetes_field.text_area :ca_cert, class: 'form-control', placeholder: s_('ClusterIntegration|Certificate Authority bundle (PEM format)') + + .form-group + = platform_kubernetes_field.label :token, s_('ClusterIntegration|Token'), class: 'label-bold' + = platform_kubernetes_field.text_field :token, class: 'form-control', placeholder: s_('ClusterIntegration|Service token'), autocomplete: 'off' + + .form-group + = platform_kubernetes_field.label :namespace, s_('ClusterIntegration|Project namespace (optional, unique)'), class: 'label-bold' + = platform_kubernetes_field.text_field :namespace, class: 'form-control', placeholder: s_('ClusterIntegration|Project namespace') + + .form-group + .form-check + = platform_kubernetes_field.check_box :authorization_type, { class: 'form-check-input qa-rbac-checkbox' }, 'rbac', 'abac' + = platform_kubernetes_field.label :authorization_type, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' + .form-text.text-muted + = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') + = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') + = link_to _('More information'), help_page_path('user/project/clusters/index.md', anchor: 'role-based-access-control-rbac-core-only'), target: '_blank' + + .form-group + = field.submit s_('ClusterIntegration|Add Kubernetes cluster'), class: 'btn btn-success' diff --git a/app/views/clusters/clusters/user/_header.html.haml b/app/views/clusters/clusters/user/_header.html.haml new file mode 100644 index 00000000000..749177fa6c1 --- /dev/null +++ b/app/views/clusters/clusters/user/_header.html.haml @@ -0,0 +1,5 @@ +%h4 + = s_('ClusterIntegration|Enter the details for your Kubernetes cluster') +%p + - link_to_help_page = link_to(s_('ClusterIntegration|documentation'), help_page_path('user/project/clusters/index', anchor: 'adding-an-existing-kubernetes-cluster'), target: '_blank', rel: 'noopener noreferrer') + = s_('ClusterIntegration|Please enter access information for your Kubernetes cluster. If you need help, you can read our %{link_to_help_page} on Kubernetes').html_safe % { link_to_help_page: link_to_help_page } diff --git a/app/views/clusters/clusters/user/_show.html.haml b/app/views/clusters/clusters/user/_show.html.haml new file mode 100644 index 00000000000..4eae08d1250 --- /dev/null +++ b/app/views/clusters/clusters/user/_show.html.haml @@ -0,0 +1,39 @@ += form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster do |field| + = form_errors(@cluster) + = hidden_clusterable_fields + .form-group + = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' + = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') + + = field.fields_for :platform_kubernetes, @cluster.platform_kubernetes do |platform_kubernetes_field| + .form-group + = platform_kubernetes_field.label :api_url, s_('ClusterIntegration|API URL'), class: 'label-bold' + = platform_kubernetes_field.text_field :api_url, class: 'form-control', placeholder: s_('ClusterIntegration|API URL') + + .form-group + = platform_kubernetes_field.label :ca_cert, s_('ClusterIntegration|CA Certificate'), class: 'label-bold' + = platform_kubernetes_field.text_area :ca_cert, class: 'form-control', placeholder: s_('ClusterIntegration|Certificate Authority bundle (PEM format)') + + .form-group + = platform_kubernetes_field.label :token, s_('ClusterIntegration|Token'), class: 'label-bold' + .input-group + = platform_kubernetes_field.text_field :token, class: 'form-control js-cluster-token', type: 'password', placeholder: s_('ClusterIntegration|Token'), autocomplete: 'off' + %span.input-group-append.clipboard-addon + .input-group-text + %button.js-show-cluster-token.btn-blank{ type: 'button' } + = s_('ClusterIntegration|Show') + + .form-group + = platform_kubernetes_field.label :namespace, s_('ClusterIntegration|Project namespace (optional, unique)'), class: 'label-bold' + = platform_kubernetes_field.text_field :namespace, class: 'form-control', placeholder: s_('ClusterIntegration|Project namespace') + + .form-group + .form-check + = platform_kubernetes_field.check_box :authorization_type, { class: 'form-check-input', disabled: true }, 'rbac', 'abac' + = platform_kubernetes_field.label :authorization_type, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' + .form-text.text-muted + = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') + = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') + + .form-group + = field.submit s_('ClusterIntegration|Save changes'), class: 'btn btn-success' diff --git a/app/views/clusters/gcp/_form.html.haml b/app/views/clusters/gcp/_form.html.haml deleted file mode 100644 index 56a5eb630cf..00000000000 --- a/app/views/clusters/gcp/_form.html.haml +++ /dev/null @@ -1,75 +0,0 @@ -= javascript_include_tag 'https://apis.google.com/js/api.js' -- external_link_icon = icon('external-link') -- zones_link_url = 'https://cloud.google.com/compute/docs/regions-zones/regions-zones' -- machine_type_link_url = 'https://cloud.google.com/compute/docs/machine-types' -- pricing_link_url = 'https://cloud.google.com/compute/pricing#machinetype' -- help_link_start = ''.html_safe -- help_link_end = ' %{external_link_icon}'.html_safe % { external_link_icon: external_link_icon } - -%p - - link_to_help_page = link_to(s_('ClusterIntegration|help page'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer') - = s_('ClusterIntegration|Read our %{link_to_help_page} on Kubernetes cluster integration.').html_safe % { link_to_help_page: link_to_help_page} - -%p= link_to('Select a different Google account', @authorize_url) - -= form_for @gcp_cluster, html: { class: 'js-gke-cluster-creation prepend-top-20', data: { token: token_in_session } }, url: create_gcp_clusters_path, as: :cluster do |field| - = form_errors(@gcp_cluster) - = hidden_clusterable_fields - .form-group - = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' - = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') - .form-group - = field.label :environment_scope, s_('ClusterIntegration|Environment scope'), class: 'label-bold' - = field.text_field :environment_scope, class: 'form-control', readonly: !has_multiple_clusters?, placeholder: s_('ClusterIntegration|Environment scope') - - = field.fields_for :provider_gcp, @gcp_cluster.provider_gcp do |provider_gcp_field| - .form-group - = provider_gcp_field.label :gcp_project_id, s_('ClusterIntegration|Google Cloud Platform project'), class: 'label-bold' - .js-gcp-project-id-dropdown-entry-point{ data: { docsUrl: 'https://console.cloud.google.com/home/dashboard' } } - = provider_gcp_field.hidden_field :gcp_project_id - .dropdown - %button.dropdown-menu-toggle.dropdown-menu-full-width{ type: 'button', disabled: true } - %span.dropdown-toggle-text - = _('Select project') - = icon('chevron-down') - %span.form-text.text-muted   - - .form-group - = provider_gcp_field.label :zone, s_('ClusterIntegration|Zone'), class: 'label-bold' - .js-gcp-zone-dropdown-entry-point - = provider_gcp_field.hidden_field :zone - .dropdown - %button.dropdown-menu-toggle.dropdown-menu-full-width{ type: 'button', disabled: true } - %span.dropdown-toggle-text - = _('Select project to choose zone') - = icon('chevron-down') - %p.form-text.text-muted - = s_('ClusterIntegration|Learn more about %{help_link_start}zones%{help_link_end}.').html_safe % { help_link_start: help_link_start % { url: zones_link_url }, help_link_end: help_link_end } - - .form-group - = provider_gcp_field.label :num_nodes, s_('ClusterIntegration|Number of nodes'), class: 'label-bold' - = provider_gcp_field.text_field :num_nodes, class: 'form-control', placeholder: '3' - - .form-group - = provider_gcp_field.label :machine_type, s_('ClusterIntegration|Machine type'), class: 'label-bold' - .js-gcp-machine-type-dropdown-entry-point - = provider_gcp_field.hidden_field :machine_type - .dropdown - %button.dropdown-menu-toggle.dropdown-menu-full-width{ type: 'button', disabled: true } - %span.dropdown-toggle-text - = _('Select project and zone to choose machine type') - = icon('chevron-down') - %p.form-text.text-muted - = s_('ClusterIntegration|Learn more about %{help_link_start_machine_type}machine types%{help_link_end} and %{help_link_start_pricing}pricing%{help_link_end}.').html_safe % { help_link_start_machine_type: help_link_start % { url: machine_type_link_url }, help_link_start_pricing: help_link_start % { url: pricing_link_url }, help_link_end: help_link_end } - - .form-group - .form-check - = provider_gcp_field.check_box :legacy_abac, { class: 'form-check-input' }, false, true - = provider_gcp_field.label :legacy_abac, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' - .form-text.text-muted - = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') - = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') - = link_to _('More information'), help_page_path('user/project/clusters/index.md', anchor: 'role-based-access-control-rbac-core-only'), target: '_blank' - - .form-group - = field.submit s_('ClusterIntegration|Create Kubernetes cluster'), class: 'js-gke-cluster-creation-submit btn btn-success', disabled: true diff --git a/app/views/clusters/gcp/_header.html.haml b/app/views/clusters/gcp/_header.html.haml deleted file mode 100644 index a2ad3cd64df..00000000000 --- a/app/views/clusters/gcp/_header.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -%h4 - = s_('ClusterIntegration|Enter the details for your Kubernetes cluster') -%p - = s_('ClusterIntegration|Please make sure that your Google account meets the following requirements:') -%ul - %li - - link_to_kubernetes_engine = link_to(s_('ClusterIntegration|access to Google Kubernetes Engine'), 'https://console.cloud.google.com/freetrial?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') - = s_('ClusterIntegration|Your account must have %{link_to_kubernetes_engine}').html_safe % { link_to_kubernetes_engine: link_to_kubernetes_engine } - %li - - link_to_requirements = link_to(s_('ClusterIntegration|meets the requirements'), 'https://cloud.google.com/kubernetes-engine/docs/quickstart?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') - = s_('ClusterIntegration|Make sure your account %{link_to_requirements} to create Kubernetes clusters').html_safe % { link_to_requirements: link_to_requirements } - %li - - link_to_container_project = link_to(s_('ClusterIntegration|Google Kubernetes Engine project'), 'https://console.cloud.google.com/home/dashboard?utm_campaign=2018_cpanel&utm_source=gitlab&utm_medium=referral', target: '_blank', rel: 'noopener noreferrer') - = s_('ClusterIntegration|This account must have permissions to create a Kubernetes cluster in the %{link_to_container_project} specified below').html_safe % { link_to_container_project: link_to_container_project } diff --git a/app/views/clusters/gcp/_show.html.haml b/app/views/clusters/gcp/_show.html.haml deleted file mode 100644 index d5f9ec8ee66..00000000000 --- a/app/views/clusters/gcp/_show.html.haml +++ /dev/null @@ -1,50 +0,0 @@ -.form-group - %label.append-bottom-10{ for: 'cluster-name' } - = s_('ClusterIntegration|Kubernetes cluster name') - .input-group - %input.form-control.cluster-name.js-select-on-focus{ value: @cluster.name, readonly: true } - %span.input-group-append - = clipboard_button(text: @cluster.name, title: s_('ClusterIntegration|Copy Kubernetes cluster name'), class: 'input-group-text btn-default') - -= form_for @cluster, url: cluster_path(@cluster), as: :cluster do |field| - = form_errors(@cluster) - = hidden_clusterable_fields - - = field.fields_for :platform_kubernetes, @cluster.platform_kubernetes do |platform_kubernetes_field| - .form-group - = platform_kubernetes_field.label :api_url, s_('ClusterIntegration|API URL') - .input-group - = platform_kubernetes_field.text_field :api_url, class: 'form-control js-select-on-focus', placeholder: s_('ClusterIntegration|API URL'), readonly: true - %span.input-group-append - = clipboard_button(text: @cluster.platform_kubernetes.api_url, title: s_('ClusterIntegration|Copy API URL'), class: 'input-group-text btn-default') - - .form-group - = platform_kubernetes_field.label :ca_cert, s_('ClusterIntegration|CA Certificate') - .input-group - = platform_kubernetes_field.text_area :ca_cert, class: 'form-control js-select-on-focus', placeholder: s_('ClusterIntegration|Certificate Authority bundle (PEM format)'), readonly: true - %span.input-group-append.clipboard-addon - = clipboard_button(text: @cluster.platform_kubernetes.ca_cert, title: s_('ClusterIntegration|Copy CA Certificate'), class: 'input-group-text btn-blank') - - .form-group - = platform_kubernetes_field.label :token, s_('ClusterIntegration|Token') - .input-group - = platform_kubernetes_field.text_field :token, class: 'form-control js-cluster-token js-select-on-focus', type: 'password', placeholder: s_('ClusterIntegration|Token'), readonly: true - %span.input-group-append - %button.btn.btn-default.input-group-text.js-show-cluster-token{ type: 'button' } - = s_('ClusterIntegration|Show') - = clipboard_button(text: @cluster.platform_kubernetes.token, title: s_('ClusterIntegration|Copy Token'), class: 'btn-default') - - .form-group - = platform_kubernetes_field.label :namespace, s_('ClusterIntegration|Project namespace (optional, unique)') - = platform_kubernetes_field.text_field :namespace, class: 'form-control', placeholder: s_('ClusterIntegration|Project namespace') - - .form-group - .form-check - = platform_kubernetes_field.check_box :authorization_type, { class: 'form-check-input', disabled: true }, 'rbac', 'abac' - = platform_kubernetes_field.label :authorization_type, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' - .form-text.text-muted - = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') - = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') - - .form-group - = field.submit s_('ClusterIntegration|Save changes'), class: 'btn btn-success' diff --git a/app/views/clusters/index.html.haml b/app/views/clusters/index.html.haml deleted file mode 100644 index a55de84b5cd..00000000000 --- a/app/views/clusters/index.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -- breadcrumb_title 'Kubernetes' -- page_title "Kubernetes Clusters" - -= render_gcp_signup_offer - -.clusters-container - - if @clusters.empty? - = render "empty_state" - - else - .top-area.adjust - .nav-text - = s_("ClusterIntegration|Kubernetes clusters can be used to deploy applications and to provide Review Apps for this project") - .ci-table.js-clusters-list - .gl-responsive-table-row.table-row-header{ role: "row" } - .table-section.section-30{ role: "rowheader" } - = s_("ClusterIntegration|Kubernetes cluster") - .table-section.section-30{ role: "rowheader" } - = s_("ClusterIntegration|Environment scope") - .table-section.section-30{ role: "rowheader" } - = s_("ClusterIntegration|Project namespace") - .table-section.section-10{ role: "rowheader" } - - @clusters.each do |cluster| - = render "cluster", cluster: cluster.present(current_user: current_user) - = paginate @clusters, theme: "gitlab" diff --git a/app/views/clusters/new.html.haml b/app/views/clusters/new.html.haml deleted file mode 100644 index 57cdbcd2d38..00000000000 --- a/app/views/clusters/new.html.haml +++ /dev/null @@ -1,36 +0,0 @@ -- breadcrumb_title 'Kubernetes' -- page_title _("Kubernetes Cluster") -- active_tab = local_assigns.fetch(:active_tab, 'gcp') -= javascript_include_tag 'https://apis.google.com/js/api.js' - -= render_gcp_signup_offer - -.row.prepend-top-default - .col-md-3 - = render 'sidebar' - .col-md-9.js-toggle-container - %ul.nav-links.nav-tabs.gitlab-tabs.nav{ role: 'tablist' } - %li.nav-item{ role: 'presentation' } - %a.nav-link{ href: '#create-gcp-cluster-pane', id: 'create-gcp-cluster-tab', class: active_when(active_tab == 'gcp'), data: { toggle: 'tab' }, role: 'tab' } - %span Create new Cluster on GKE - %li.nav-item{ role: 'presentation' } - %a.nav-link{ href: '#add-user-cluster-pane', id: 'add-user-cluster-tab', class: active_when(active_tab == 'user'), data: { toggle: 'tab' }, role: 'tab' } - %span Add existing cluster - - .tab-content.gitlab-tab-content - .tab-pane{ id: 'create-gcp-cluster-pane', class: active_when(active_tab == 'gcp'), role: 'tabpanel' } - = render 'clusters/gcp/header' - - if @valid_gcp_token - = render 'clusters/gcp/form' - - elsif @authorize_url - .signin-with-google - = link_to(image_tag('auth_buttons/signin_with_google.png', width: '191px'), @authorize_url) - = _('or') - = link_to('create a new Google account', 'https://accounts.google.com/SignUpWithoutGmail?service=cloudconsole&continue=https%3A%2F%2Fconsole.cloud.google.com%2Ffreetrial%3Futm_campaign%3D2018_cpanel%26utm_source%3Dgitlab%26utm_medium%3Dreferral', target: '_blank', rel: 'noopener noreferrer') - - else - - link = link_to(s_('ClusterIntegration|properly configured'), help_page_path("integration/google"), target: '_blank', rel: 'noopener noreferrer') - = s_('Google authentication is not %{link_to_documentation}. Ask your GitLab administrator if you want to use this service.').html_safe % { link_to_documentation: link } - - .tab-pane{ id: 'add-user-cluster-pane', class: active_when(active_tab == 'user'), role: 'tabpanel' } - = render 'clusters/user/header' - = render 'clusters/user/form' diff --git a/app/views/clusters/show.html.haml b/app/views/clusters/show.html.haml deleted file mode 100644 index c0169fbf5a2..00000000000 --- a/app/views/clusters/show.html.haml +++ /dev/null @@ -1,53 +0,0 @@ -- @content_class = "limit-container-width" unless fluid_layout -- add_to_breadcrumbs "Kubernetes Clusters", clusterable.index_path -- breadcrumb_title @cluster.name -- page_title _("Kubernetes Cluster") -- manage_prometheus_path = edit_project_service_path(@cluster.project, 'prometheus') if @project - -- expanded = Rails.env.test? - -- status_path = status_cluster_path(@cluster.id, clusterable.clusterable_params.merge(format: :json)) if can?(current_user, :admin_cluster, @cluster) -.edit-cluster-form.js-edit-cluster-form{ data: { status_path: status_path, - install_helm_path: install_applications_cluster_path(@cluster, :helm, clusterable.clusterable_params), - install_ingress_path: install_applications_cluster_path(@cluster, :ingress, clusterable.clusterable_params), - install_prometheus_path: install_applications_cluster_path(@cluster, :prometheus, clusterable.clusterable_params), - install_runner_path: install_applications_cluster_path(@cluster, :runner, clusterable.clusterable_params), - install_jupyter_path: install_applications_cluster_path(@cluster, :jupyter, clusterable.clusterable_params), - toggle_status: @cluster.enabled? ? 'true': 'false', - cluster_status: @cluster.status_name, - cluster_status_reason: @cluster.status_reason, - help_path: help_page_path('user/project/clusters/index.md', anchor: 'installing-applications'), - ingress_help_path: help_page_path('user/project/clusters/index.md', anchor: 'getting-the-external-ip-address'), - ingress_dns_help_path: help_page_path('topics/autodevops/quick_start_guide.md', anchor: 'point-dns-at-cluster-ip'), - manage_prometheus_path: manage_prometheus_path } } - - .js-cluster-application-notice - .flash-container - - %section#cluster-integration - %h4= @cluster.name - = render 'banner' - = render 'integration_form' - - .cluster-applications-table#js-cluster-applications - - %section.settings#js-cluster-details{ class: ('expanded' if expanded) } - .settings-header - %h4= s_('ClusterIntegration|Kubernetes cluster details') - %button.btn.js-settings-toggle{ type: 'button' } - = expanded ? 'Collapse' : 'Expand' - %p= s_('ClusterIntegration|See and edit the details for your Kubernetes cluster') - .settings-content - - if @cluster.managed? - = render 'clusters/gcp/show' - - else - = render 'clusters/user/show' - - %section.settings.no-animate#js-cluster-advanced-settings{ class: ('expanded' if expanded) } - .settings-header - %h4= _('Advanced settings') - %button.btn.js-settings-toggle{ type: 'button' } - = expanded ? 'Collapse' : 'Expand' - %p= s_("ClusterIntegration|Advanced options on this Kubernetes cluster's integration") - .settings-content - = render 'advanced_settings' diff --git a/app/views/clusters/user/_form.html.haml b/app/views/clusters/user/_form.html.haml deleted file mode 100644 index 05462d27b99..00000000000 --- a/app/views/clusters/user/_form.html.haml +++ /dev/null @@ -1,39 +0,0 @@ -= form_for @user_cluster, url: create_user_clusters_path, as: :cluster do |field| - = form_errors(@user_cluster) - = hidden_clusterable_fields - .form-group - = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' - = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') - - if has_multiple_clusters? - .form-group - = field.label :environment_scope, s_('ClusterIntegration|Environment scope'), class: 'label-bold' - = field.text_field :environment_scope, class: 'form-control', placeholder: s_('ClusterIntegration|Environment scope') - - = field.fields_for :platform_kubernetes, @user_cluster.platform_kubernetes do |platform_kubernetes_field| - .form-group - = platform_kubernetes_field.label :api_url, s_('ClusterIntegration|API URL'), class: 'label-bold' - = platform_kubernetes_field.text_field :api_url, class: 'form-control', placeholder: s_('ClusterIntegration|API URL') - - .form-group - = platform_kubernetes_field.label :ca_cert, s_('ClusterIntegration|CA Certificate'), class: 'label-bold' - = platform_kubernetes_field.text_area :ca_cert, class: 'form-control', placeholder: s_('ClusterIntegration|Certificate Authority bundle (PEM format)') - - .form-group - = platform_kubernetes_field.label :token, s_('ClusterIntegration|Token'), class: 'label-bold' - = platform_kubernetes_field.text_field :token, class: 'form-control', placeholder: s_('ClusterIntegration|Service token'), autocomplete: 'off' - - .form-group - = platform_kubernetes_field.label :namespace, s_('ClusterIntegration|Project namespace (optional, unique)'), class: 'label-bold' - = platform_kubernetes_field.text_field :namespace, class: 'form-control', placeholder: s_('ClusterIntegration|Project namespace') - - .form-group - .form-check - = platform_kubernetes_field.check_box :authorization_type, { class: 'form-check-input qa-rbac-checkbox' }, 'rbac', 'abac' - = platform_kubernetes_field.label :authorization_type, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' - .form-text.text-muted - = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') - = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') - = link_to _('More information'), help_page_path('user/project/clusters/index.md', anchor: 'role-based-access-control-rbac-core-only'), target: '_blank' - - .form-group - = field.submit s_('ClusterIntegration|Add Kubernetes cluster'), class: 'btn btn-success' diff --git a/app/views/clusters/user/_header.html.haml b/app/views/clusters/user/_header.html.haml deleted file mode 100644 index 749177fa6c1..00000000000 --- a/app/views/clusters/user/_header.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -%h4 - = s_('ClusterIntegration|Enter the details for your Kubernetes cluster') -%p - - link_to_help_page = link_to(s_('ClusterIntegration|documentation'), help_page_path('user/project/clusters/index', anchor: 'adding-an-existing-kubernetes-cluster'), target: '_blank', rel: 'noopener noreferrer') - = s_('ClusterIntegration|Please enter access information for your Kubernetes cluster. If you need help, you can read our %{link_to_help_page} on Kubernetes').html_safe % { link_to_help_page: link_to_help_page } diff --git a/app/views/clusters/user/_show.html.haml b/app/views/clusters/user/_show.html.haml deleted file mode 100644 index 57f6cd1f43d..00000000000 --- a/app/views/clusters/user/_show.html.haml +++ /dev/null @@ -1,39 +0,0 @@ -= form_for @cluster, url: cluster_path(@cluster), as: :cluster do |field| - = form_errors(@cluster) - = hidden_clusterable_fields - .form-group - = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' - = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') - - = field.fields_for :platform_kubernetes, @cluster.platform_kubernetes do |platform_kubernetes_field| - .form-group - = platform_kubernetes_field.label :api_url, s_('ClusterIntegration|API URL'), class: 'label-bold' - = platform_kubernetes_field.text_field :api_url, class: 'form-control', placeholder: s_('ClusterIntegration|API URL') - - .form-group - = platform_kubernetes_field.label :ca_cert, s_('ClusterIntegration|CA Certificate'), class: 'label-bold' - = platform_kubernetes_field.text_area :ca_cert, class: 'form-control', placeholder: s_('ClusterIntegration|Certificate Authority bundle (PEM format)') - - .form-group - = platform_kubernetes_field.label :token, s_('ClusterIntegration|Token'), class: 'label-bold' - .input-group - = platform_kubernetes_field.text_field :token, class: 'form-control js-cluster-token', type: 'password', placeholder: s_('ClusterIntegration|Token'), autocomplete: 'off' - %span.input-group-append.clipboard-addon - .input-group-text - %button.js-show-cluster-token.btn-blank{ type: 'button' } - = s_('ClusterIntegration|Show') - - .form-group - = platform_kubernetes_field.label :namespace, s_('ClusterIntegration|Project namespace (optional, unique)'), class: 'label-bold' - = platform_kubernetes_field.text_field :namespace, class: 'form-control', placeholder: s_('ClusterIntegration|Project namespace') - - .form-group - .form-check - = platform_kubernetes_field.check_box :authorization_type, { class: 'form-check-input', disabled: true }, 'rbac', 'abac' - = platform_kubernetes_field.label :authorization_type, s_('ClusterIntegration|RBAC-enabled cluster (experimental)'), class: 'form-check-label label-bold' - .form-text.text-muted - = s_('ClusterIntegration|Enable this setting if using role-based access control (RBAC).') - = s_('ClusterIntegration|This option will allow you to install applications on RBAC clusters.') - - .form-group - = field.submit s_('ClusterIntegration|Save changes'), class: 'btn btn-success' -- cgit v1.2.1 From 2c6a3f6a1a90fb4eb780e081a6673fd2e90c7dc1 Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Fri, 2 Nov 2018 10:38:17 +1300 Subject: Remove method as using nested resource routes We introduced hidden_clusterable_fields in this MR but it is no longer needed as we have gone back to nested resource routes which should provide the params such as `project_id`. --- app/views/clusters/clusters/_integration_form.html.haml | 1 - app/views/clusters/clusters/gcp/_form.html.haml | 1 - app/views/clusters/clusters/gcp/_show.html.haml | 1 - app/views/clusters/clusters/user/_form.html.haml | 1 - app/views/clusters/clusters/user/_show.html.haml | 1 - 5 files changed, 5 deletions(-) (limited to 'app/views/clusters') diff --git a/app/views/clusters/clusters/_integration_form.html.haml b/app/views/clusters/clusters/_integration_form.html.haml index 0792ad0085c..5e451f60c9d 100644 --- a/app/views/clusters/clusters/_integration_form.html.haml +++ b/app/views/clusters/clusters/_integration_form.html.haml @@ -1,6 +1,5 @@ = form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster do |field| = form_errors(@cluster) - = hidden_clusterable_fields .form-group %h5= s_('ClusterIntegration|Integration status') %label.append-bottom-0.js-cluster-enable-toggle-area diff --git a/app/views/clusters/clusters/gcp/_form.html.haml b/app/views/clusters/clusters/gcp/_form.html.haml index cff5cf335dc..ad842036a62 100644 --- a/app/views/clusters/clusters/gcp/_form.html.haml +++ b/app/views/clusters/clusters/gcp/_form.html.haml @@ -14,7 +14,6 @@ = form_for @gcp_cluster, html: { class: 'js-gke-cluster-creation prepend-top-20', data: { token: token_in_session } }, url: clusterable.create_gcp_clusters_path, as: :cluster do |field| = form_errors(@gcp_cluster) - = hidden_clusterable_fields .form-group = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') diff --git a/app/views/clusters/clusters/gcp/_show.html.haml b/app/views/clusters/clusters/gcp/_show.html.haml index e0159cee4a3..6021b220285 100644 --- a/app/views/clusters/clusters/gcp/_show.html.haml +++ b/app/views/clusters/clusters/gcp/_show.html.haml @@ -8,7 +8,6 @@ = form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster do |field| = form_errors(@cluster) - = hidden_clusterable_fields = field.fields_for :platform_kubernetes, @cluster.platform_kubernetes do |platform_kubernetes_field| .form-group diff --git a/app/views/clusters/clusters/user/_form.html.haml b/app/views/clusters/clusters/user/_form.html.haml index 43c15274180..4e6232b69de 100644 --- a/app/views/clusters/clusters/user/_form.html.haml +++ b/app/views/clusters/clusters/user/_form.html.haml @@ -1,6 +1,5 @@ = form_for @user_cluster, url: clusterable.create_user_clusters_path, as: :cluster do |field| = form_errors(@user_cluster) - = hidden_clusterable_fields .form-group = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') diff --git a/app/views/clusters/clusters/user/_show.html.haml b/app/views/clusters/clusters/user/_show.html.haml index 4eae08d1250..a871fef0240 100644 --- a/app/views/clusters/clusters/user/_show.html.haml +++ b/app/views/clusters/clusters/user/_show.html.haml @@ -1,6 +1,5 @@ = form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster do |field| = form_errors(@cluster) - = hidden_clusterable_fields .form-group = field.label :name, s_('ClusterIntegration|Kubernetes cluster name'), class: 'label-bold' = field.text_field :name, class: 'form-control', placeholder: s_('ClusterIntegration|Kubernetes cluster name') -- cgit v1.2.1