diff options
author | Robert Speicher <rspeicher@gmail.com> | 2019-01-31 00:55:28 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2019-01-31 00:55:28 +0300 |
commit | 1414cfae43ce175feaaaca346287274fe3c372e2 (patch) | |
tree | 68d745b196edca87ef48460b57090adf8ca78a2b /app/assets/javascripts/clusters | |
parent | 13c6d254d682359c62fc63a29c813940a34da20f (diff) |
Revert "Merge branch '56398-fix-cluster-installation-loading-state' into 'master'"
This reverts merge request !24485
Diffstat (limited to 'app/assets/javascripts/clusters')
-rw-r--r-- | app/assets/javascripts/clusters/clusters_bundle.js | 28 | ||||
-rw-r--r-- | app/assets/javascripts/clusters/components/application_row.vue | 59 | ||||
-rw-r--r-- | app/assets/javascripts/clusters/constants.js | 3 |
3 files changed, 48 insertions, 42 deletions
diff --git a/app/assets/javascripts/clusters/clusters_bundle.js b/app/assets/javascripts/clusters/clusters_bundle.js index fc4779632f9..b1f992c03ff 100644 --- a/app/assets/javascripts/clusters/clusters_bundle.js +++ b/app/assets/javascripts/clusters/clusters_bundle.js @@ -6,7 +6,7 @@ import Flash from '../flash'; import Poll from '../lib/utils/poll'; import initSettingsPanels from '../settings_panels'; import eventHub from './event_hub'; -import { APPLICATION_STATUS, REQUEST_SUBMITTED, REQUEST_FAILURE } from './constants'; +import { APPLICATION_STATUS, REQUEST_LOADING, REQUEST_SUCCESS, REQUEST_FAILURE } from './constants'; import ClustersService from './services/clusters_service'; import ClustersStore from './stores/clusters_store'; import Applications from './components/applications.vue'; @@ -231,18 +231,22 @@ export default class Clusters { installApplication(data) { const appId = data.id; - this.store.updateAppProperty(appId, 'requestStatus', REQUEST_SUBMITTED); + this.store.updateAppProperty(appId, 'requestStatus', REQUEST_LOADING); this.store.updateAppProperty(appId, 'requestReason', null); - this.store.updateAppProperty(appId, 'statusReason', null); - - this.service.installApplication(appId, data.params).catch(() => { - this.store.updateAppProperty(appId, 'requestStatus', REQUEST_FAILURE); - this.store.updateAppProperty( - appId, - 'requestReason', - s__('ClusterIntegration|Request to begin installing failed'), - ); - }); + + this.service + .installApplication(appId, data.params) + .then(() => { + this.store.updateAppProperty(appId, 'requestStatus', REQUEST_SUCCESS); + }) + .catch(() => { + this.store.updateAppProperty(appId, 'requestStatus', REQUEST_FAILURE); + this.store.updateAppProperty( + appId, + 'requestReason', + s__('ClusterIntegration|Request to begin installing failed'), + ); + }); } destroy() { diff --git a/app/assets/javascripts/clusters/components/application_row.vue b/app/assets/javascripts/clusters/components/application_row.vue index 3c3ce1dec56..d4354dcfebd 100644 --- a/app/assets/javascripts/clusters/components/application_row.vue +++ b/app/assets/javascripts/clusters/components/application_row.vue @@ -4,7 +4,12 @@ import { s__, sprintf } from '../../locale'; import eventHub from '../event_hub'; import identicon from '../../vue_shared/components/identicon.vue'; import loadingButton from '../../vue_shared/components/loading_button.vue'; -import { APPLICATION_STATUS, REQUEST_SUBMITTED, REQUEST_FAILURE } from '../constants'; +import { + APPLICATION_STATUS, + REQUEST_LOADING, + REQUEST_SUCCESS, + REQUEST_FAILURE, +} from '../constants'; export default { components: { @@ -67,13 +72,6 @@ export default { isKnownStatus() { return Object.values(APPLICATION_STATUS).includes(this.status); }, - isInstalling() { - return ( - this.status === APPLICATION_STATUS.SCHEDULED || - this.status === APPLICATION_STATUS.INSTALLING || - (this.requestStatus === REQUEST_SUBMITTED && !this.statusReason && !this.isInstalled) - ); - }, isInstalled() { return ( this.status === APPLICATION_STATUS.INSTALLED || @@ -81,18 +79,6 @@ export default { this.status === APPLICATION_STATUS.UPDATING ); }, - canInstall() { - if (this.isInstalling) { - return false; - } - - return ( - this.status === APPLICATION_STATUS.NOT_INSTALLABLE || - this.status === APPLICATION_STATUS.INSTALLABLE || - this.status === APPLICATION_STATUS.ERROR || - this.isUnknownStatus - ); - }, hasLogo() { return !!this.logoUrl; }, @@ -104,7 +90,12 @@ export default { return `js-cluster-application-row-${this.id}`; }, installButtonLoading() { - return !this.status || this.status === APPLICATION_STATUS.SCHEDULED || this.isInstalling; + return ( + !this.status || + this.status === APPLICATION_STATUS.SCHEDULED || + this.status === APPLICATION_STATUS.INSTALLING || + this.requestStatus === REQUEST_LOADING + ); }, installButtonDisabled() { // Avoid the potential for the real-time data to say APPLICATION_STATUS.INSTALLABLE but @@ -113,17 +104,30 @@ export default { return ( ((this.status !== APPLICATION_STATUS.INSTALLABLE && this.status !== APPLICATION_STATUS.ERROR) || - this.isInstalling) && + this.requestStatus === REQUEST_LOADING || + this.requestStatus === REQUEST_SUCCESS) && this.isKnownStatus ); }, installButtonLabel() { let label; - if (this.canInstall) { + if ( + this.status === APPLICATION_STATUS.NOT_INSTALLABLE || + this.status === APPLICATION_STATUS.INSTALLABLE || + this.status === APPLICATION_STATUS.ERROR || + this.isUnknownStatus + ) { label = s__('ClusterIntegration|Install'); - } else if (this.isInstalling) { + } else if ( + this.status === APPLICATION_STATUS.SCHEDULED || + this.status === APPLICATION_STATUS.INSTALLING + ) { label = s__('ClusterIntegration|Installing'); - } else if (this.isInstalled) { + } else if ( + this.status === APPLICATION_STATUS.INSTALLED || + this.status === APPLICATION_STATUS.UPDATED || + this.status === APPLICATION_STATUS.UPDATING + ) { label = s__('ClusterIntegration|Installed'); } @@ -136,10 +140,7 @@ export default { return s__('ClusterIntegration|Manage'); }, hasError() { - return ( - !this.isInstalling && - (this.status === APPLICATION_STATUS.ERROR || this.requestStatus === REQUEST_FAILURE) - ); + return this.status === APPLICATION_STATUS.ERROR || this.requestStatus === REQUEST_FAILURE; }, generalErrorDescription() { return sprintf(s__('ClusterIntegration|Something went wrong while installing %{title}'), { diff --git a/app/assets/javascripts/clusters/constants.js b/app/assets/javascripts/clusters/constants.js index 360511e8882..e31afadf186 100644 --- a/app/assets/javascripts/clusters/constants.js +++ b/app/assets/javascripts/clusters/constants.js @@ -18,7 +18,8 @@ export const APPLICATION_STATUS = { }; // These are only used client-side -export const REQUEST_SUBMITTED = 'request-submitted'; +export const REQUEST_LOADING = 'request-loading'; +export const REQUEST_SUCCESS = 'request-success'; export const REQUEST_FAILURE = 'request-failure'; export const INGRESS = 'ingress'; export const JUPYTER = 'jupyter'; |