refactor: Remove pre-setup prompt on owner setup (#6495)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-06-21 13:21:34 +02:00
committed by कारतोफ्फेलस्क्रिप्ट™
parent 0287d5becd
commit abe7f71627
7 changed files with 8 additions and 134 deletions

View File

@@ -25,12 +25,6 @@ export async function logout(context: IRestApiContext): Promise<void> {
await makeRestApiRequest(context, 'POST', '/logout');
}
export async function preOwnerSetup(
context: IRestApiContext,
): Promise<{ credentials: number; workflows: number }> {
return makeRestApiRequest(context, 'GET', '/owner/pre-setup');
}
export async function setupOwner(
context: IRestApiContext,
params: { firstName: string; lastName: string; email: string; password: string },

View File

@@ -90,15 +90,8 @@
"auth.roles.member": "Member",
"auth.roles.owner": "Owner",
"auth.agreement.label": "Inform me about security vulnerabilities if they arise",
"auth.setup.confirmOwnerSetup": "Set up owner account?",
"auth.setup.confirmOwnerSetupMessage": "To give others access to your <b>{entities}</b>, youll need to share these account details with them. Or you can continue as before with no account, by going back and skipping this setup. <a href=\"https://docs.n8n.io/user-management/\" target=\"_blank\">More info</a>",
"auth.setup.createAccount": "Create account",
"auth.setup.goBack": "Go back",
"auth.setup.next": "Next",
"auth.setup.settingUpOwnerError": "Problem setting up owner",
"auth.setup.setupConfirmation.concatEntities": "{workflows} and {credentials}",
"auth.setup.setupConfirmation.credentials": "{count} credential | {count} credentials",
"auth.setup.setupConfirmation.existingWorkflows": "{count} existing workflow | {count} existing workflows",
"auth.setup.setupOwner": "Set up owner account",
"auth.signin": "Sign in",
"auth.signin.error": "Problem logging in",

View File

@@ -8,7 +8,6 @@ import {
login,
loginCurrentUser,
logout,
preOwnerSetup,
reinvite,
sendForgotPasswordEmail,
setupOwner,
@@ -185,9 +184,6 @@ export const useUsersStore = defineStore(STORES.USERS, {
this.currentUserId = null;
usePostHog().reset();
},
async preOwnerSetup() {
return preOwnerSetup(useRootStore().getRestApiContext);
},
async createOwner(params: {
firstName: string;
lastName: string;

View File

@@ -11,14 +11,13 @@
import AuthView from './AuthView.vue';
import { defineComponent } from 'vue';
import { useToast, useMessage } from '@/composables';
import { useToast } from '@/composables';
import type { IFormBoxConfig } from '@/Interface';
import { MODAL_CONFIRM, VIEWS } from '@/constants';
import { VIEWS } from '@/constants';
import { mapStores } from 'pinia';
import { useUIStore } from '@/stores/ui.store';
import { useSettingsStore } from '@/stores/settings.store';
import { useUsersStore } from '@/stores/users.store';
import { useCredentialsStore } from '@/stores/credentials.store';
export default defineComponent({
name: 'SetupView',
@@ -26,15 +25,7 @@ export default defineComponent({
AuthView,
},
setup() {
return {
...useToast(),
...useMessage(),
};
},
async mounted() {
const { credentials, workflows } = await this.usersStore.preOwnerSetup();
this.credentialsCount = credentials;
this.workflowsCount = workflows;
return useToast();
},
data() {
const FORM_CONFIG: IFormBoxConfig = {
@@ -97,62 +88,14 @@ export default defineComponent({
return {
FORM_CONFIG,
loading: false,
workflowsCount: 0,
credentialsCount: 0,
};
},
computed: {
...mapStores(useCredentialsStore, useSettingsStore, useUIStore, useUsersStore),
...mapStores(useSettingsStore, useUIStore, useUsersStore),
},
methods: {
async confirmSetupOrGoBack(): Promise<boolean> {
if (this.workflowsCount === 0 && this.credentialsCount === 0) {
return true;
}
const workflows =
this.workflowsCount > 0
? this.$locale.baseText('auth.setup.setupConfirmation.existingWorkflows', {
adjustToNumber: this.workflowsCount,
})
: '';
const credentials =
this.credentialsCount > 0
? this.$locale.baseText('auth.setup.setupConfirmation.credentials', {
adjustToNumber: this.credentialsCount,
})
: '';
const entities =
workflows && credentials
? this.$locale.baseText('auth.setup.setupConfirmation.concatEntities', {
interpolate: { workflows, credentials },
})
: workflows || credentials;
const confirm = await this.confirm(
this.$locale.baseText('auth.setup.confirmOwnerSetupMessage', {
interpolate: {
entities,
},
}),
this.$locale.baseText('auth.setup.confirmOwnerSetup'),
{
dangerouslyUseHTMLString: true,
confirmButtonText: this.$locale.baseText('auth.setup.createAccount'),
cancelButtonText: this.$locale.baseText('auth.setup.goBack'),
},
);
return confirm === MODAL_CONFIRM;
},
async onSubmit(values: { [key: string]: string | boolean }) {
try {
const confirmSetup = await this.confirmSetupOrGoBack();
if (!confirmSetup) {
return;
}
const forceRedirectedHere = this.settingsStore.showSetupPage;
this.loading = true;
await this.usersStore.createOwner(