feat(editor): Allow enabling canvas v2 via instance settings (no-changelog) (#11447)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2024-10-29 14:41:10 +01:00 committed by GitHub
parent a701d87f5b
commit 60cdf0ba44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 34 additions and 3 deletions

View file

@ -21,6 +21,7 @@
"dist/**/*" "dist/**/*"
], ],
"devDependencies": { "devDependencies": {
"@n8n/config": "workspace:*",
"n8n-workflow": "workspace:*" "n8n-workflow": "workspace:*"
}, },
"dependencies": { "dependencies": {

View file

@ -1,3 +1,4 @@
import type { FrontendBetaFeatures } from '@n8n/config';
import type { ExpressionEvaluatorType, LogLevel, WorkflowSettings } from 'n8n-workflow'; import type { ExpressionEvaluatorType, LogLevel, WorkflowSettings } from 'n8n-workflow';
export interface IVersionNotificationSettings { export interface IVersionNotificationSettings {
@ -169,4 +170,5 @@ export interface FrontendSettings {
security: { security: {
blockFileAccessToN8nFiles: boolean; blockFileAccessToN8nFiles: boolean;
}; };
betaFeatures: FrontendBetaFeatures[];
} }

View file

@ -0,0 +1,11 @@
import { Config, Env } from '../decorators';
import { StringArray } from '../utils';
export type FrontendBetaFeatures = 'canvas_v2';
@Config
export class FrontendConfig {
/** Which UI experiments to enable. Separate multiple values with a comma `,` */
@Env('N8N_UI_BETA_FEATURES')
betaFeatures: StringArray<FrontendBetaFeatures> = [];
}

View file

@ -24,6 +24,7 @@ import { Config, Env, Nested } from './decorators';
export { Config, Env, Nested } from './decorators'; export { Config, Env, Nested } from './decorators';
export { TaskRunnersConfig } from './configs/runners.config'; export { TaskRunnersConfig } from './configs/runners.config';
export { SecurityConfig } from './configs/security.config'; export { SecurityConfig } from './configs/security.config';
export { FrontendBetaFeatures, FrontendConfig } from './configs/frontend.config';
export { LOG_SCOPES } from './configs/logging.config'; export { LOG_SCOPES } from './configs/logging.config';
export type { LogScope } from './configs/logging.config'; export type { LogScope } from './configs/logging.config';

View file

@ -1,5 +1,5 @@
import type { FrontendSettings, ITelemetrySettings } from '@n8n/api-types'; import type { FrontendSettings, ITelemetrySettings } from '@n8n/api-types';
import { GlobalConfig, SecurityConfig } from '@n8n/config'; import { GlobalConfig, FrontendConfig, SecurityConfig } from '@n8n/config';
import { createWriteStream } from 'fs'; import { createWriteStream } from 'fs';
import { mkdir } from 'fs/promises'; import { mkdir } from 'fs/promises';
import uniq from 'lodash/uniq'; import uniq from 'lodash/uniq';
@ -47,6 +47,7 @@ export class FrontendService {
private readonly instanceSettings: InstanceSettings, private readonly instanceSettings: InstanceSettings,
private readonly urlService: UrlService, private readonly urlService: UrlService,
private readonly securityConfig: SecurityConfig, private readonly securityConfig: SecurityConfig,
private readonly frontendConfig: FrontendConfig,
) { ) {
loadNodesAndCredentials.addPostProcessor(async () => await this.generateTypes()); loadNodesAndCredentials.addPostProcessor(async () => await this.generateTypes());
void this.generateTypes(); void this.generateTypes();
@ -228,6 +229,7 @@ export class FrontendService {
security: { security: {
blockFileAccessToN8nFiles: this.securityConfig.blockFileAccessToN8nFiles, blockFileAccessToN8nFiles: this.securityConfig.blockFileAccessToN8nFiles,
}, },
betaFeatures: this.frontendConfig.betaFeatures,
}; };
} }

View file

@ -124,4 +124,5 @@ export const defaultSettings: FrontendSettings = {
aiAssistant: { aiAssistant: {
enabled: false, enabled: false,
}, },
betaFeatures: [],
}; };

