diff --git a/components/centraldashboard/public/assets/i18n/languages.json b/components/centraldashboard/public/assets/i18n/languages.json index c528ae73042..b1623e6604f 100644 --- a/components/centraldashboard/public/assets/i18n/languages.json +++ b/components/centraldashboard/public/assets/i18n/languages.json @@ -65,6 +65,12 @@ "landingPage.slackLink": "https://statcan-aaw.slack.com", "landingPage.firstTime": "This seems to be the first time you access Kubeflow, we are happy to see you!", "landingPage.autoNamespace": "Your namespace is automatically generated.", + "landingPage.yourNamespace": "Your namespace will be", + "landingPage.email": "Your email is", + "landingPage.errCreateNS": "An error occured while creating the namespace.", + "landingPage.errGetNS": "An error occured while trying to retrieve the namespace", + "landingPage.errCreateDefaultNotebook": "An error occured while trying to create the default notebook", + "landingPage.errGeneral": "An unexpected error occured, details available in English:", "notebookDefaultCard.goto": "Go to Notebooks", "notebookDefaultCard.create": "Create", "notebookDefaultCard.details": "Details", @@ -76,8 +82,7 @@ "notebookDefaultCard.txtNoDefaultNotebook": "No default notebook for this namespace. You may click on 'Create' below to generate one.", "notebookDefaultCard.txtDefaultNotReady": "The default notebook is not ready yet.", "notebookDefaultCard.errorDefaultNotebook": "Failed to do the current operation, because:", - "landingPage.yourNamespace": "Your namespace will be", - "landingPage.email": "Your email is", + "registrationPage.btnNext": "Next", "registrationPage.lblNamespace": "Namespace", "registrationPage.lblNamespaceDesc": "A namespace is a collection of Kubeflow services. Resources created within a namespace are isolated to that namespace. By default, a namespace will be created for you.", @@ -200,6 +205,10 @@ "landingPage.autoNamespace": "Votre espace de noms est automatiquement généré.", "landingPage.yourNamespace": "Votre espace de noms sera", "landingPage.email": "Votre courriel est", + "landingPage.errCreateNS": "Une erreur s'est produite lors de la création de l'espace de noms.", + "landingPage.errGetNS": "Une erreur s'est produite lors de la tentative de récupération de l'espace de noms", + "landingPage.errCreateDefaultNotebook": "Une erreur s'est produite lors de la tentative de création du notebook par défaut", + "landingPage.errGeneral": "Une erreur inattendue s'est produite, détails disponibles en anglais :", "registrationPage.btnNext": "Suivant", "registrationPage.btnStartSetup": "Commencer", "registrationPage.lblNamespace": "Espace de nom", diff --git a/components/centraldashboard/public/components/landing-page.js b/components/centraldashboard/public/components/landing-page.js index 85ce936438d..4f3b9bfb103 100644 --- a/components/centraldashboard/public/components/landing-page.js +++ b/components/centraldashboard/public/components/landing-page.js @@ -40,7 +40,8 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities userDetails: {type: Object, observer: '_onUserDetails'}, namespaceName: String, emailAddress: String, - error: Object, + errorText: {type: String, value: ''}, + errorDetail: {type: String, value: ''}, flowComplete: {type: Boolean, value: false}, waitForRedirect: {type: Boolean, value: false}, showAPIText: {type: Boolean, value: false}, @@ -51,7 +52,7 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities super.ready(); } - _onUserDetails(d) { + _onUserDetails() { this.emailAddress = this.userDetails; this.generateNamespace(this.userDetails); } @@ -93,10 +94,8 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities } this.namespaceName = ns; }).catch((e)=> { - this.set('error', {response: { - error: e, - namespace: this.namespaceName, - }}); + this.showError('landingPage.errGeneral'); + this.errorDetail= e; }); } @@ -106,15 +105,7 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities this.waitForRedirect = true; await API.generateRequest().completes.catch((e) => e); await this.sleep(1); // So the errors and callbacks can schedule - if (this.error && this.error.response) { - if (this.error.response.error) { - this.set('error', {response: { - error: 'registrationPage.errDuplicate', - namespace: this.namespaceName, - }}); - } - return this.waitForRedirect = false; - } + /* * Poll for profile over a span of 20 seconds (every 300ms) * if still not there, let the user click next again! @@ -127,16 +118,8 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities await APICreateDefault.generateRequest().completes.catch((e) => e); await this.sleep(1); // So the errors and callbacks can schedule - if (this.error && this.error.response) { - if (this.error.response.error) { - this.set('error', {response: { - error: 'registrationPage.errCreateNotebook', - namespace: this.namespaceName, - }}); - } - return this.waitForRedirect = false; - } - this.waitForRedirect = false; + + return this.waitForRedirect = false; } async pollProfile(times, delay) { @@ -152,9 +135,35 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities _successSetup() { this.flowComplete = true; - this.set('error', {}); + this.closeError(); this.fireEvent('flowcomplete'); } + + // Error handling functions + showError(err) { + this.errorText = err; + this.errorDetail = ''; + } + + closeError() { + this.errorText = ''; + this.errorDetail = ''; + } + + _onCreateNamespaceError(ev) { + this.showError('mainPage.errCreateNS'); + return; + } + + _onGetNamespaceError(ev) { + this.showError('mainPage.errGetNS'); + return; + } + + _onCreateDefaultNotebookError(ev) { + this.showError('mainPage.errCreateDefaultNotebook'); + return; + } } diff --git a/components/centraldashboard/public/components/landing-page.pug b/components/centraldashboard/public/components/landing-page.pug index 73ae6839cb2..358dc53a8c3 100644 --- a/components/centraldashboard/public/components/landing-page.pug +++ b/components/centraldashboard/public/components/landing-page.pug @@ -1,7 +1,7 @@ -iron-ajax#MakeNamespace(method='POST', url='/api/workgroup/create', handle-as='json', last-error='{{error}}', last-response='{{resp}}', +iron-ajax#MakeNamespace(method='POST', url='/api/workgroup/create', handle-as='json', on-error='_onCreateNamespaceError', last-response='{{resp}}', content-type='application/json', loading='{{submittingWorkgroup}}') -iron-ajax#GetMyNamespace(url='/api/workgroup/exists', handle-as='json') -iron-ajax#CreateDefaultNotebook(method='POST', url='/jupyter/api/namespaces/[[namespaceName]]/createdefault', headers='{"Content-Type": "application/json"}') +iron-ajax#GetMyNamespace(url='/api/workgroup/exists', handle-as='json', on-error='_onGetNamespaceError') +iron-ajax#CreateDefaultNotebook(method='POST', url='/jupyter/api/namespaces/[[namespaceName]]/createdefault', headers='{"Content-Type": "application/json"}', on-error='_onCreateDefaultNotebookError') paper-card#MainCard figure#Logo !{logo} neon-animatable.Main-Content @@ -21,3 +21,7 @@ nav#Links a(href='https://github.com/kubeflow/kubeflow', tabindex='-1', target="_blank") {{localize('registrationPage.linkGitHub')}} a(href='https://www.kubeflow.org/docs/about/kubeflow/', tabindex='-1', target="_blank") {{localize('registrationPage.linkDocumentation')}} a(href='https://policies.google.com/privacy', tabindex='-1', target="_blank") {{localize('registrationPage.linkPrivacy')}} + +paper-toast#ErrorLandingPageToast(duration=0, opened='[[!empty(errorText)]]', on-click='closeError') {{localize(errorText)}} + strong [[errorDetail]] + paper-icon-button(icon='close') \ No newline at end of file