feat: Enable canvas v2 only if beta feature enabled (no-changelog) (#12049)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions

This commit is contained in:
Alex Grozav 2024-12-04 21:33:35 +02:00 committed by GitHub
parent 5c76de324c
commit 72e6343964
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 26 deletions

View file

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

View file

@ -191,30 +191,32 @@ const workflowMenuItems = computed<ActionDropdownItem[]>(() => {
disabled: !onWorkflowPage.value || isNewWorkflow.value, disabled: !onWorkflowPage.value || isNewWorkflow.value,
}); });
actions.push({ if (settingsStore.isCanvasV2Enabled) {
id: WORKFLOW_MENU_ACTIONS.SWITCH_NODE_VIEW_VERSION, actions.push({
...(nodeViewVersion.value === '2' id: WORKFLOW_MENU_ACTIONS.SWITCH_NODE_VIEW_VERSION,
? nodeViewSwitcherDiscovered.value || isNewUser.value ...(nodeViewVersion.value === '2'
? {} ? nodeViewSwitcherDiscovered.value || isNewUser.value
: { ? {}
badge: locale.baseText('menuActions.badge.new'), : {
} badge: locale.baseText('menuActions.badge.new'),
: nodeViewSwitcherDiscovered.value }
? { : nodeViewSwitcherDiscovered.value
badge: locale.baseText('menuActions.badge.beta'), ? {
badgeProps: { badge: locale.baseText('menuActions.badge.beta'),
theme: 'tertiary', badgeProps: {
}, theme: 'tertiary',
} },
: { }
badge: locale.baseText('menuActions.badge.new'), : {
}), badge: locale.baseText('menuActions.badge.new'),
label: }),
nodeViewVersion.value === '2' label:
? locale.baseText('menuActions.switchToOldNodeViewVersion') nodeViewVersion.value === '2'
: locale.baseText('menuActions.switchToNewNodeViewVersion'), ? locale.baseText('menuActions.switchToOldNodeViewVersion')
disabled: !onWorkflowPage.value, : locale.baseText('menuActions.switchToNewNodeViewVersion'),
}); disabled: !onWorkflowPage.value,
});
}
if ((workflowPermissions.value.delete && !props.readOnly) || isNewWorkflow.value) { if ((workflowPermissions.value.delete && !props.readOnly) || isNewWorkflow.value) {
actions.push({ actions.push({

View file

@ -16,6 +16,11 @@ describe('useNodeViewVersionSwitcher', () => {
const initialState = { const initialState = {
[STORES.WORKFLOWS]: {}, [STORES.WORKFLOWS]: {},
[STORES.NDV]: {}, [STORES.NDV]: {},
[STORES.SETTINGS]: {
settings: {
betaFeatures: ['canvas_v2'],
},
},
}; };
beforeEach(() => { beforeEach(() => {

View file

@ -3,15 +3,18 @@ import { useLocalStorage } from '@vueuse/core';
import { useTelemetry } from '@/composables/useTelemetry'; import { useTelemetry } from '@/composables/useTelemetry';
import { useWorkflowsStore } from '@/stores/workflows.store'; import { useWorkflowsStore } from '@/stores/workflows.store';
import { useNDVStore } from '@/stores/ndv.store'; import { useNDVStore } from '@/stores/ndv.store';
import { useSettingsStore } from '@/stores/settings.store';
export function useNodeViewVersionSwitcher() { export function useNodeViewVersionSwitcher() {
const ndvStore = useNDVStore(); const ndvStore = useNDVStore();
const workflowsStore = useWorkflowsStore(); const workflowsStore = useWorkflowsStore();
const telemetry = useTelemetry(); const telemetry = useTelemetry();
const settingsStore = useSettingsStore();
const isNewUser = computed(() => workflowsStore.activeWorkflows.length === 0); const isNewUser = computed(() => workflowsStore.activeWorkflows.length === 0);
const nodeViewVersion = useLocalStorage('NodeView.version', '2'); const defaultVersion = settingsStore.isCanvasV2Enabled ? '2' : '1';
const nodeViewVersion = useLocalStorage('NodeView.version', defaultVersion);
const nodeViewVersionMigrated = useLocalStorage('NodeView.migrated', false); const nodeViewVersionMigrated = useLocalStorage('NodeView.migrated', false);
function setNodeViewSwitcherDropdownOpened(visible: boolean) { function setNodeViewSwitcherDropdownOpened(visible: boolean) {