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 {
.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);
}
}
......
......@@ -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;
},
......
......@@ -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
......
......@@ -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
......
......@@ -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')
......
......@@ -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');
});
});
......
......@@ -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', () => {
......
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