mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 17:14:05 -08:00
d143f3f2ec
* adds ExecutionEvents view modal to ExecutionList * fix time rendering and remove wf column * checks for unfinished executions and fails them * prevent re-setting stoppedAt for execution * some cleanup / manually create rundata after crash * quicksave * remove Threads lib, log worker rewrite * cleanup comment * fix sentry destination return value * test for tests... * run tests with single worker * fix tests * remove console log * add endpoint for execution data recovery * lint cleanup and some refactoring * fix accidental recursion * remove cyclic imports * add rundata recovery to Workflowrunner * remove comments * cleanup and refactor * adds a status field to executions * setExecutionStatus on queued worker * fix onWorkflowPostExecute * set waiting from worker * get crashed status into frontend * remove comment * merge fix * cleanup * catch empty rundata in recovery * refactor IExecutionsSummary and inject nodeExecution Errors * reduce default event log size to 10mb from 100mb * add per node execution status * lint fix * merge and lint fix * phrasing change * improve preview rendering and messaging * remove debug * Improve partial rundata recovery * fix labels * fix line through * send manual rundata to ui at crash * some type and msg push fixes * improve recovered item rendering in preview * update workflowStatistics on recover * merge fix * review fixes * merge fix * notify eventbus when ui is back up * add a small timeout to make sure the UI is back up * increase reconnect timeout to 30s * adjust recover timeout and ui connection lost msg * do not stop execution in editor after x reconnects * add executionRecovered push event * fix recovered connection not green * remove reconnect toast and merge existing rundata * merge editor and recovered data for own mode
321 lines
8.4 KiB
Vue
321 lines
8.4 KiB
Vue
<template>
|
|
<Modal
|
|
:name="INVITE_USER_MODAL_KEY"
|
|
@enter="onSubmit"
|
|
:title="
|
|
$locale.baseText(
|
|
showInviteUrls ? 'settings.users.copyInviteUrls' : 'settings.users.inviteNewUsers',
|
|
)
|
|
"
|
|
:center="true"
|
|
width="460px"
|
|
:eventBus="modalBus"
|
|
>
|
|
<template #content>
|
|
<div v-if="showInviteUrls">
|
|
<n8n-users-list :users="invitedUsers">
|
|
<template #actions="{ user }">
|
|
<n8n-tooltip>
|
|
<template #content>
|
|
{{ $locale.baseText('settings.users.inviteLink.copy') }}
|
|
</template>
|
|
<n8n-icon-button
|
|
icon="link"
|
|
type="tertiary"
|
|
data-test-id="copy-invite-link-button"
|
|
:data-invite-link="user.inviteAcceptUrl"
|
|
@click="onCopyInviteLink(user)"
|
|
></n8n-icon-button>
|
|
</n8n-tooltip>
|
|
</template>
|
|
</n8n-users-list>
|
|
</div>
|
|
<n8n-form-inputs
|
|
v-else
|
|
:inputs="config"
|
|
:eventBus="formBus"
|
|
:columnView="true"
|
|
@input="onInput"
|
|
@submit="onSubmit"
|
|
/>
|
|
<n8n-info-tip v-if="!settingsStore.isSmtpSetup" class="mt-s">
|
|
<i18n path="settings.users.setupSMTPInfo">
|
|
<template #link>
|
|
<a
|
|
href="https://docs.n8n.io/reference/user-management.html#step-one-smtp"
|
|
target="_blank"
|
|
>
|
|
{{ $locale.baseText('settings.users.setupSMTPInfo.link') }}
|
|
</a>
|
|
</template>
|
|
</i18n>
|
|
</n8n-info-tip>
|
|
</template>
|
|
<template v-if="!showInviteUrls" #footer>
|
|
<n8n-button
|
|
:loading="loading"
|
|
:disabled="!enabledButton"
|
|
:label="buttonLabel"
|
|
@click="onSubmitClick"
|
|
float="right"
|
|
/>
|
|
</template>
|
|
</Modal>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
import { showMessage } from '@/mixins/showMessage';
|
|
import { copyPaste } from '@/mixins/copyPaste';
|
|
import Modal from './Modal.vue';
|
|
import Vue from 'vue';
|
|
import { IFormInputs, IInviteResponse, IUser } from '@/Interface';
|
|
import { VALID_EMAIL_REGEX, INVITE_USER_MODAL_KEY } from '@/constants';
|
|
import { ROLE } from '@/utils';
|
|
import { mapStores } from 'pinia';
|
|
import { useUsersStore } from '@/stores/users';
|
|
import { useSettingsStore } from '@/stores/settings';
|
|
|
|
const NAME_EMAIL_FORMAT_REGEX = /^.* <(.*)>$/;
|
|
|
|
function getEmail(email: string): string {
|
|
let parsed = email.trim();
|
|
if (NAME_EMAIL_FORMAT_REGEX.test(parsed)) {
|
|
const matches = parsed.match(NAME_EMAIL_FORMAT_REGEX);
|
|
if (matches && matches.length === 2) {
|
|
parsed = matches[1];
|
|
}
|
|
}
|
|
return parsed;
|
|
}
|
|
|
|
export default mixins(showMessage, copyPaste).extend({
|
|
components: { Modal },
|
|
name: 'InviteUsersModal',
|
|
props: {
|
|
modalName: {
|
|
type: String,
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
config: null as IFormInputs | null,
|
|
formBus: new Vue(),
|
|
modalBus: new Vue(),
|
|
emails: '',
|
|
showInviteUrls: null as IInviteResponse[] | null,
|
|
loading: false,
|
|
INVITE_USER_MODAL_KEY,
|
|
};
|
|
},
|
|
mounted() {
|
|
this.config = [
|
|
{
|
|
name: 'emails',
|
|
properties: {
|
|
label: this.$locale.baseText('settings.users.newEmailsToInvite'),
|
|
required: true,
|
|
validationRules: [{ name: 'VALID_EMAILS' }],
|
|
validators: {
|
|
VALID_EMAILS: {
|
|
validate: this.validateEmails,
|
|
},
|
|
},
|
|
placeholder: 'name1@email.com, name2@email.com, ...',
|
|
capitalize: true,
|
|
focusInitially: true,
|
|
},
|
|
},
|
|
{
|
|
name: 'role',
|
|
initialValue: 'member',
|
|
properties: {
|
|
label: this.$locale.baseText('auth.role'),
|
|
required: true,
|
|
type: 'select',
|
|
options: [
|
|
{
|
|
value: ROLE.Member,
|
|
label: this.$locale.baseText('auth.roles.member'),
|
|
},
|
|
],
|
|
capitalize: true,
|
|
},
|
|
},
|
|
];
|
|
},
|
|
computed: {
|
|
...mapStores(useUsersStore, useSettingsStore),
|
|
emailsCount(): number {
|
|
return this.emails.split(',').filter((email: string) => !!email.trim()).length;
|
|
},
|
|
buttonLabel(): string {
|
|
if (this.emailsCount > 1) {
|
|
return this.$locale.baseText(
|
|
`settings.users.inviteXUser${this.settingsStore.isSmtpSetup ? '' : '.inviteUrl'}`,
|
|
{
|
|
interpolate: { count: this.emailsCount.toString() },
|
|
},
|
|
);
|
|
}
|
|
|
|
return this.$locale.baseText(
|
|
`settings.users.inviteUser${this.settingsStore.isSmtpSetup ? '' : '.inviteUrl'}`,
|
|
);
|
|
},
|
|
enabledButton(): boolean {
|
|
return this.emailsCount >= 1;
|
|
},
|
|
invitedUsers(): IUser[] {
|
|
return this.showInviteUrls
|
|
? this.usersStore.allUsers.filter((user) =>
|
|
this.showInviteUrls!.find((invite) => invite.user.id === user.id),
|
|
)
|
|
: [];
|
|
},
|
|
},
|
|
methods: {
|
|
validateEmails(value: string | number | boolean | null | undefined) {
|
|
if (typeof value !== 'string') {
|
|
return false;
|
|
}
|
|
|
|
const emails = value.split(',');
|
|
for (let i = 0; i < emails.length; i++) {
|
|
const email = emails[i];
|
|
const parsed = getEmail(email);
|
|
|
|
if (!!parsed.trim() && !VALID_EMAIL_REGEX.test(String(parsed).trim().toLowerCase())) {
|
|
return {
|
|
messageKey: 'settings.users.invalidEmailError',
|
|
options: { interpolate: { email: parsed } },
|
|
};
|
|
}
|
|
}
|
|
|
|
return false;
|
|
},
|
|
onInput(e: { name: string; value: string }) {
|
|
if (e.name === 'emails') {
|
|
this.emails = e.value;
|
|
}
|
|
},
|
|
async onSubmit() {
|
|
try {
|
|
this.loading = true;
|
|
|
|
const emails = this.emails
|
|
.split(',')
|
|
.map((email) => ({ email: getEmail(email) }))
|
|
.filter((invite) => !!invite.email);
|
|
|
|
if (emails.length === 0) {
|
|
throw new Error(this.$locale.baseText('settings.users.noUsersToInvite'));
|
|
}
|
|
|
|
const invited: IInviteResponse[] = await this.usersStore.inviteUsers(emails);
|
|
const erroredInvites = invited.filter((invite) => invite.error);
|
|
const successfulEmailInvites = invited.filter(
|
|
(invite) => !invite.error && invite.user.emailSent,
|
|
);
|
|
const successfulUrlInvites = invited.filter(
|
|
(invite) => !invite.error && !invite.user.emailSent,
|
|
);
|
|
|
|
if (successfulEmailInvites.length) {
|
|
this.$showMessage({
|
|
type: 'success',
|
|
title: this.$locale.baseText(
|
|
successfulEmailInvites.length > 1
|
|
? 'settings.users.usersInvited'
|
|
: 'settings.users.userInvited',
|
|
),
|
|
message: this.$locale.baseText('settings.users.emailInvitesSent', {
|
|
interpolate: {
|
|
emails: successfulEmailInvites.map(({ user }) => user.email).join(', '),
|
|
},
|
|
}),
|
|
});
|
|
}
|
|
|
|
if (successfulUrlInvites.length) {
|
|
if (successfulUrlInvites.length === 1) {
|
|
this.copyToClipboard(successfulUrlInvites[0].user.inviteAcceptUrl);
|
|
}
|
|
|
|
this.$showMessage({
|
|
type: 'success',
|
|
title: this.$locale.baseText(
|
|
successfulUrlInvites.length > 1
|
|
? 'settings.users.multipleInviteUrlsCreated'
|
|
: 'settings.users.inviteUrlCreated',
|
|
),
|
|
message: this.$locale.baseText(
|
|
successfulUrlInvites.length > 1
|
|
? 'settings.users.multipleInviteUrlsCreated.message'
|
|
: 'settings.users.inviteUrlCreated.message',
|
|
{
|
|
interpolate: {
|
|
emails: successfulUrlInvites.map(({ user }) => user.email).join(', '),
|
|
},
|
|
},
|
|
),
|
|
});
|
|
}
|
|
|
|
if (erroredInvites.length) {
|
|
setTimeout(() => {
|
|
this.$showMessage({
|
|
type: 'error',
|
|
title: this.$locale.baseText('settings.users.usersEmailedError'),
|
|
message: this.$locale.baseText('settings.users.emailInvitesSentError', {
|
|
interpolate: { emails: erroredInvites.map(({ error }) => error).join(', ') },
|
|
}),
|
|
});
|
|
}, 0); // notifications stack on top of each other otherwise
|
|
}
|
|
|
|
if (successfulUrlInvites.length > 1) {
|
|
this.showInviteUrls = successfulUrlInvites;
|
|
} else {
|
|
this.modalBus.$emit('close');
|
|
}
|
|
} catch (error) {
|
|
this.$showError(error, this.$locale.baseText('settings.users.usersInvitedError'));
|
|
}
|
|
this.loading = false;
|
|
},
|
|
showCopyInviteLinkToast(successfulUrlInvites: IInviteResponse[]) {
|
|
this.$showMessage({
|
|
type: 'success',
|
|
title: this.$locale.baseText(
|
|
successfulUrlInvites.length > 1
|
|
? 'settings.users.multipleInviteUrlsCreated'
|
|
: 'settings.users.inviteUrlCreated',
|
|
),
|
|
message: this.$locale.baseText(
|
|
successfulUrlInvites.length > 1
|
|
? 'settings.users.multipleInviteUrlsCreated.message'
|
|
: 'settings.users.inviteUrlCreated.message',
|
|
{
|
|
interpolate: {
|
|
emails: successfulUrlInvites.map(({ user }) => user.email).join(', '),
|
|
},
|
|
},
|
|
),
|
|
});
|
|
},
|
|
onSubmitClick() {
|
|
this.formBus.$emit('submit');
|
|
},
|
|
onCopyInviteLink(user: IUser) {
|
|
if (user.inviteAcceptUrl && this.showInviteUrls) {
|
|
this.copyToClipboard(user.inviteAcceptUrl);
|
|
this.showCopyInviteLinkToast([]);
|
|
}
|
|
},
|
|
},
|
|
});
|
|
</script>
|