n8n/packages/editor-ui/src/views/SignupView.vue
Milorad FIlipović 3ebfa45570
refactor: Add Onboarding call prompts (#3682)
*  Implemented initial onboarding call prompt logic

*  Added onboarding call prompt feature environment variable

*  Implemented onboarding session signup modal

* 📈 Added initial telemetry for the onboarding call prompt

* ✔️ Fixing linter error in server.ts

* 💄 Updating onboaring call prompt and modal wording and styling

*  Implemented initial version of fake doors feature

*  Added parameters to onboarding call prompt request

*  Finished implementing fake doors in settings

* 🔨 Updating onboarding call prompt fetching logic (fetching before timeout starts)

* 👌 Updating onboarding call prompt and fake door components based on the front-end review feedback

*  Updated fake doors so they support UI location specification. Added credentials UI fake doors.

*  Added checkbox to the signup form, improved N8NCheckbox formatting to better handle overflow

* 💄 Moving seignup checkbox label text to i18n file, updating checkbox component css to force text wrap

*  Update API calls to work with the new workflow request and response formats

* 👌 Updating fake door front-end based on the review feedback

* 👌 Updating onboarding call prompt and fake doors UI based in the product feedback

*   Updated onboarding call prompts front-end to work with new endpoints and added new telemetry events

* 🐛 Fixing onboarding call prompts not appearing in first user sessions

* ️ add createdAt to PublicUser

* 👌 Updating onboarding call prompts front-end to work with the latest back-end and addressing latest product review

*  Improving error handling when submitting user emails on signup

* 💄 Updating info text on Logging feature page

* 💄 Updating first onboarding call prompt timeout to 5 minutes

* 💄 Fixing `N8nCheckbox` component font overflow

Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2022-07-27 16:28:13 +02:00

127 lines
3.2 KiB
Vue

<template>
<AuthView
:form="FORM_CONFIG"
:formLoading="loading"
:subtitle="inviteMessage"
@submit="onSubmit"
/>
</template>
<script lang="ts">
import AuthView from './AuthView.vue';
import { showMessage } from '@/components/mixins/showMessage';
import mixins from 'vue-typed-mixins';
import { IFormBoxConfig } from '@/Interface';
import { VIEWS } from '@/constants';
export default mixins(
showMessage,
).extend({
name: 'SignupView',
components: {
AuthView,
},
data() {
const FORM_CONFIG: IFormBoxConfig = {
title: this.$locale.baseText('auth.signup.setupYourAccount'),
buttonText: this.$locale.baseText('auth.signup.finishAccountSetup'),
inputs: [
{
name: 'firstName',
properties: {
label: this.$locale.baseText('auth.firstName'),
maxlength: 32,
required: true,
autocomplete: 'given-name',
capitalize: true,
},
},
{
name: 'lastName',
properties: {
label: this.$locale.baseText('auth.lastName'),
maxlength: 32,
required: true,
autocomplete: 'family-name',
capitalize: true,
},
},
{
name: 'password',
properties: {
label: this.$locale.baseText('auth.password'),
type: 'password',
validationRules: [{ name: 'DEFAULT_PASSWORD_RULES' }],
required: true,
infoText: this.$locale.baseText('auth.defaultPasswordRequirements'),
autocomplete: 'new-password',
capitalize: true,
},
},
{
name: 'agree',
properties: {
label: this.$locale.baseText('auth.agreement.label'),
type: 'checkbox',
},
},
],
};
return {
FORM_CONFIG,
loading: false,
inviter: null as null | {firstName: string, lastName: string},
};
},
async mounted() {
const inviterId = this.$route.query.inviterId;
const inviteeId = this.$route.query.inviteeId;
try {
if (!inviterId || !inviteeId) {
throw new Error(this.$locale.baseText('auth.signup.missingTokenError'));
}
const invite = await this.$store.dispatch('users/validateSignupToken', { inviterId, inviteeId});
this.inviter = invite.inviter as {firstName: string, lastName: string};
} catch (e) {
this.$showError(e, this.$locale.baseText('auth.signup.tokenValidationError'));
this.$router.replace({name: VIEWS.SIGNIN});
}
},
computed: {
inviteMessage(): null | string {
if (!this.inviter) {
return null;
}
return this.$locale.baseText(
'settings.signup.signUpInviterInfo',
{ interpolate: { firstName: this.inviter.firstName, lastName: this.inviter.lastName }},
);
},
},
methods: {
async onSubmit(values: {[key: string]: string | boolean}) {
try {
this.loading = true;
const inviterId = this.$route.query.inviterId;
const inviteeId = this.$route.query.inviteeId;
await this.$store.dispatch('users/signup', {...values, inviterId, inviteeId});
if (values.agree === true) {
try {
await this.$store.dispatch('ui/submitContactEmail', { email: values.email, agree: values.agree });
} catch { }
}
await this.$router.push({ name: VIEWS.HOMEPAGE });
} catch (error) {
this.$showError(error, this.$locale.baseText('auth.signup.setupYourAccountError'));
}
this.loading = false;
},
},
});
</script>