From e1d4deb2d2bc91c0730b57f81196b290fdfa86cf Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 24 May 2018 21:00:21 +0100 Subject: [PATCH] Disables jupyter install button while ingress is not installed Includes juptyer hostname in the post request Adds tests --- .../javascripts/clusters/clusters_bundle.js | 5 +- .../clusters/components/application_row.vue | 17 +++- .../clusters/components/applications.vue | 55 +++---------- .../clusters/services/clusters_service.js | 11 +-- .../clusters/stores/clusters_store.js | 2 +- .../clusters/clusters_bundle_spec.js | 32 ++++++-- .../components/application_row_spec.js | 32 +++++++- .../clusters/components/applications_spec.js | 77 +++++++++++++++++-- .../clusters/services/mock_data.js | 35 +++++++++ .../clusters/stores/clusters_store_spec.js | 18 +++++ 10 files changed, 212 insertions(+), 72 deletions(-) diff --git a/app/assets/javascripts/clusters/clusters_bundle.js b/app/assets/javascripts/clusters/clusters_bundle.js index 6bf9dca1112..e42a3632e79 100644 --- a/app/assets/javascripts/clusters/clusters_bundle.js +++ b/app/assets/javascripts/clusters/clusters_bundle.js @@ -211,11 +211,12 @@ export default class Clusters { } } - installApplication(appId) { + installApplication(data) { + const appId = data.id; this.store.updateAppProperty(appId, 'requestStatus', REQUEST_LOADING); this.store.updateAppProperty(appId, 'requestReason', null); - this.service.installApplication(appId) + this.service.installApplication(appId, data.params) .then(() => { this.store.updateAppProperty(appId, 'requestStatus', REQUEST_SUCCESS); }) diff --git a/app/assets/javascripts/clusters/components/application_row.vue b/app/assets/javascripts/clusters/components/application_row.vue index fae580c091b..ff4fd0b118c 100644 --- a/app/assets/javascripts/clusters/components/application_row.vue +++ b/app/assets/javascripts/clusters/components/application_row.vue @@ -52,6 +52,16 @@ type: String, required: false, }, + disableInstallButton: { + type: Boolean, + required: false, + default: false, + }, + installApplicationRequestParams: { + type: Object, + required: false, + default: () => ({}), + }, }, computed: { rowJsClass() { @@ -67,7 +77,7 @@ // 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.disableInstallButton || (this.status !== APPLICATION_INSTALLABLE && this.status !== APPLICATION_ERROR) || this.requestStatus === REQUEST_LOADING || this.requestStatus === REQUEST_SUCCESS; @@ -109,7 +119,10 @@ }, methods: { installClicked() { - eventHub.$emit('installApplication', this.id); + eventHub.$emit('installApplication', { + id: this.id, + params: this.installApplicationRequestParams, + }); }, }, }; diff --git a/app/assets/javascripts/clusters/components/applications.vue b/app/assets/javascripts/clusters/components/applications.vue index e03db7b8974..5b127c7911c 100644 --- a/app/assets/javascripts/clusters/components/applications.vue +++ b/app/assets/javascripts/clusters/components/applications.vue @@ -37,11 +37,6 @@ export default { default: '', }, }, - data() { - return { - jupyterSuggestHostnameValue: '', - }; - }, computed: { generalApplicationDescription() { return sprintf( @@ -132,14 +127,6 @@ export default { jupyterHostname() { return this.applications.jupyter.hostname; }, - jupyterSuggestHostname() { - return `jupyter.${this.applications.ingress.externalIp}.xip.io`; - }, - }, - watch: { - jupyterSuggestHostname() { - this.jupyterSuggestHostnameValue = this.jupyterSuggestHostname; - }, }, }; @@ -305,6 +292,8 @@ export default { :status-reason="applications.jupyter.statusReason" :request-status="applications.jupyter.requestStatus" :request-reason="applications.jupyter.requestReason" + :disable-install-button="!ingressInstalled" + :install-application-request-params="{ hostname: applications.jupyter.hostname }" >

@@ -314,45 +303,23 @@ export default { notebooks to a class of students, a corporate data science group, or a scientific research group.`) }}

- -