summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/pages/clusters/create_gcp/index.js (renamed from app/assets/javascripts/pages/projects/clusters/gcp/new/index.js)2
-rw-r--r--app/assets/javascripts/pages/clusters/create_user/index.js7
-rw-r--r--app/assets/javascripts/pages/clusters/destroy/index.js (renamed from app/assets/javascripts/pages/projects/clusters/destroy/index.js)0
-rw-r--r--app/assets/javascripts/pages/clusters/index/index.js (renamed from app/assets/javascripts/pages/projects/clusters/index/index.js)0
-rw-r--r--app/assets/javascripts/pages/clusters/new/index.js7
-rw-r--r--app/assets/javascripts/pages/clusters/show/index.js (renamed from app/assets/javascripts/pages/projects/clusters/show/index.js)0
-rw-r--r--app/assets/javascripts/pages/clusters/update/index.js (renamed from app/assets/javascripts/pages/projects/clusters/update/index.js)0
-rw-r--r--app/assets/javascripts/pages/projects/index.js14
-rw-r--r--app/controllers/clusters/applications_controller.rb (renamed from app/controllers/projects/clusters/applications_controller.rb)3
-rw-r--r--app/controllers/clusters/base_controller.rb42
-rw-r--r--app/controllers/clusters_controller.rb (renamed from app/controllers/projects/clusters_controller.rb)16
-rw-r--r--app/helpers/clusters_helper.rb2
-rw-r--r--app/views/clusters/_advanced_settings.html.haml (renamed from app/views/projects/clusters/_advanced_settings.html.haml)0
-rw-r--r--app/views/clusters/_banner.html.haml (renamed from app/views/projects/clusters/_banner.html.haml)0
-rw-r--r--app/views/clusters/_cluster.html.haml (renamed from app/views/projects/clusters/_cluster.html.haml)0
-rw-r--r--app/views/clusters/_empty_state.html.haml (renamed from app/views/projects/clusters/_empty_state.html.haml)0
-rw-r--r--app/views/clusters/_gcp_signup_offer_banner.html.haml (renamed from app/views/projects/clusters/_gcp_signup_offer_banner.html.haml)0
-rw-r--r--app/views/clusters/_integration_form.html.haml (renamed from app/views/projects/clusters/_integration_form.html.haml)0
-rw-r--r--app/views/clusters/_sidebar.html.haml (renamed from app/views/projects/clusters/_sidebar.html.haml)0
-rw-r--r--app/views/clusters/gcp/_form.html.haml (renamed from app/views/projects/clusters/gcp/_form.html.haml)0
-rw-r--r--app/views/clusters/gcp/_header.html.haml (renamed from app/views/projects/clusters/gcp/_header.html.haml)0
-rw-r--r--app/views/clusters/gcp/_show.html.haml (renamed from app/views/projects/clusters/gcp/_show.html.haml)0
-rw-r--r--app/views/clusters/index.html.haml (renamed from app/views/projects/clusters/index.html.haml)0
-rw-r--r--app/views/clusters/new.html.haml (renamed from app/views/projects/clusters/new.html.haml)8
-rw-r--r--app/views/clusters/show.html.haml (renamed from app/views/projects/clusters/show.html.haml)4
-rw-r--r--app/views/clusters/user/_form.html.haml (renamed from app/views/projects/clusters/user/_form.html.haml)0
-rw-r--r--app/views/clusters/user/_header.html.haml (renamed from app/views/projects/clusters/user/_header.html.haml)0
-rw-r--r--app/views/clusters/user/_show.html.haml (renamed from app/views/projects/clusters/user/_show.html.haml)0
28 files changed, 78 insertions, 27 deletions
diff --git a/app/assets/javascripts/pages/projects/clusters/gcp/new/index.js b/app/assets/javascripts/pages/clusters/create_gcp/index.js
index d4f34e32a48..e7c8cc4ab5f 100644
--- a/app/assets/javascripts/pages/projects/clusters/gcp/new/index.js
+++ b/app/assets/javascripts/pages/clusters/create_gcp/index.js
@@ -1,5 +1,7 @@
+import initDismissableCallout from '~/dismissable_callout';
import initGkeDropdowns from '~/projects/gke_cluster_dropdowns';
document.addEventListener('DOMContentLoaded', () => {
+ initDismissableCallout('.gcp-signup-offer');
initGkeDropdowns();
});
diff --git a/app/assets/javascripts/pages/clusters/create_user/index.js b/app/assets/javascripts/pages/clusters/create_user/index.js
new file mode 100644
index 00000000000..e7c8cc4ab5f
--- /dev/null
+++ b/app/assets/javascripts/pages/clusters/create_user/index.js
@@ -0,0 +1,7 @@
+import initDismissableCallout from '~/dismissable_callout';
+import initGkeDropdowns from '~/projects/gke_cluster_dropdowns';
+
+document.addEventListener('DOMContentLoaded', () => {
+ initDismissableCallout('.gcp-signup-offer');
+ initGkeDropdowns();
+});
diff --git a/app/assets/javascripts/pages/projects/clusters/destroy/index.js b/app/assets/javascripts/pages/clusters/destroy/index.js
index 8001d2dd1da..8001d2dd1da 100644
--- a/app/assets/javascripts/pages/projects/clusters/destroy/index.js
+++ b/app/assets/javascripts/pages/clusters/destroy/index.js
diff --git a/app/assets/javascripts/pages/projects/clusters/index/index.js b/app/assets/javascripts/pages/clusters/index/index.js
index e4b8baede58..e4b8baede58 100644
--- a/app/assets/javascripts/pages/projects/clusters/index/index.js
+++ b/app/assets/javascripts/pages/clusters/index/index.js
diff --git a/app/assets/javascripts/pages/clusters/new/index.js b/app/assets/javascripts/pages/clusters/new/index.js
new file mode 100644
index 00000000000..e7c8cc4ab5f
--- /dev/null
+++ b/app/assets/javascripts/pages/clusters/new/index.js
@@ -0,0 +1,7 @@
+import initDismissableCallout from '~/dismissable_callout';
+import initGkeDropdowns from '~/projects/gke_cluster_dropdowns';
+
+document.addEventListener('DOMContentLoaded', () => {
+ initDismissableCallout('.gcp-signup-offer');
+ initGkeDropdowns();
+});
diff --git a/app/assets/javascripts/pages/projects/clusters/show/index.js b/app/assets/javascripts/pages/clusters/show/index.js
index 8001d2dd1da..8001d2dd1da 100644
--- a/app/assets/javascripts/pages/projects/clusters/show/index.js
+++ b/app/assets/javascripts/pages/clusters/show/index.js
diff --git a/app/assets/javascripts/pages/projects/clusters/update/index.js b/app/assets/javascripts/pages/clusters/update/index.js
index 8001d2dd1da..8001d2dd1da 100644
--- a/app/assets/javascripts/pages/projects/clusters/update/index.js
+++ b/app/assets/javascripts/pages/clusters/update/index.js
diff --git a/app/assets/javascripts/pages/projects/index.js b/app/assets/javascripts/pages/projects/index.js
index 5659e13981a..8e0af018b61 100644
--- a/app/assets/javascripts/pages/projects/index.js
+++ b/app/assets/javascripts/pages/projects/index.js
@@ -1,21 +1,7 @@
-import initDismissableCallout from '~/dismissable_callout';
-import initGkeDropdowns from '~/projects/gke_cluster_dropdowns';
import Project from './project';
import ShortcutsNavigation from '../../behaviors/shortcuts/shortcuts_navigation';
document.addEventListener('DOMContentLoaded', () => {
- const { page } = document.body.dataset;
- const newClusterViews = [
- 'projects:clusters:new',
- 'projects:clusters:create_gcp',
- 'projects:clusters:create_user',
- ];
-
- if (newClusterViews.indexOf(page) > -1) {
- initDismissableCallout('.gcp-signup-offer');
- initGkeDropdowns();
- }
-
new Project(); // eslint-disable-line no-new
new ShortcutsNavigation(); // eslint-disable-line no-new
});
diff --git a/app/controllers/projects/clusters/applications_controller.rb b/app/controllers/clusters/applications_controller.rb
index bcea96bce94..a5ac5fe3f8e 100644
--- a/app/controllers/projects/clusters/applications_controller.rb
+++ b/app/controllers/clusters/applications_controller.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
-class Projects::Clusters::ApplicationsController < Projects::ApplicationController
+class Clusters::ApplicationsController < Clusters::BaseController
before_action :cluster
- before_action :authorize_read_cluster!
before_action :authorize_create_cluster!, only: [:create]
def create
diff --git a/app/controllers/clusters/base_controller.rb b/app/controllers/clusters/base_controller.rb
new file mode 100644
index 00000000000..2804b236d17
--- /dev/null
+++ b/app/controllers/clusters/base_controller.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+class Clusters::BaseController < ApplicationController
+ include RoutableActions
+
+ skip_before_action :authenticate_user!
+ before_action :require_project_id
+ before_action :project, if: :project_type?
+ before_action :repository, if: :project_type?
+ before_action :authorize_read_cluster!
+
+ private
+
+ # We can extend to `#group_type?` in the future
+ def require_project_id
+ not_found unless project_type?
+ end
+
+ def project
+ @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]))
+ end
+
+ def repository
+ @repository ||= project.repository
+ end
+
+ def authorize_read_cluster!
+ access_denied! unless can?(current_user, :read_cluster, clusterable)
+ end
+
+ def authorize_create_cluster!
+ access_denied! unless can?(current_user, :create_cluster, clusterable)
+ end
+
+ def clusterable
+ project if project_type?
+ end
+
+ def project_type?
+ params[:project_id].present?
+ end
+end
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/clusters_controller.rb
index 62adc66fb09..5cf4e44c4ed 100644
--- a/app/controllers/projects/clusters_controller.rb
+++ b/app/controllers/clusters_controller.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
-class Projects::ClustersController < Projects::ApplicationController
+class ClustersController < Clusters::BaseController
before_action :cluster, except: [:index, :new, :create_gcp, :create_user]
- before_action :authorize_read_cluster!
before_action :generate_gcp_authorize_url, only: [:new]
before_action :validate_gcp_token, only: [:new]
before_action :gcp_cluster, only: [:new]
@@ -11,6 +10,9 @@ class Projects::ClustersController < Projects::ApplicationController
before_action :authorize_update_cluster!, only: [:update]
before_action :authorize_admin_cluster!, only: [:destroy]
before_action :update_applications_status, only: [:status]
+
+ layout :determine_layout
+
helper_method :token_in_session
STATUS_POLLING_INTERVAL = 10_000
@@ -29,7 +31,7 @@ class Projects::ClustersController < Projects::ApplicationController
Gitlab::PollingInterval.set_header(response, interval: STATUS_POLLING_INTERVAL)
render json: ClusterSerializer
- .new(project: @project, current_user: @current_user)
+ .new(project: project, current_user: @current_user)
.represent_status(@cluster)
end
end
@@ -105,6 +107,12 @@ class Projects::ClustersController < Projects::ApplicationController
private
+ def determine_layout
+ if project_type?
+ 'project'
+ end
+ end
+
def cluster
@cluster ||= project.clusters.find(params[:id])
.present(current_user: current_user)
@@ -169,7 +177,7 @@ class Projects::ClustersController < Projects::ApplicationController
end
def generate_gcp_authorize_url
- state = generate_session_key_redirect(new_project_cluster_path(@project).to_s)
+ state = generate_session_key_redirect(new_project_cluster_path(project).to_s)
@authorize_url = GoogleApi::CloudPlatform::Client.new(
nil, callback_google_api_auth_url,
diff --git a/app/helpers/clusters_helper.rb b/app/helpers/clusters_helper.rb
index 19eb763e1de..21ee95a6f20 100644
--- a/app/helpers/clusters_helper.rb
+++ b/app/helpers/clusters_helper.rb
@@ -10,7 +10,7 @@ module ClustersHelper
return unless show_gcp_signup_offer?
content_tag :section, class: 'no-animate expanded' do
- render 'projects/clusters/gcp_signup_offer_banner'
+ render 'clusters/gcp_signup_offer_banner'
end
end
end
diff --git a/app/views/projects/clusters/_advanced_settings.html.haml b/app/views/clusters/_advanced_settings.html.haml
index 243e8cd9ba0..243e8cd9ba0 100644
--- a/app/views/projects/clusters/_advanced_settings.html.haml
+++ b/app/views/clusters/_advanced_settings.html.haml
diff --git a/app/views/projects/clusters/_banner.html.haml b/app/views/clusters/_banner.html.haml
index 73cfea0ef92..73cfea0ef92 100644
--- a/app/views/projects/clusters/_banner.html.haml
+++ b/app/views/clusters/_banner.html.haml
diff --git a/app/views/projects/clusters/_cluster.html.haml b/app/views/clusters/_cluster.html.haml
index 2d7f7c6b1fb..2d7f7c6b1fb 100644
--- a/app/views/projects/clusters/_cluster.html.haml
+++ b/app/views/clusters/_cluster.html.haml
diff --git a/app/views/projects/clusters/_empty_state.html.haml b/app/views/clusters/_empty_state.html.haml
index b8a3556a206..b8a3556a206 100644
--- a/app/views/projects/clusters/_empty_state.html.haml
+++ b/app/views/clusters/_empty_state.html.haml
diff --git a/app/views/projects/clusters/_gcp_signup_offer_banner.html.haml b/app/views/clusters/_gcp_signup_offer_banner.html.haml
index 73b11d509d3..73b11d509d3 100644
--- a/app/views/projects/clusters/_gcp_signup_offer_banner.html.haml
+++ b/app/views/clusters/_gcp_signup_offer_banner.html.haml
diff --git a/app/views/projects/clusters/_integration_form.html.haml b/app/views/clusters/_integration_form.html.haml
index d0a553e3414..d0a553e3414 100644
--- a/app/views/projects/clusters/_integration_form.html.haml
+++ b/app/views/clusters/_integration_form.html.haml
diff --git a/app/views/projects/clusters/_sidebar.html.haml b/app/views/clusters/_sidebar.html.haml
index 3d10348212f..3d10348212f 100644
--- a/app/views/projects/clusters/_sidebar.html.haml
+++ b/app/views/clusters/_sidebar.html.haml
diff --git a/app/views/projects/clusters/gcp/_form.html.haml b/app/views/clusters/gcp/_form.html.haml
index 171ceeceb68..171ceeceb68 100644
--- a/app/views/projects/clusters/gcp/_form.html.haml
+++ b/app/views/clusters/gcp/_form.html.haml
diff --git a/app/views/projects/clusters/gcp/_header.html.haml b/app/views/clusters/gcp/_header.html.haml
index a2ad3cd64df..a2ad3cd64df 100644
--- a/app/views/projects/clusters/gcp/_header.html.haml
+++ b/app/views/clusters/gcp/_header.html.haml
diff --git a/app/views/projects/clusters/gcp/_show.html.haml b/app/views/clusters/gcp/_show.html.haml
index 779c9c245c1..779c9c245c1 100644
--- a/app/views/projects/clusters/gcp/_show.html.haml
+++ b/app/views/clusters/gcp/_show.html.haml
diff --git a/app/views/projects/clusters/index.html.haml b/app/views/clusters/index.html.haml
index a55de84b5cd..a55de84b5cd 100644
--- a/app/views/projects/clusters/index.html.haml
+++ b/app/views/clusters/index.html.haml
diff --git a/app/views/projects/clusters/new.html.haml b/app/views/clusters/new.html.haml
index a38003f5750..57cdbcd2d38 100644
--- a/app/views/projects/clusters/new.html.haml
+++ b/app/views/clusters/new.html.haml
@@ -19,9 +19,9 @@
.tab-content.gitlab-tab-content
.tab-pane{ id: 'create-gcp-cluster-pane', class: active_when(active_tab == 'gcp'), role: 'tabpanel' }
- = render 'projects/clusters/gcp/header'
+ = render 'clusters/gcp/header'
- if @valid_gcp_token
- = render 'projects/clusters/gcp/form'
+ = render 'clusters/gcp/form'
- elsif @authorize_url
.signin-with-google
= link_to(image_tag('auth_buttons/signin_with_google.png', width: '191px'), @authorize_url)
@@ -32,5 +32,5 @@
= 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 'projects/clusters/user/header'
- = render 'projects/clusters/user/form'
+ = render 'clusters/user/header'
+ = render 'clusters/user/form'
diff --git a/app/views/projects/clusters/show.html.haml b/app/views/clusters/show.html.haml
index eddd3613c5f..14416303827 100644
--- a/app/views/projects/clusters/show.html.haml
+++ b/app/views/clusters/show.html.haml
@@ -38,9 +38,9 @@
%p= s_('ClusterIntegration|See and edit the details for your Kubernetes cluster')
.settings-content
- if @cluster.managed?
- = render 'projects/clusters/gcp/show'
+ = render 'clusters/gcp/show'
- else
- = render 'projects/clusters/user/show'
+ = render 'clusters/user/show'
%section.settings.no-animate#js-cluster-advanced-settings{ class: ('expanded' if expanded) }
.settings-header
diff --git a/app/views/projects/clusters/user/_form.html.haml b/app/views/clusters/user/_form.html.haml
index 54a6e685bb0..54a6e685bb0 100644
--- a/app/views/projects/clusters/user/_form.html.haml
+++ b/app/views/clusters/user/_form.html.haml
diff --git a/app/views/projects/clusters/user/_header.html.haml b/app/views/clusters/user/_header.html.haml
index 749177fa6c1..749177fa6c1 100644
--- a/app/views/projects/clusters/user/_header.html.haml
+++ b/app/views/clusters/user/_header.html.haml
diff --git a/app/views/projects/clusters/user/_show.html.haml b/app/views/clusters/user/_show.html.haml
index 5b57f7ceb7d..5b57f7ceb7d 100644
--- a/app/views/projects/clusters/user/_show.html.haml
+++ b/app/views/clusters/user/_show.html.haml