From 0c27de5f45aa1dc9841d10d348292324546685f2 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 7 Nov 2017 06:27:33 -0600 Subject: Update Cluster application install to be enabled when errored --- app/assets/javascripts/clusters/components/application_row.vue | 2 +- spec/javascripts/clusters/components/application_row_spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/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', () => { -- cgit v1.2.1 From 1bd1d462dab33997c19432b00c867070fb6b1214 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 7 Nov 2017 06:28:02 -0600 Subject: Use flash for dismissable alerts --- app/assets/javascripts/clusters/clusters_bundle.js | 6 ++--- app/views/projects/clusters/show.html.haml | 3 ++- spec/javascripts/clusters/clusters_bundle_spec.js | 30 ++++------------------ 3 files changed, 9 insertions(+), 30 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/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'); }); }); -- cgit v1.2.1 From 67e12219bf6257568f91c1a9c883e4821337c80d Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 7 Nov 2017 13:50:04 +0100 Subject: Rework initial state --- app/models/clusters/applications/helm.rb | 10 ++++++---- app/models/clusters/concerns/application_status.rb | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) 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 -- cgit v1.2.1