refactor: Fix Enteprise type errors (#9442)

This commit is contained in:
Mutasem Aldmour 2024-05-17 13:58:26 +02:00 committed by GitHub
parent feba07ba8b
commit b2c17034c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 75 additions and 39 deletions

View file

@ -1925,3 +1925,20 @@ export type NewConnectionInfo = {
export type AIAssistantConnectionInfo = NewConnectionInfo & {
stepName: string;
};
export type EnterpriseEditionFeatureKey =
| 'AdvancedExecutionFilters'
| 'Sharing'
| 'Ldap'
| 'LogStreaming'
| 'Variables'
| 'Saml'
| 'SourceControl'
| 'ExternalSecrets'
| 'AuditLogs'
| 'DebugInEditor'
| 'WorkflowHistory'
| 'WorkerView'
| 'AdvancedPermissions';
export type EnterpriseEditionFeatureValue = keyof Omit<IN8nUISettings['enterprise'], 'projects'>;

View file

@ -68,6 +68,11 @@ export const defaultSettings: IN8nUISettings = {
externalSecrets: false,
workerView: false,
advancedPermissions: false,
projects: {
team: {
limit: 1,
},
},
},
expressions: {
evaluator: 'tournament',

View file

@ -9,11 +9,16 @@ import {
getNodeAuthOptions,
isAuthRelatedParameter,
} from '@/utils/nodeTypesUtils';
import type { INodeProperties, INodeTypeDescription, NodeParameterValue } from 'n8n-workflow';
import type {
ICredentialType,
INodeProperties,
INodeTypeDescription,
NodeParameterValue,
} from 'n8n-workflow';
import { computed, onMounted, ref } from 'vue';
export interface Props {
credentialType: object;
credentialType: ICredentialType;
}
const emit = defineEmits<{

View file

@ -142,7 +142,7 @@ import { defineComponent } from 'vue';
import type { PropType } from 'vue';
import { mapStores } from 'pinia';
import type { ICredentialType, INodeTypeDescription } from 'n8n-workflow';
import type { ICredentialType, INodeProperties, INodeTypeDescription } from 'n8n-workflow';
import { getAppNameFromCredType, isCommunityPackageName } from '@/utils/nodeTypesUtils';
import Banner from '../Banner.vue';
@ -177,13 +177,15 @@ export default defineComponent({
},
props: {
credentialType: {
type: Object,
type: Object as PropType<ICredentialType>,
required: true,
},
credentialProperties: {
type: Array,
type: Array as PropType<INodeProperties[]>,
required: true,
},
parentTypes: {
type: Array,
type: Array as PropType<string[]>,
},
credentialData: {},
credentialId: {

View file

@ -60,7 +60,11 @@
@select="onTabSelect"
></n8n-menu>
</div>
<div v-if="activeTab === 'connection'" ref="content" :class="$style.mainContent">
<div
v-if="activeTab === 'connection' && credentialType"
ref="content"
:class="$style.mainContent"
>
<CredentialConfig
:credential-type="credentialType"
:credential-properties="credentialProperties"

View file

@ -6,8 +6,8 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import type { EnterpriseEditionFeature } from '@/constants';
import { type PropType, defineComponent } from 'vue';
import type { EnterpriseEditionFeatureValue } from '@/Interface';
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/settings.store';
@ -15,18 +15,15 @@ export default defineComponent({
name: 'EnterpriseEdition',
props: {
features: {
type: Array,
default: () => [] as EnterpriseEditionFeature[],
type: Array as PropType<EnterpriseEditionFeatureValue[]>,
default: () => [],
},
},
computed: {
...mapStores(useSettingsStore),
canAccess(): boolean {
return this.features.reduce((acc: boolean, feature) => {
return (
acc &&
!!this.settingsStore.isEnterpriseFeatureEnabled(feature as EnterpriseEditionFeature)
);
return acc && !!this.settingsStore.isEnterpriseFeatureEnabled(feature);
}, true);
},
},

View file

@ -1,4 +1,8 @@
import type { NodeCreatorOpenSource } from './Interface';
import type {
EnterpriseEditionFeatureKey,
EnterpriseEditionFeatureValue,
NodeCreatorOpenSource,
} from './Interface';
import { NodeConnectionType } from 'n8n-workflow';
export const MAX_WORKFLOW_SIZE = 1024 * 1024 * 16; // Workflow size limit in bytes
@ -541,21 +545,25 @@ export const enum WORKFLOW_MENU_ACTIONS {
/**
* Enterprise edition
*/
export const enum EnterpriseEditionFeature {
AdvancedExecutionFilters = 'advancedExecutionFilters',
Sharing = 'sharing',
Ldap = 'ldap',
LogStreaming = 'logStreaming',
Variables = 'variables',
Saml = 'saml',
SourceControl = 'sourceControl',
ExternalSecrets = 'externalSecrets',
AuditLogs = 'auditLogs',
DebugInEditor = 'debugInEditor',
WorkflowHistory = 'workflowHistory',
WorkerView = 'workerView',
AdvancedPermissions = 'advancedPermissions',
}
export const EnterpriseEditionFeature: Record<
EnterpriseEditionFeatureKey,
EnterpriseEditionFeatureValue
> = {
AdvancedExecutionFilters: 'advancedExecutionFilters',
Sharing: 'sharing',
Ldap: 'ldap',
LogStreaming: 'logStreaming',
Variables: 'variables',
Saml: 'saml',
SourceControl: 'sourceControl',
ExternalSecrets: 'externalSecrets',
AuditLogs: 'auditLogs',
DebugInEditor: 'debugInEditor',
WorkflowHistory: 'workflowHistory',
WorkerView: 'workerView',
AdvancedPermissions: 'advancedPermissions',
};
export const MAIN_NODE_PANEL_WIDTH = 360;
export const enum MAIN_HEADER_TABS {

View file

@ -8,7 +8,7 @@ import {
} from '@/api/ldap';
import { getPromptsData, getSettings, submitContactInfo, submitValueSurvey } from '@/api/settings';
import { testHealthEndpoint } from '@/api/templates';
import type { EnterpriseEditionFeature } from '@/constants';
import type { EnterpriseEditionFeatureValue } from '@/Interface';
import {
CONTACT_PROMPT_MODAL_KEY,
STORES,
@ -79,7 +79,8 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
}),
getters: {
isEnterpriseFeatureEnabled() {
return (feature: EnterpriseEditionFeature): boolean => this.settings.enterprise?.[feature];
return (feature: EnterpriseEditionFeatureValue): boolean =>
Boolean(this.settings.enterprise?.[feature]);
},
versionCli(): string {
return this.settings.versionCli;

View file

@ -1,6 +1,5 @@
import type { EnterpriseEditionFeature } from '@/constants';
import type { Resource, ScopeOptions, Scope } from '@n8n/permissions';
import type { IRole } from '@/Interface';
import type { EnterpriseEditionFeatureValue, IRole } from '@/Interface';
export type AuthenticatedPermissionOptions = {
bypass?: () => boolean;
@ -9,7 +8,7 @@ export type CustomPermissionOptions<C = {}> = RBACPermissionCheck<C>;
export type DefaultUserMiddlewareOptions = {};
export type InstanceOwnerMiddlewareOptions = {};
export type EnterprisePermissionOptions = {
feature?: EnterpriseEditionFeature | EnterpriseEditionFeature[];
feature?: EnterpriseEditionFeatureValue | EnterpriseEditionFeatureValue[];
mode?: 'oneOf' | 'allOf';
};
export type GuestPermissionOptions = {};

View file

@ -5,8 +5,6 @@ import type {
INodeProperties,
INodeTypeDescription,
NodeParameterValueType,
INodePropertyOptions,
INodePropertyCollection,
ResourceMapperField,
} from 'n8n-workflow';
import {
@ -271,7 +269,7 @@ export const getNodeCredentialForSelectedAuthType = (
export const getAuthTypeForNodeCredential = (
nodeType: INodeTypeDescription | null | undefined,
credentialType: INodeCredentialDescription | null | undefined,
): INodePropertyOptions | INodeProperties | INodePropertyCollection | null => {
): NodeAuthenticationOption | null => {
if (nodeType && credentialType) {
const authField = getMainAuthField(nodeType);
const authFieldName = authField ? authField.name : '';