Skip to content
/ qp-n8n Public
forked from n8n-io/n8n

Commit

Permalink
refactor(editor): Consolidate IN8nUISettings interface (n8n-io#6055)
Browse files Browse the repository at this point in the history
* consolidate IN8nUISettings

* cleanup
  • Loading branch information
flipswitchingmonkey authored and sunilrr committed Apr 24, 2023
1 parent e6e2655 commit f8892d1
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 214 deletions.
101 changes: 0 additions & 101 deletions packages/cli/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type {
IRunData,
IRunExecutionData,
ITaskData,
ITelemetrySettings,
ITelemetryTrackProperties,
IWorkflowBase,
CredentialLoadingDetails,
Expand All @@ -23,8 +22,6 @@ import type {
ExecutionStatus,
IExecutionsSummary,
FeatureFlags,
WorkflowSettings,
AuthenticationMethod,
} from 'n8n-workflow';

import type { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
Expand Down Expand Up @@ -469,90 +466,6 @@ export interface IVersionNotificationSettings {
infoUrl: string;
}

export interface IN8nUISettings {
endpointWebhook: string;
endpointWebhookTest: string;
saveDataErrorExecution: WorkflowSettings.SaveDataExecution;
saveDataSuccessExecution: WorkflowSettings.SaveDataExecution;
saveManualExecutions: boolean;
executionTimeout: number;
maxExecutionTimeout: number;
workflowCallerPolicyDefaultOption: WorkflowSettings.CallerPolicy;
oauthCallbackUrls: {
oauth1: string;
oauth2: string;
};
timezone: string;
urlBaseWebhook: string;
urlBaseEditor: string;
versionCli: string;
n8nMetadata?: {
[key: string]: string | number | undefined;
};
versionNotifications: IVersionNotificationSettings;
instanceId: string;
telemetry: ITelemetrySettings;
posthog: {
enabled: boolean;
apiHost: string;
apiKey: string;
autocapture: boolean;
disableSessionRecording: boolean;
debug: boolean;
};
personalizationSurveyEnabled: boolean;
userActivationSurveyEnabled: boolean;
defaultLocale: string;
userManagement: IUserManagementSettings;
sso: {
saml: {
loginLabel: string;
loginEnabled: boolean;
};
ldap: {
loginLabel: string;
loginEnabled: boolean;
};
};
publicApi: IPublicApiSettings;
workflowTagsDisabled: boolean;
logLevel: 'info' | 'debug' | 'warn' | 'error' | 'verbose' | 'silent';
hiringBannerEnabled: boolean;
templates: {
enabled: boolean;
host: string;
};
onboardingCallPromptEnabled: boolean;
missingPackages?: boolean;
executionMode: 'regular' | 'queue';
pushBackend: 'sse' | 'websocket';
communityNodesEnabled: boolean;
deployment: {
type: string;
};
isNpmAvailable: boolean;
allowedModules: {
builtIn?: string;
external?: string;
};
enterprise: {
sharing: boolean;
ldap: boolean;
saml: boolean;
logStreaming: boolean;
advancedExecutionFilters: boolean;
variables: boolean;
versionControl: boolean;
};
hideUsagePage: boolean;
license: {
environment: 'production' | 'staging';
};
variables: {
limit: number;
};
}

export interface IPersonalizationSurveyAnswers {
email: string | null;
codingSkill: string | null;
Expand All @@ -570,23 +483,9 @@ export interface IUserSettings {
userActivated?: boolean;
}

export interface IUserManagementSettings {
enabled: boolean;
showSetupOnFirstLoad?: boolean;
smtpSetup: boolean;
authenticationMethod: AuthenticationMethod;
}
export interface IActiveDirectorySettings {
enabled: boolean;
}
export interface IPublicApiSettings {
enabled: boolean;
latestVersion: number;
path: string;
swaggerUi: {
enabled: boolean;
};
}

export interface IPackageVersions {
cli: string;
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import type {
ICredentialTypes,
ExecutionStatus,
IExecutionsSummary,
IN8nUISettings,
} from 'n8n-workflow';
import { LoggerProxy, jsonParse } from 'n8n-workflow';

Expand Down Expand Up @@ -112,7 +113,6 @@ import type {
IDiagnosticInfo,
IExecutionFlattedDb,
IExecutionsStopData,
IN8nUISettings,
} from '@/Interfaces';
import { ActiveExecutions } from '@/ActiveExecutions';
import {
Expand Down Expand Up @@ -313,8 +313,8 @@ class Server extends AbstractServer {
},
isNpmAvailable: false,
allowedModules: {
builtIn: process.env.NODE_FUNCTION_ALLOW_BUILTIN,
external: process.env.NODE_FUNCTION_ALLOW_EXTERNAL,
builtIn: process.env.NODE_FUNCTION_ALLOW_BUILTIN?.split(',') ?? undefined,
external: process.env.NODE_FUNCTION_ALLOW_EXTERNAL?.split(',') ?? undefined,
},
enterprise: {
sharing: false,
Expand Down
100 changes: 6 additions & 94 deletions packages/editor-ui/src/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
IRun,
IRunData,
ITaskData,
ITelemetrySettings,
IWorkflowSettings as IWorkflowSettingsWorkflow,
WorkflowExecuteMode,
PublicInstalledPackage,
Expand All @@ -33,6 +32,9 @@ import {
FeatureFlags,
ExecutionStatus,
ITelemetryTrackProperties,
IN8nUISettings,
IUserManagementSettings,
WorkflowSettings,
} from 'n8n-workflow';
import { SignInType } from './constants';
import { FAKE_DOOR_FEATURES, TRIGGER_NODE_FILTER, REGULAR_NODE_FILTER } from './constants';
Expand Down Expand Up @@ -641,13 +643,6 @@ export const enum UserManagementAuthenticationMethod {
Saml = 'saml',
}

export interface IUserManagementConfig {
enabled: boolean;
showSetupOnFirstLoad?: boolean;
smtpSetup: boolean;
authenticationMethod: UserManagementAuthenticationMethod;
}

export interface IPermissionGroup {
loginStatus?: ILogInStatus[];
role?: IRole[];
Expand Down Expand Up @@ -732,94 +727,14 @@ export interface ITemplatesCategory {

export type WorkflowCallerPolicyDefaultOption = 'any' | 'none' | 'workflowsFromAList';

export interface IN8nUISettings {
endpointWebhook: string;
endpointWebhookTest: string;
saveDataErrorExecution: string;
saveDataSuccessExecution: string;
saveManualExecutions: boolean;
workflowCallerPolicyDefaultOption: WorkflowCallerPolicyDefaultOption;
timezone: string;
executionTimeout: number;
maxExecutionTimeout: number;
oauthCallbackUrls: {
oauth1: string;
oauth2: string;
};
urlBaseEditor: string;
urlBaseWebhook: string;
versionCli: string;
n8nMetadata?: {
[key: string]: string | number | undefined;
};
versionNotifications: IVersionNotificationSettings;
instanceId: string;
personalizationSurveyEnabled: boolean;
userActivationSurveyEnabled: boolean;
telemetry: ITelemetrySettings;
userManagement: IUserManagementConfig;
defaultLocale: string;
workflowTagsDisabled: boolean;
logLevel: ILogLevel;
hiringBannerEnabled: boolean;
templates: {
enabled: boolean;
host: string;
};
posthog: {
enabled: boolean;
apiHost: string;
apiKey: string;
autocapture: boolean;
disableSessionRecording: boolean;
debug: boolean;
};
executionMode: string;
pushBackend: 'sse' | 'websocket';
communityNodesEnabled: boolean;
isNpmAvailable: boolean;
publicApi: {
enabled: boolean;
latestVersion: number;
path: string;
swaggerUi: {
enabled: boolean;
};
};
sso: {
saml: {
loginLabel: string;
loginEnabled: boolean;
};
ldap: {
loginLabel: string;
loginEnabled: boolean;
};
};
onboardingCallPromptEnabled: boolean;
allowedModules: {
builtIn?: string[];
external?: string[];
};
enterprise: Record<string, boolean>;
deployment?: {
type: string | 'default' | 'n8n-internal' | 'cloud' | 'desktop_mac' | 'desktop_win';
};
hideUsagePage: boolean;
license: {
environment: 'development' | 'production';
};
}

export interface IWorkflowSettings extends IWorkflowSettingsWorkflow {
errorWorkflow?: string;
saveDataErrorExecution?: string;
saveDataSuccessExecution?: string;
saveManualExecutions?: boolean;
timezone?: string;
executionTimeout?: number;
maxExecutionTimeout?: number;
callerIds?: string;
callerPolicy?: WorkflowCallerPolicyDefaultOption;
callerPolicy?: WorkflowSettings.CallerPolicy;
}

export interface ITimeoutHMS {
Expand Down Expand Up @@ -1177,9 +1092,6 @@ export interface UIState {
addFirstStepOnLoad: boolean;
executionSidebarAutoRefresh: boolean;
}

export type ILogLevel = 'info' | 'debug' | 'warn' | 'error' | 'verbose';

export type IFakeDoor = {
id: FAKE_DOOR_FEATURES;
featureName: string;
Expand Down Expand Up @@ -1221,7 +1133,7 @@ export interface INodeCreatorState {
export interface ISettingsState {
settings: IN8nUISettings;
promptsData: IN8nPrompts;
userManagement: IUserManagementConfig;
userManagement: IUserManagementSettings;
templatesEndpointHealthy: boolean;
api: {
enabled: boolean;
Expand Down
22 changes: 18 additions & 4 deletions packages/editor-ui/src/__tests__/server/endpoints/settings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Response, Server } from 'miragejs';
import { AppSchema } from '../types';
import { IN8nUISettings, ISettingsState } from '@/Interface';
import { IN8nUISettings } from 'n8n-workflow';

const defaultSettings: IN8nUISettings = {
allowedModules: {},
Expand All @@ -9,9 +9,15 @@ const defaultSettings: IN8nUISettings = {
endpointWebhook: '',
endpointWebhookTest: '',
enterprise: {
sharing: false,
ldap: false,
saml: false,
logStreaming: false,
advancedExecutionFilters: false,
variables: true,
versionControl: false,
},
executionMode: '',
executionMode: 'regular',
executionTimeout: 0,
hideUsagePage: false,
hiringBannerEnabled: false,
Expand All @@ -33,8 +39,8 @@ const defaultSettings: IN8nUISettings = {
},
publicApi: { enabled: false, latestVersion: 0, path: '', swaggerUi: { enabled: false } },
pushBackend: 'websocket',
saveDataErrorExecution: '',
saveDataSuccessExecution: '',
saveDataErrorExecution: 'DEFAULT',
saveDataSuccessExecution: 'DEFAULT',
saveManualExecutions: false,
sso: {
ldap: { loginEnabled: false, loginLabel: '' },
Expand All @@ -51,6 +57,7 @@ const defaultSettings: IN8nUISettings = {
enabled: true,
showSetupOnFirstLoad: true,
smtpSetup: true,
authenticationMethod: 'email',
},
versionCli: '',
versionNotifications: {
Expand All @@ -60,6 +67,13 @@ const defaultSettings: IN8nUISettings = {
},
workflowCallerPolicyDefaultOption: 'any',
workflowTagsDisabled: false,
variables: {
limit: -1,
},
userActivationSurveyEnabled: false,
deployment: {
type: 'default',
},
};

export function routesForSettings(server: Server) {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import {
IRestApiContext,
IN8nPrompts,
IN8nValueSurveyData,
IN8nUISettings,
IN8nPromptResponse,
} from '../Interface';
import { makeRestApiRequest, get, post } from '@/utils';
import { N8N_IO_BASE_URL, NPM_COMMUNITY_NODE_SEARCH_API_URL } from '@/constants';
import { IN8nUISettings } from 'n8n-workflow';

export function getSettings(context: IRestApiContext): Promise<IN8nUISettings> {
return makeRestApiRequest(context, 'GET', '/settings');
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-ui/src/components/WorkflowSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ import {
import mixins from 'vue-typed-mixins';
import { deepCopy } from 'n8n-workflow';
import { WorkflowSettings, deepCopy } from 'n8n-workflow';
import { mapStores } from 'pinia';
import { useWorkflowsStore } from '@/stores/workflows';
import { useSettingsStore } from '@/stores/settings';
Expand Down Expand Up @@ -504,7 +504,7 @@ export default mixins(externalHooks, genericHelpers, restApi, showMessage).exten
}
if (workflowSettings.callerPolicy === undefined) {
workflowSettings.callerPolicy = this.defaultValues
.workflowCallerPolicy as WorkflowCallerPolicyDefaultOption;
.workflowCallerPolicy as WorkflowSettings.CallerPolicy;
}
if (workflowSettings.executionTimeout === undefined) {
workflowSettings.executionTimeout = this.rootStore.executionTimeout;
Expand Down
Loading

0 comments on commit f8892d1

Please sign in to comment.