From 637b6c4d3eb9e647a57f44667ce757e16cd5d2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 4 Apr 2024 15:53:34 +0200 Subject: [PATCH] refactor(editor): Do not make rest api calls for disabled features (no-changelog) (#9046) --- packages/editor-ui/src/init.ts | 16 +++++++----- packages/editor-ui/src/views/NodeView.vue | 26 ++++++++++++------- .../src/views/SettingsExternalSecrets.vue | 1 + .../src/views/SettingsSourceControl.vue | 1 + .../editor-ui/src/views/VariablesView.vue | 1 + 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/packages/editor-ui/src/init.ts b/packages/editor-ui/src/init.ts index ed76b904bc..1e6ca97b65 100644 --- a/packages/editor-ui/src/init.ts +++ b/packages/editor-ui/src/init.ts @@ -24,15 +24,17 @@ export async function initializeCore() { const versionsStore = useVersionsStore(); await settingsStore.initialize(); - await usersStore.initialize(); + if (!settingsStore.isPreviewMode) { + await usersStore.initialize(); - void versionsStore.checkForNewVersions(); + void versionsStore.checkForNewVersions(); - if (settingsStore.isCloudDeployment) { - try { - await initializeCloudHooks(); - } catch (e) { - console.error('Failed to initialize cloud hooks:', e); + if (settingsStore.isCloudDeployment) { + try { + await initializeCloudHooks(); + } catch (e) { + console.error('Failed to initialize cloud hooks:', e); + } } } diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 940ba3bab2..9ea6de100f 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -809,16 +809,22 @@ export default defineComponent({ this.clipboard.onPaste.value = this.onClipboardPasteEvent; this.canvasStore.startLoading(); - const loadPromises = - this.settingsStore.isPreviewMode && this.isDemo - ? [] - : [ - this.loadActiveWorkflows(), - this.loadCredentials(), - this.loadCredentialTypes(), - this.loadVariables(), - this.loadSecrets(), - ]; + + const loadPromises = (() => { + if (this.settingsStore.isPreviewMode && this.isDemo) return []; + const promises = [ + this.loadActiveWorkflows(), + this.loadCredentials(), + this.loadCredentialTypes(), + ]; + if (this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.Variables)) { + promises.push(this.loadVariables()); + } + if (this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.ExternalSecrets)) { + promises.push(this.loadSecrets()); + } + return promises; + })(); if (this.nodeTypesStore.allNodeTypes.length === 0) { loadPromises.push(this.loadNodeTypes()); diff --git a/packages/editor-ui/src/views/SettingsExternalSecrets.vue b/packages/editor-ui/src/views/SettingsExternalSecrets.vue index 886d70250c..a8fe89fb6c 100644 --- a/packages/editor-ui/src/views/SettingsExternalSecrets.vue +++ b/packages/editor-ui/src/views/SettingsExternalSecrets.vue @@ -19,6 +19,7 @@ const sortedProviders = computed(() => { }); onMounted(() => { + if (!externalSecretsStore.isEnterpriseExternalSecretsEnabled) return; try { void externalSecretsStore.fetchAllSecrets(); void externalSecretsStore.getProviders(); diff --git a/packages/editor-ui/src/views/SettingsSourceControl.vue b/packages/editor-ui/src/views/SettingsSourceControl.vue index 176c118c01..89d0156407 100644 --- a/packages/editor-ui/src/views/SettingsSourceControl.vue +++ b/packages/editor-ui/src/views/SettingsSourceControl.vue @@ -112,6 +112,7 @@ const initialize = async () => { }; onMounted(async () => { + if (!sourceControlStore.isEnterpriseSourceControlEnabled) return; await initialize(); }); diff --git a/packages/editor-ui/src/views/VariablesView.vue b/packages/editor-ui/src/views/VariablesView.vue index 6364361f8a..478ce29c96 100644 --- a/packages/editor-ui/src/views/VariablesView.vue +++ b/packages/editor-ui/src/views/VariablesView.vue @@ -116,6 +116,7 @@ function resetNewVariablesList() { } async function initialize() { + if (!isFeatureEnabled.value) return; await environmentsStore.fetchAllVariables(); allVariables.value = [...environmentsStore.variables];