diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-01 21:06:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-01 21:06:43 +0000 |
commit | 9c4066878fe309781bbadd20f87c223c12dc60f6 (patch) | |
tree | b5a5adefc861696c4ebb75d937fe70b9241d5bdc /app | |
parent | 77a73903aa803869d0ab7fe544cc2d8b1a6aa1e0 (diff) | |
download | gitlab-ce-9c4066878fe309781bbadd20f87c223c12dc60f6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/create_cluster/gke_cluster_namespace/index.js (renamed from app/assets/javascripts/projects/gke_cluster_namespace/index.js) | 0 | ||||
-rw-r--r-- | app/assets/javascripts/create_cluster/init_create_cluster.js | 37 | ||||
-rw-r--r-- | app/assets/javascripts/pages/admin/clusters/index.js | 20 | ||||
-rw-r--r-- | app/assets/javascripts/pages/groups/index.js | 20 | ||||
-rw-r--r-- | app/assets/javascripts/pages/projects/clusters/new/index.js | 13 | ||||
-rw-r--r-- | app/assets/javascripts/pages/projects/clusters/show/index.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/pages/projects/index.js | 19 |
7 files changed, 44 insertions, 67 deletions
diff --git a/app/assets/javascripts/projects/gke_cluster_namespace/index.js b/app/assets/javascripts/create_cluster/gke_cluster_namespace/index.js index 0ec4d8807b0..0ec4d8807b0 100644 --- a/app/assets/javascripts/projects/gke_cluster_namespace/index.js +++ b/app/assets/javascripts/create_cluster/gke_cluster_namespace/index.js diff --git a/app/assets/javascripts/create_cluster/init_create_cluster.js b/app/assets/javascripts/create_cluster/init_create_cluster.js new file mode 100644 index 00000000000..7c984582fd8 --- /dev/null +++ b/app/assets/javascripts/create_cluster/init_create_cluster.js @@ -0,0 +1,37 @@ +import initGkeDropdowns from './gke_cluster'; +import initGkeNamespace from './gke_cluster_namespace'; +import PersistentUserCallout from '~/persistent_user_callout'; + +const newClusterViews = [':clusters:new', ':clusters:create_gcp', ':clusters:create_user']; + +const isProjectLevelCluster = page => page.startsWith('project:clusters'); + +export default (document, gon) => { + const { page } = document.body.dataset; + const isNewClusterView = newClusterViews.some(view => page.endsWith(view)); + + if (!isNewClusterView) { + return; + } + + const callout = document.querySelector('.gcp-signup-offer'); + PersistentUserCallout.factory(callout); + + initGkeDropdowns(); + + if (gon.features.createEksClusters) { + import(/* webpackChunkName: 'eks_cluster' */ '~/create_cluster/eks_cluster') + .then(({ default: initCreateEKSCluster }) => { + const el = document.querySelector('.js-create-eks-cluster-form-container'); + + if (el) { + initCreateEKSCluster(el); + } + }) + .catch(() => {}); + } + + if (isProjectLevelCluster(page)) { + initGkeNamespace(); + } +}; diff --git a/app/assets/javascripts/pages/admin/clusters/index.js b/app/assets/javascripts/pages/admin/clusters/index.js index 43992938d07..4d04c37caa7 100644 --- a/app/assets/javascripts/pages/admin/clusters/index.js +++ b/app/assets/javascripts/pages/admin/clusters/index.js @@ -1,21 +1,5 @@ -import PersistentUserCallout from '~/persistent_user_callout'; -import initGkeDropdowns from '~/create_cluster/gke_cluster'; - -function initGcpSignupCallout() { - const callout = document.querySelector('.gcp-signup-offer'); - PersistentUserCallout.factory(callout); -} +import initCreateCluster from '~/create_cluster/init_create_cluster'; document.addEventListener('DOMContentLoaded', () => { - const { page } = document.body.dataset; - const newClusterViews = [ - 'admin:clusters:new', - 'admin:clusters:create_gcp', - 'admin:clusters:create_user', - ]; - - if (newClusterViews.indexOf(page) > -1) { - initGcpSignupCallout(); - initGkeDropdowns(); - } + initCreateCluster(document, gon); }); diff --git a/app/assets/javascripts/pages/groups/index.js b/app/assets/javascripts/pages/groups/index.js index a33d242908b..4d04c37caa7 100644 --- a/app/assets/javascripts/pages/groups/index.js +++ b/app/assets/javascripts/pages/groups/index.js @@ -1,21 +1,5 @@ -import PersistentUserCallout from '~/persistent_user_callout'; -import initGkeDropdowns from '~/create_cluster/gke_cluster'; - -function initGcpSignupCallout() { - const callout = document.querySelector('.gcp-signup-offer'); - PersistentUserCallout.factory(callout); -} +import initCreateCluster from '~/create_cluster/init_create_cluster'; document.addEventListener('DOMContentLoaded', () => { - const { page } = document.body.dataset; - const newClusterViews = [ - 'groups:clusters:new', - 'groups:clusters:create_gcp', - 'groups:clusters:create_user', - ]; - - if (newClusterViews.indexOf(page) > -1) { - initGcpSignupCallout(); - initGkeDropdowns(); - } + initCreateCluster(document, gon); }); diff --git a/app/assets/javascripts/pages/projects/clusters/new/index.js b/app/assets/javascripts/pages/projects/clusters/new/index.js deleted file mode 100644 index 14d5ab21555..00000000000 --- a/app/assets/javascripts/pages/projects/clusters/new/index.js +++ /dev/null @@ -1,13 +0,0 @@ -document.addEventListener('DOMContentLoaded', () => { - if (gon.features.createEksClusters) { - import(/* webpackChunkName: 'eks_cluster' */ '~/create_cluster/eks_cluster') - .then(({ default: initCreateEKSCluster }) => { - const el = document.querySelector('.js-create-eks-cluster-form-container'); - - if (el) { - initCreateEKSCluster(el); - } - }) - .catch(() => {}); - } -}); diff --git a/app/assets/javascripts/pages/projects/clusters/show/index.js b/app/assets/javascripts/pages/projects/clusters/show/index.js index f091c01fc98..397f9faf6fe 100644 --- a/app/assets/javascripts/pages/projects/clusters/show/index.js +++ b/app/assets/javascripts/pages/projects/clusters/show/index.js @@ -1,5 +1,5 @@ import ClustersBundle from '~/clusters/clusters_bundle'; -import initGkeNamespace from '~/projects/gke_cluster_namespace'; +import initGkeNamespace from '~/create_cluster/gke_cluster_namespace'; document.addEventListener('DOMContentLoaded', () => { new ClustersBundle(); // eslint-disable-line no-new diff --git a/app/assets/javascripts/pages/projects/index.js b/app/assets/javascripts/pages/projects/index.js index 196798a9076..190d0806c28 100644 --- a/app/assets/javascripts/pages/projects/index.js +++ b/app/assets/javascripts/pages/projects/index.js @@ -1,24 +1,9 @@ -import initGkeDropdowns from '~/create_cluster/gke_cluster'; -import initGkeNamespace from '~/projects/gke_cluster_namespace'; -import PersistentUserCallout from '../../persistent_user_callout'; import Project from './project'; import ShortcutsNavigation from '../../behaviors/shortcuts/shortcuts_navigation'; +import initCreateCluster from '~/create_cluster/init_create_cluster'; 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) { - const callout = document.querySelector('.gcp-signup-offer'); - PersistentUserCallout.factory(callout); - - initGkeDropdowns(); - initGkeNamespace(); - } + initCreateCluster(document, gon); new Project(); // eslint-disable-line no-new new ShortcutsNavigation(); // eslint-disable-line no-new |