Commit a03b5d22 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch '38464-k8s-apps' of https://gitlab.com/gitlab-org/gitlab-ce into 38464-k8s-apps

parents 134e840d 67e12219
...@@ -163,12 +163,10 @@ export default class Clusters { ...@@ -163,12 +163,10 @@ export default class Clusters {
.map(appId => newApplicationMap[appId].title); .map(appId => newApplicationMap[appId].title);
if (appTitles.length > 0) { 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(', '), appList: appTitles.join(', '),
}); });
this.successApplicationContainer.classList.remove('hidden'); Flash(text, 'notice', this.successApplicationContainer);
} else {
this.successApplicationContainer.classList.add('hidden');
} }
} }
......
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
// Avoid the potential for the real-time data to say APPLICATION_INSTALLABLE but // 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 // we already made a request to install and are just waiting for the real-time
// to sync up. // to sync up.
return this.status !== APPLICATION_INSTALLABLE || return (this.status !== APPLICATION_INSTALLABLE && this.status !== APPLICATION_ERROR) ||
this.requestStatus === REQUEST_LOADING || this.requestStatus === REQUEST_LOADING ||
this.requestStatus === REQUEST_SUCCESS; this.requestStatus === REQUEST_SUCCESS;
}, },
......
...@@ -11,14 +11,16 @@ module Clusters ...@@ -11,14 +11,16 @@ module Clusters
validates :cluster, presence: true validates :cluster, presence: true
after_initialize :set_initial_status
def self.application_name def self.application_name
self.to_s.demodulize.underscore self.to_s.demodulize.underscore
end end
def set_initial_status def initial_status
self.status = 0 unless cluster&.platform_kubernetes_active? if cluster&.platform_kubernetes_active?
:installable
else
:not_installable
end
end end
def name def name
......
...@@ -4,7 +4,7 @@ module Clusters ...@@ -4,7 +4,7 @@ module Clusters
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
state_machine :status, initial: :installable do state_machine :status, initial: ->(application) { application.initial_status } do
state :not_installable, value: -2 state :not_installable, value: -2
state :errored, value: -1 state :errored, value: -1
state :installable, value: 0 state :installable, value: 0
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
help_path: help_page_path('user/project/clusters/index.md', anchor: 'installing-applications') } } 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 %section.settings.no-animate.expanded
%h4= s_('ClusterIntegration|Enable cluster integration') %h4= s_('ClusterIntegration|Enable cluster integration')
......
...@@ -49,7 +49,7 @@ describe('Clusters', () => { ...@@ -49,7 +49,7 @@ describe('Clusters', () => {
helm: { status: APPLICATION_INSTALLABLE, title: 'Helm Tiller' }, 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', () => { it('shows an alert when something gets newly installed', () => {
...@@ -61,8 +61,8 @@ describe('Clusters', () => { ...@@ -61,8 +61,8 @@ describe('Clusters', () => {
helm: { status: APPLICATION_INSTALLED, title: 'Helm Tiller' }, helm: { status: APPLICATION_INSTALLED, title: 'Helm Tiller' },
}); });
expect(document.querySelector('.js-cluster-application-notice:not(.hidden)')).toBeDefined(); expect(document.querySelector('.js-cluster-application-notice .flash-text')).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').textContent.trim()).toEqual('Helm Tiller was successfully installed on your cluster');
}); });
it('shows an alert when multiple things gets newly installed', () => { it('shows an alert when multiple things gets newly installed', () => {
...@@ -76,28 +76,8 @@ describe('Clusters', () => { ...@@ -76,28 +76,8 @@ describe('Clusters', () => {
ingress: { status: APPLICATION_INSTALLED, title: 'Ingress' }, ingress: { status: APPLICATION_INSTALLED, title: 'Ingress' },
}); });
expect(document.querySelector('.js-cluster-application-notice:not(.hidden)')).toBeDefined(); expect(document.querySelector('.js-cluster-application-notice .flash-text')).toBeDefined();
expect(document.querySelector('.js-cluster-application-notice').textContent.trim()).toEqual('Helm Tiller, Ingress was successfully installed on your cluster'); expect(document.querySelector('.js-cluster-application-notice .flash-text').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();
}); });
}); });
......
...@@ -117,7 +117,7 @@ describe('Application Row', () => { ...@@ -117,7 +117,7 @@ describe('Application Row', () => {
expect(vm.installButtonDisabled).toEqual(true); expect(vm.installButtonDisabled).toEqual(true);
}); });
it('has disabled "Install" when APPLICATION_ERROR', () => { it('has enabled "Install" when APPLICATION_ERROR', () => {
vm = mountComponent(ApplicationRow, { vm = mountComponent(ApplicationRow, {
...DEFAULT_APPLICATION_STATE, ...DEFAULT_APPLICATION_STATE,
status: APPLICATION_ERROR, status: APPLICATION_ERROR,
...@@ -125,7 +125,7 @@ describe('Application Row', () => { ...@@ -125,7 +125,7 @@ describe('Application Row', () => {
expect(vm.installButtonLabel).toEqual('Install'); expect(vm.installButtonLabel).toEqual('Install');
expect(vm.installButtonLoading).toEqual(false); expect(vm.installButtonLoading).toEqual(false);
expect(vm.installButtonDisabled).toEqual(true); expect(vm.installButtonDisabled).toEqual(false);
}); });
it('has loading "Install" when REQUEST_LOADING', () => { it('has loading "Install" when REQUEST_LOADING', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment