n8n/packages/editor-ui/src/components/OnboardingCallSignupModal.vue
Milorad FIlipović 40e413d958
refactor(editor): Migrate part of the vuex store to pinia (#4484)
*  Added pinia support. Migrated community nodes module.
*  Added ui pinia store, moved some data from root store to it, updated modals to work with pinia stores
*  Added ui pinia store and migrated a part of the root store
*  Migrated `settings` store to pinia
*  Removing vuex store refs from router
*  Migrated `users` module to pinia store
*  Fixing errors after sync with master
*  One more error after merge
*  Created `workflows` pinia store. Moved large part of root store to it. Started updating references.
*  Finished migrating workflows store to pinia
*  Renaming some getters and actions to make more sense
*  Finished migrating the root store to pinia
*  Migrated ndv store to pinia
*  Renaming main panel dimensions getter so it doesn't clash with data prop name
* ✔️ Fixing lint errors
*  Migrated `templates` store to pinia
*  Migrated the `nodeTypes`store
*  Removed unused pieces of code and oold vuex modules
*  Adding vuex calls to pinia store, fi	xing wrong references
* 💄 Removing leftover $store refs
*  Added legacy getters and mutations to store to support webhooks
*  Added missing front-end hooks, updated vuex state subscriptions to pinia
* ✔️ Fixing linting errors
*  Removing vue composition api plugin
*  Fixing main sidebar state when loading node view
* 🐛 Fixing an error when activating workflows
* 🐛 Fixing isses with workflow settings and executions auto-refresh
* 🐛 Removing duplicate listeners which cause import error
* 🐛 Fixing route authentication
*  Updating freshly pulled $store refs
* Adding deleted const
*  Updating store references in ee features. Reseting NodeView credentials update flag when resetting workspace
*  Adding return type to email submission modal
*  Making NodeView only react to paste event when active
* 🐛 Fixing signup view errors
* 👌 Addressing PR review comments
* 👌 Addressing new PR comments
* 👌 Updating invite id logic in signup view
2022-11-04 14:04:31 +01:00

132 lines
3.1 KiB
Vue

<template>
<Modal
:name="ONBOARDING_CALL_SIGNUP_MODAL_KEY"
:title="$locale.baseText('onboardingCallSignupModal.title')"
:eventBus="modalBus"
:center="true"
:showClose="false"
:beforeClose="onModalClose"
width="460px"
>
<template slot="content">
<div class="pb-m">
<n8n-text>
{{ $locale.baseText('onboardingCallSignupModal.description') }}
</n8n-text>
</div>
<div @keyup.enter="onSignup">
<n8n-input v-model="email" :placeholder="$locale.baseText('onboardingCallSignupModal.emailInput.placeholder')" />
<n8n-text v-if="showError" size="small" class="mt-4xs" tag="div" color="danger">
{{ $locale.baseText('onboardingCallSignupModal.infoText.emailError') }}
</n8n-text>
</div>
</template>
<template slot="footer">
<div :class="$style.buttonsContainer">
<n8n-button
:label="$locale.baseText('onboardingCallSignupModal.cancelButton.label')"
:disabled="loading"
size="medium"
float="right"
type="outline"
@click="onCancel"
/>
<n8n-button
:disabled="email === '' || loading"
:label="$locale.baseText('onboardingCallSignupModal.signupButton.label')"
size="medium"
float="right"
:loading="loading"
@click="onSignup"
/>
</div>
</template>
</Modal>
</template>
<script lang="ts">
import Vue from 'vue';
import {
ONBOARDING_CALL_SIGNUP_MODAL_KEY,
VALID_EMAIL_REGEX,
} from '@/constants';
import Modal from './Modal.vue';
import mixins from 'vue-typed-mixins';
import { showMessage } from './mixins/showMessage';
import { mapStores } from 'pinia';
import { useUIStore } from '@/stores/ui';
export default mixins(
showMessage,
).extend({
components: {
Modal,
},
name: 'OnboardingCallSignupModal',
props: [ 'modalName' ],
data() {
return {
email: '',
modalBus: new Vue(),
ONBOARDING_CALL_SIGNUP_MODAL_KEY,
showError: false,
okToClose: false,
loading: false,
};
},
computed: {
...mapStores(useUIStore),
isEmailValid(): boolean {
return VALID_EMAIL_REGEX.test(String(this.email).toLowerCase());
},
},
methods: {
async onSignup() {
if (!this.isEmailValid) {
this.showError = true;
return;
}
this.showError = false;
this.loading = true;
this.okToClose = false;
try {
await this.uiStore.applyForOnboardingCall(this.email);
this.$showMessage({
type: 'success',
title: this.$locale.baseText('onboardingCallSignupSucess.title'),
message: this.$locale.baseText('onboardingCallSignupSucess.message'),
});
this.okToClose = true;
this.modalBus.$emit('close');
} catch (e) {
this.$showError(
e,
this.$locale.baseText('onboardingCallSignupFailed.title'),
this.$locale.baseText('onboardingCallSignupFailed.message'),
);
this.loading = false;
this.okToClose = true;
}
},
async onCancel() {
this.okToClose = true;
this.modalBus.$emit('close');
},
onModalClose() {
return this.okToClose;
},
},
});
</script>
<style lang="scss" module>
.buttonsContainer {
display: flex;
justify-content: flex-end;
column-gap: var(--spacing-xs);
}
</style>