Skip to content

Commit

Permalink
Validate edited data
Browse files Browse the repository at this point in the history
  • Loading branch information
wg102 committed Mar 28, 2024
1 parent 2104566 commit 265f482
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
2 changes: 2 additions & 0 deletions components/centraldashboard/public/assets/i18n/languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"landingPage.errGetNS": "An error occured while trying to retrieve the workspace",
"landingPage.errCreateDefaultNotebook": "An error occured while trying to create the default notebook",
"landingPage.errGeneral": "An unexpected error occured, details available in English:",
"landingPage.errEditedContent": "We detected a change in the email or the namespace, please refresh the page and try again.",
"notebookDefaultCard.goto": "Go to Notebooks",
"notebookDefaultCard.create": "Create",
"notebookDefaultCard.details": "Details",
Expand Down Expand Up @@ -220,6 +221,7 @@
"landingPage.errGetNS": "Une erreur s'est produite lors de la tentative de récupération de l'espace de travail",
"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 :",
"landingPage.errEditedContent": "Nous avons détecté un changement dans le courriel ou l'espace de nom, veuillez actualiser la page et réessayer.",
"registrationPage.btnNext": "Suivant",
"registrationPage.btnStartSetup": "Commencer",
"registrationPage.lblNamespace": "Espace de travail",
Expand Down
57 changes: 32 additions & 25 deletions components/centraldashboard/public/components/landing-page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import '@polymer/iron-ajax/iron-ajax.js';
import '@polymer/iron-icons/iron-icons.js';
import '@polymer/iron-media-query/iron-media-query.js';
Expand Down Expand Up @@ -40,6 +39,7 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities
return {
userDetails: {type: Object, observer: '_onUserDetails'},
namespaceName: String,
generatedNamespace: String,
emailAddress: String,
errorText: {type: String, value: ''},
errorDetail: {type: String, value: ''},
Expand Down Expand Up @@ -98,6 +98,7 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities
ns = originalNs + counter;
}
this.namespaceName = ns;
this.generateNamespace = ns;
}).catch((e)=> {
this.showError('landingPage.errGeneral');
this.errorDetail= e;
Expand All @@ -110,28 +111,30 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities

async nextPage() {
// Verify the email + namesoace are as expacted
const API = this.$.MakeNamespace;
if (this.emailAddress != this.userDetails) {
console.log('DOESNT MATCH');
if (this.emailAddress != this.userDetails ||
this.generateNamespace != this.namespaceName) {
this._onCreateNamespaceError('editedData');
return;
} else {
const API = this.$.MakeNamespace;
API.body = {namespace: this.namespaceName};
this.waitForRedirect = true;
await API.generateRequest().completes.catch((e) => e);
await this.sleep(1); // So the errors and callbacks can schedule

/*
* Poll for profile over a span of 20 seconds (every 300ms)
* if still not there, let the user click next again!
*/
const success = await this.pollProfile(66, 300);
if (success) this._successSetup();

// Create the default notebook
const APICreateDefault = this.$.CreateDefaultNotebook;

await APICreateDefault.generateRequest().completes.catch((e) => e);
await this.sleep(1); // So the errors and callbacks can schedule
}
API.body = {namespace: this.namespaceName};
this.waitForRedirect = true;
await API.generateRequest().completes.catch((e) => e);
await this.sleep(1); // So the errors and callbacks can schedule

/*
* Poll for profile over a span of 20 seconds (every 300ms)
* if still not there, let the user click next again!
*/
const success = await this.pollProfile(66, 300);
if (success) this._successSetup();

// Create the default notebook
const APICreateDefault = this.$.CreateDefaultNotebook;

await APICreateDefault.generateRequest().completes.catch((e) => e);
await this.sleep(1); // So the errors and callbacks can schedule

return this.waitForRedirect = false;
}

Expand Down Expand Up @@ -164,17 +167,21 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities
}

_onCreateNamespaceError(ev) {
this.showError('mainPage.errCreateNS');
if (ev=='editedData') {
this.showError('landingPage.errEditedContent');
} else {
this.showError('landingPage.errCreateNS');
}
return;
}

_onGetNamespaceError(ev) {
this.showError('mainPage.errGetNS');
this.showError('landingPage.errGetNS');
return;
}

_onCreateDefaultNotebookError(ev) {
this.showError('mainPage.errCreateDefaultNotebook');
this.showError('landingPage.errCreateDefaultNotebook');
return;
}
}
Expand Down
1 change: 0 additions & 1 deletion components/centraldashboard/public/components/main-page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import '@polymer/app-layout/app-drawer/app-drawer.js';
import '@polymer/app-layout/app-drawer-layout/app-drawer-layout.js';
import '@polymer/app-layout/app-header/app-header.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ app-drawer-layout.flex(narrow='{{narrowMode}}',
namespace-needed-view(language='[[language]]', resources='[[resources]]')
iron-media-query(query='(max-width: 900px)', query-matches='{{sidebarBleed}}')
iron-media-query(query='(max-width: 1270px)', query-matches='{{thinView}}')
paper-toast#welcomeUser(duration=5000) Welcome, [[_extractLdap(user)]]!
paper-toast#welcomeUser(duration=5000, opened='[[!registrationFlow]]') {{localize('registrationPage.lblWelcome')}}, [[_extractLdap(user)]]!
paper-toast#ErrorToast(duration=0, opened='[[!empty(errorText)]]', on-click='closeError') {{localize(errorText)}}
paper-icon-button(icon='close')
template(is='dom-if', if='[[registrationFlow]]')
Expand Down

0 comments on commit 265f482

Please sign in to comment.