summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-11-07 21:59:55 +0900
committerShinya Maeda <shinya@gitlab.com>2017-11-07 21:59:55 +0900
commita03b5d2291a11a23182576308897d2a8f909c970 (patch)
tree5ff6cfa035debf92494ab7fb40f3b34b989147b7
parent134e840d23ea08bfd578f9622ffec60c01ed665c (diff)
parent67e12219bf6257568f91c1a9c883e4821337c80d (diff)
downloadgitlab-ce-a03b5d2291a11a23182576308897d2a8f909c970.tar.gz
Merge branch '38464-k8s-apps' of https://gitlab.com/gitlab-org/gitlab-ce into 38464-k8s-apps
-rw-r--r--app/assets/javascripts/clusters/clusters_bundle.js6
-rw-r--r--app/assets/javascripts/clusters/components/application_row.vue2
-rw-r--r--app/models/clusters/applications/helm.rb10
-rw-r--r--app/models/clusters/concerns/application_status.rb2
-rw-r--r--app/views/projects/clusters/show.html.haml3
-rw-r--r--spec/javascripts/clusters/clusters_bundle_spec.js30
-rw-r--r--spec/javascripts/clusters/components/application_row_spec.js4
7 files changed, 19 insertions, 38 deletions
diff --git a/app/assets/javascripts/clusters/clusters_bundle.js b/app/assets/javascripts/clusters/clusters_bundle.js
index c486208175f..5f421ea58ba 100644
--- a/app/assets/javascripts/clusters/clusters_bundle.js
+++ b/app/assets/javascripts/clusters/clusters_bundle.js
@@ -163,12 +163,10 @@ export default class Clusters {
.map(appId => newApplicationMap[appId].title);
if (appTitles.length > 0) {
- this.successApplicationContainer.textContent = sprintf(s__('ClusterIntegration|%{appList} was successfully installed on your cluster'), {
+ const text = sprintf(s__('ClusterIntegration|%{appList} was successfully installed on your cluster'), {
appList: appTitles.join(', '),
});
- this.successApplicationContainer.classList.remove('hidden');
- } else {
- this.successApplicationContainer.classList.add('hidden');
+ Flash(text, 'notice', this.successApplicationContainer);
}
}
diff --git a/app/assets/javascripts/clusters/components/application_row.vue b/app/assets/javascripts/clusters/components/application_row.vue
index b672111fda8..872abf03ef1 100644
--- a/app/assets/javascripts/clusters/components/application_row.vue
+++ b/app/assets/javascripts/clusters/components/application_row.vue
@@ -66,7 +66,7 @@ export default {
// Avoid the potential for the real-time data to say APPLICATION_INSTALLABLE but
// we already made a request to install and are just waiting for the real-time
// to sync up.
- return this.status !== APPLICATION_INSTALLABLE ||
+ return (this.status !== APPLICATION_INSTALLABLE && this.status !== APPLICATION_ERROR) ||
this.requestStatus === REQUEST_LOADING ||
this.requestStatus === REQUEST_SUCCESS;
},
diff --git a/app/models/clusters/applications/helm.rb b/app/models/clusters/applications/helm.rb
index 863f9b9d834..d60bb7dcd02 100644
--- a/app/models/clusters/applications/helm.rb
+++ b/app/models/clusters/applications/helm.rb
@@ -11,14 +11,16 @@ module Clusters
validates :cluster, presence: true
- after_initialize :set_initial_status
-
def self.application_name
self.to_s.demodulize.underscore
end
- def set_initial_status
- self.status = 0 unless cluster&.platform_kubernetes_active?
+ def initial_status
+ if cluster&.platform_kubernetes_active?
+ :installable
+ else
+ :not_installable
+ end
end
def name
diff --git a/app/models/clusters/concerns/application_status.rb b/app/models/clusters/concerns/application_status.rb
index e73abfa9055..3e15da7fc32 100644
--- a/app/models/clusters/concerns/application_status.rb
+++ b/app/models/clusters/concerns/application_status.rb
@@ -4,7 +4,7 @@ module Clusters
extend ActiveSupport::Concern
included do
- state_machine :status, initial: :installable do
+ state_machine :status, initial: ->(application) { application.initial_status } do
state :not_installable, value: -2
state :errored, value: -1
state :installable, value: 0
diff --git a/app/views/projects/clusters/show.html.haml b/app/views/projects/clusters/show.html.haml
index f116c4f7dba..be6784058ae 100644
--- a/app/views/projects/clusters/show.html.haml
+++ b/app/views/projects/clusters/show.html.haml
@@ -13,7 +13,8 @@
help_path: help_page_path('user/project/clusters/index.md', anchor: 'installing-applications') } }
- .hidden.js-cluster-application-notice.alert.alert-info.alert-block.append-bottom-10{ role: 'alert' }
+ .js-cluster-application-notice
+ .flash-container
%section.settings.no-animate.expanded
%h4= s_('ClusterIntegration|Enable cluster integration')
diff --git a/spec/javascripts/clusters/clusters_bundle_spec.js b/spec/javascripts/clusters/clusters_bundle_spec.js
index 86e9cb22be8..027e8001053 100644
--- a/spec/javascripts/clusters/clusters_bundle_spec.js
+++ b/spec/javascripts/clusters/clusters_bundle_spec.js
@@ -49,7 +49,7 @@ describe('Clusters', () => {
helm: { status: APPLICATION_INSTALLABLE, title: 'Helm Tiller' },
});
- expect(document.querySelector('.js-cluster-application-notice.hidden')).toBeDefined();
+ expect(document.querySelector('.js-cluster-application-notice .flash-text')).toBeNull();
});
it('shows an alert when something gets newly installed', () => {
@@ -61,8 +61,8 @@ describe('Clusters', () => {
helm: { status: APPLICATION_INSTALLED, title: 'Helm Tiller' },
});
- expect(document.querySelector('.js-cluster-application-notice:not(.hidden)')).toBeDefined();
- expect(document.querySelector('.js-cluster-application-notice').textContent.trim()).toEqual('Helm Tiller was successfully installed on your cluster');
+ expect(document.querySelector('.js-cluster-application-notice .flash-text')).toBeDefined();
+ expect(document.querySelector('.js-cluster-application-notice .flash-text').textContent.trim()).toEqual('Helm Tiller was successfully installed on your cluster');
});
it('shows an alert when multiple things gets newly installed', () => {
@@ -76,28 +76,8 @@ describe('Clusters', () => {
ingress: { status: APPLICATION_INSTALLED, title: 'Ingress' },
});
- expect(document.querySelector('.js-cluster-application-notice:not(.hidden)')).toBeDefined();
- expect(document.querySelector('.js-cluster-application-notice').textContent.trim()).toEqual('Helm Tiller, Ingress was successfully installed on your cluster');
- });
-
- it('hides existing alert when we call again and nothing is newly installed', () => {
- const installedState = {
- ...INITIAL_APP_MAP,
- helm: { status: APPLICATION_INSTALLED, title: 'Helm Tiller' },
- };
-
- // Show the banner
- cluster.checkForNewInstalls({
- ...INITIAL_APP_MAP,
- helm: { status: APPLICATION_INSTALLING, title: 'Helm Tiller' },
- }, installedState);
-
- expect(document.querySelector('.js-cluster-application-notice:not(.hidden)')).toBeDefined();
-
- // Banner should go back hidden
- cluster.checkForNewInstalls(installedState, installedState);
-
- expect(document.querySelector('.js-cluster-application-notice.hidden')).toBeDefined();
+ expect(document.querySelector('.js-cluster-application-notice .flash-text')).toBeDefined();
+ expect(document.querySelector('.js-cluster-application-notice .flash-text').textContent.trim()).toEqual('Helm Tiller, Ingress was successfully installed on your cluster');
});
});
diff --git a/spec/javascripts/clusters/components/application_row_spec.js b/spec/javascripts/clusters/components/application_row_spec.js
index 392cebc5e35..e671c18e1a5 100644
--- a/spec/javascripts/clusters/components/application_row_spec.js
+++ b/spec/javascripts/clusters/components/application_row_spec.js
@@ -117,7 +117,7 @@ describe('Application Row', () => {
expect(vm.installButtonDisabled).toEqual(true);
});
- it('has disabled "Install" when APPLICATION_ERROR', () => {
+ it('has enabled "Install" when APPLICATION_ERROR', () => {
vm = mountComponent(ApplicationRow, {
...DEFAULT_APPLICATION_STATE,
status: APPLICATION_ERROR,
@@ -125,7 +125,7 @@ describe('Application Row', () => {
expect(vm.installButtonLabel).toEqual('Install');
expect(vm.installButtonLoading).toEqual(false);
- expect(vm.installButtonDisabled).toEqual(true);
+ expect(vm.installButtonDisabled).toEqual(false);
});
it('has loading "Install" when REQUEST_LOADING', () => {