From 71b72942b9c577b9a7b07a9ba43cdd724cde16b1 Mon Sep 17 00:00:00 2001 From: Michael Auerswald Date: Tue, 18 Apr 2023 12:04:22 +0200 Subject: [PATCH] add versionControl feature flag --- packages/cli/src/Interfaces.ts | 1 + packages/cli/src/License.ts | 4 ++++ packages/cli/src/Server.ts | 3 +++ packages/cli/src/api/e2e.api.ts | 1 + packages/cli/src/constants.ts | 1 + .../src/environment/versionControl/versionControlHelper.ts | 7 +++++++ packages/editor-ui/src/constants.ts | 1 + 7 files changed, 18 insertions(+) create mode 100644 packages/cli/src/environment/versionControl/versionControlHelper.ts diff --git a/packages/cli/src/Interfaces.ts b/packages/cli/src/Interfaces.ts index cb4ad810f7f87..bb2f84d3dd5e0 100644 --- a/packages/cli/src/Interfaces.ts +++ b/packages/cli/src/Interfaces.ts @@ -538,6 +538,7 @@ export interface IN8nUISettings { saml: boolean; logStreaming: boolean; advancedExecutionFilters: boolean; + versionControl: boolean; }; hideUsagePage: boolean; license: { diff --git a/packages/cli/src/License.ts b/packages/cli/src/License.ts index 19d3e9510fdd7..348a1dee28972 100644 --- a/packages/cli/src/License.ts +++ b/packages/cli/src/License.ts @@ -119,6 +119,10 @@ export class License { return this.isFeatureEnabled(LICENSE_FEATURES.ADVANCED_EXECUTION_FILTERS); } + isVersionControlEnabled() { + return this.isFeatureEnabled(LICENSE_FEATURES.VERSION_CONTROL); + } + getCurrentEntitlements() { return this.manager?.getCurrentEntitlements() ?? []; } diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 9081651b878b7..487a889ea55b2 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -158,6 +158,7 @@ import { SamlController } from './sso/saml/routes/saml.controller.ee'; import { SamlService } from './sso/saml/saml.service.ee'; import { LdapManager } from './Ldap/LdapManager.ee'; import { getCurrentAuthenticationMethod } from './sso/ssoHelpers'; +import { isVersionControlEnabled } from './environment/versionControl/versionControlHelper'; const exec = promisify(callbackExec); @@ -317,6 +318,7 @@ class Server extends AbstractServer { saml: false, logStreaming: false, advancedExecutionFilters: false, + versionControl: false, }, hideUsagePage: config.getEnv('hideUsagePage'), license: { @@ -347,6 +349,7 @@ class Server extends AbstractServer { ldap: isLdapEnabled(), saml: isSamlLicensed(), advancedExecutionFilters: isAdvancedExecutionFiltersEnabled(), + versionControl: isVersionControlEnabled(), }); if (isLdapEnabled()) { diff --git a/packages/cli/src/api/e2e.api.ts b/packages/cli/src/api/e2e.api.ts index 0de1f207bafbf..73adae880dbf9 100644 --- a/packages/cli/src/api/e2e.api.ts +++ b/packages/cli/src/api/e2e.api.ts @@ -29,6 +29,7 @@ const enabledFeatures = { [LICENSE_FEATURES.SAML]: false, [LICENSE_FEATURES.LOG_STREAMING]: false, [LICENSE_FEATURES.ADVANCED_EXECUTION_FILTERS]: false, + [LICENSE_FEATURES.VERSION_CONTROL]: false, }; type Feature = keyof typeof enabledFeatures; diff --git a/packages/cli/src/constants.ts b/packages/cli/src/constants.ts index 82f87dc13c048..260202bcf7fa5 100644 --- a/packages/cli/src/constants.ts +++ b/packages/cli/src/constants.ts @@ -74,6 +74,7 @@ export enum LICENSE_FEATURES { SAML = 'feat:saml', LOG_STREAMING = 'feat:logStreaming', ADVANCED_EXECUTION_FILTERS = 'feat:advancedExecutionFilters', + VERSION_CONTROL = 'feat:versionControl', } export const CREDENTIAL_BLANKING_VALUE = '__n8n_BLANK_VALUE_e5362baf-c777-4d57-a609-6eaf1f9e87f6'; diff --git a/packages/cli/src/environment/versionControl/versionControlHelper.ts b/packages/cli/src/environment/versionControl/versionControlHelper.ts new file mode 100644 index 0000000000000..295e24526afdd --- /dev/null +++ b/packages/cli/src/environment/versionControl/versionControlHelper.ts @@ -0,0 +1,7 @@ +import Container from 'typedi'; +import { License } from '../../License'; + +export function isVersionControlEnabled() { + const license = Container.get(License); + return license.isVersionControlEnabled(); +} diff --git a/packages/editor-ui/src/constants.ts b/packages/editor-ui/src/constants.ts index 1dd90ccbada3b..6d23c24098c48 100644 --- a/packages/editor-ui/src/constants.ts +++ b/packages/editor-ui/src/constants.ts @@ -458,6 +458,7 @@ export enum EnterpriseEditionFeature { Ldap = 'ldap', LogStreaming = 'logStreaming', Saml = 'saml', + VersionControl = 'versionControl', } export const MAIN_NODE_PANEL_WIDTH = 360;