refactor(core): Improve instance owner setup and add unit tests (no-changelog) (#5499)

* refactor(core): Avoid fetching all workflows and credentials for the owner setup screen

* refactor(core): Add unit tests for the owner controller
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-02-17 10:59:09 +01:00
committed by GitHub
parent 12104bc4a3
commit 561882f599
10 changed files with 204 additions and 51 deletions

View File

@@ -28,9 +28,9 @@ export default mixins(showMessage, restApi).extend({
AuthView,
},
async mounted() {
const getAllCredentialsPromise = this.getAllCredentials();
const getAllWorkflowsPromise = this.getAllWorkflows();
await Promise.all([getAllCredentialsPromise, getAllWorkflowsPromise]);
const { credentials, workflows } = await this.usersStore.preOwnerSetup();
this.credentialsCount = credentials;
this.workflowsCount = workflows;
},
data() {
const FORM_CONFIG: IFormBoxConfig = {
@@ -102,14 +102,6 @@ export default mixins(showMessage, restApi).extend({
...mapStores(useCredentialsStore, useSettingsStore, useUIStore, useUsersStore),
},
methods: {
async getAllCredentials() {
const credentials = await this.credentialsStore.fetchAllCredentials();
this.credentialsCount = credentials.length;
},
async getAllWorkflows() {
const workflows = await this.restApi().getWorkflows();
this.workflowsCount = workflows.length;
},
async confirmSetupOrGoBack(): Promise<boolean> {
if (this.workflowsCount === 0 && this.credentialsCount === 0) {
return true;