View file

@ -16,7 +16,7 @@ export function useNodeViewVersionSwitcher() {
const nodeViewVersion = useLocalStorage( const nodeViewVersion = useLocalStorage(
'NodeView.version', 'NodeView.version',
settingsStore.deploymentType === 'n8n-internal' ? '2' : '1', settingsStore.isCanvasV2Enabled ? '2' : '1',
); );
function setNodeViewSwitcherDropdownOpened(visible: boolean) { function setNodeViewSwitcherDropdownOpened(visible: boolean) {

View file

@ -156,6 +156,10 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => {
const isDevRelease = computed(() => settings.value.releaseChannel === 'dev'); const isDevRelease = computed(() => settings.value.releaseChannel === 'dev');
const isCanvasV2Enabled = computed(() =>
(settings.value.betaFeatures ?? []).includes('canvas_v2'),
);
const setSettings = (newSettings: FrontendSettings) => { const setSettings = (newSettings: FrontendSettings) => {
settings.value = newSettings; settings.value = newSettings;
userManagement.value = newSettings.userManagement; userManagement.value = newSettings.userManagement;
@ -418,6 +422,7 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => {
saveDataProgressExecution, saveDataProgressExecution,
isCommunityPlan, isCommunityPlan,
isAskAiEnabled, isAskAiEnabled,
isCanvasV2Enabled,
reset, reset,
testLdapConnection, testLdapConnection,
getLdapConfig, getLdapConfig,

View file

@ -254,6 +254,9 @@ importers:
specifier: 0.0.15 specifier: 0.0.15
version: 0.0.15(zod@3.23.8) version: 0.0.15(zod@3.23.8)
devDependencies: devDependencies:
'@n8n/config':
specifier: workspace:*
version: link:../config
n8n-workflow: n8n-workflow:
specifier: workspace:* specifier: workspace:*
version: link:../../workflow version: link:../../workflow
@ -12104,6 +12107,9 @@ packages:
vue-component-type-helpers@2.1.6: vue-component-type-helpers@2.1.6:
resolution: {integrity: sha512-ng11B8B/ZADUMMOsRbqv0arc442q7lifSubD0v8oDXIFoMg/mXwAPUunrroIDkY+mcD0dHKccdaznSVp8EoX3w==} resolution: {integrity: sha512-ng11B8B/ZADUMMOsRbqv0arc442q7lifSubD0v8oDXIFoMg/mXwAPUunrroIDkY+mcD0dHKccdaznSVp8EoX3w==}
vue-component-type-helpers@2.1.8:
resolution: {integrity: sha512-ii36gDzrYAfOQIkOlo44yceDdT5269gKmNGxf07Qx6seH2U50+tQ2ol02XLhYPmxrh6YabAsOdte8WDrpaO6Tw==}
vue-demi@0.14.10: vue-demi@0.14.10:
resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==} resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==}
engines: {node: '>=12'} engines: {node: '>=12'}
@ -16272,7 +16278,7 @@ snapshots:
ts-dedent: 2.2.0 ts-dedent: 2.2.0
type-fest: 2.19.0 type-fest: 2.19.0
vue: 3.5.11(typescript@5.6.2) vue: 3.5.11(typescript@5.6.2)
vue-component-type-helpers: 2.1.6 vue-component-type-helpers: 2.1.8
'@supabase/auth-js@2.65.0': '@supabase/auth-js@2.65.0':
dependencies: dependencies:
@ -25465,6 +25471,8 @@ snapshots:
vue-component-type-helpers@2.1.6: {} vue-component-type-helpers@2.1.6: {}
vue-component-type-helpers@2.1.8: {}
vue-demi@0.14.10(vue@3.5.11(typescript@5.6.2)): vue-demi@0.14.10(vue@3.5.11(typescript@5.6.2)):
dependencies: dependencies:
vue: 3.5.11(typescript@5.6.2) vue: 3.5.11(typescript@5.6.2)