From beea77229c8ee307aeab92a2bcb4b18e01b3c75f Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Fri, 21 Jul 2023 12:03:40 +0300 Subject: [PATCH] fix: remove import cycle. --- .../components/__tests__/PersonalizationModal.spec.ts | 6 +++--- packages/editor-ui/src/mixins/workflowHelpers.ts | 4 ++-- packages/editor-ui/src/stores/n8nRoot.store.ts | 10 ---------- packages/editor-ui/src/stores/nodeTypes.store.ts | 9 +++++++++ packages/editor-ui/src/views/NodeView.vue | 2 +- packages/editor-ui/vite.config.ts | 4 ++-- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/packages/editor-ui/src/components/__tests__/PersonalizationModal.spec.ts b/packages/editor-ui/src/components/__tests__/PersonalizationModal.spec.ts index ffb61c9483..1161202945 100644 --- a/packages/editor-ui/src/components/__tests__/PersonalizationModal.spec.ts +++ b/packages/editor-ui/src/components/__tests__/PersonalizationModal.spec.ts @@ -1,6 +1,6 @@ import PersonalizationModal from '@/components/PersonalizationModal.vue'; import { createTestingPinia } from '@pinia/testing'; -import { PERSONALIZATION_MODAL_KEY } from '@/constants'; +import { PERSONALIZATION_MODAL_KEY, STORES } from '@/constants'; import { retry } from '@/__tests__/utils'; import { createComponentRenderer } from '@/__tests__/render'; import { fireEvent } from '@testing-library/vue'; @@ -8,12 +8,12 @@ import { fireEvent } from '@testing-library/vue'; const renderComponent = createComponentRenderer(PersonalizationModal, { pinia: createTestingPinia({ initialState: { - ui: { + [STORES.UI]: { modals: { [PERSONALIZATION_MODAL_KEY]: { open: true }, }, }, - settings: { + [STORES.SETTINGS]: { settings: { templates: { host: '', diff --git a/packages/editor-ui/src/mixins/workflowHelpers.ts b/packages/editor-ui/src/mixins/workflowHelpers.ts index ecfa9b259f..750c8fb039 100644 --- a/packages/editor-ui/src/mixins/workflowHelpers.ts +++ b/packages/editor-ui/src/mixins/workflowHelpers.ts @@ -58,11 +58,11 @@ import { useNDVStore } from '@/stores/ndv.store'; import { useTemplatesStore } from '@/stores/templates.store'; import { useNodeTypesStore } from '@/stores/nodeTypes.store'; import { useWorkflowsEEStore } from '@/stores/workflows.ee.store'; +import { useEnvironmentsStore } from '@/stores/environments.ee.store'; import { useUsersStore } from '@/stores/users.store'; -import type { IPermissions } from '@/permissions'; import { getWorkflowPermissions } from '@/permissions'; +import type { IPermissions } from '@/permissions'; import type { ICredentialsResponse } from '@/Interface'; -import { useEnvironmentsStore } from '@/stores'; export function resolveParameter( parameter: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[], diff --git a/packages/editor-ui/src/stores/n8nRoot.store.ts b/packages/editor-ui/src/stores/n8nRoot.store.ts index 1043040a66..3e688cf6f3 100644 --- a/packages/editor-ui/src/stores/n8nRoot.store.ts +++ b/packages/editor-ui/src/stores/n8nRoot.store.ts @@ -2,7 +2,6 @@ import { CLOUD_BASE_URL_PRODUCTION, CLOUD_BASE_URL_STAGING, STORES } from '@/con import type { IRestApiContext, RootState } from '@/Interface'; import type { IDataObject } from 'n8n-workflow'; import { defineStore } from 'pinia'; -import { useNodeTypesStore } from './nodeTypes.store'; const { VUE_APP_URL_BASE_API } = import.meta.env; @@ -62,15 +61,6 @@ export const useRootStore = defineStore(STORES.ROOT, { sessionId: this.sessionId, }; }, - /** - * Getter for node default names ending with a number: `'S3'`, `'Magento 2'`, etc. - */ - nativelyNumberSuffixedDefaults: (): string[] => { - return useNodeTypesStore().allNodeTypes.reduce((acc, cur) => { - if (/\d$/.test(cur.defaults.name as string)) acc.push(cur.defaults.name as string); - return acc; - }, []); - }, }, actions: { setUrlBaseWebhook(urlBaseWebhook: string): void { diff --git a/packages/editor-ui/src/stores/nodeTypes.store.ts b/packages/editor-ui/src/stores/nodeTypes.store.ts index d740cb06ca..5b91796f44 100644 --- a/packages/editor-ui/src/stores/nodeTypes.store.ts +++ b/packages/editor-ui/src/stores/nodeTypes.store.ts @@ -87,6 +87,15 @@ export const useNodeTypesStore = defineStore(STORES.NODE_TYPES, { visibleNodeTypes(): INodeTypeDescription[] { return this.allLatestNodeTypes.filter((nodeType: INodeTypeDescription) => !nodeType.hidden); }, + /** + * Getter for node default names ending with a number: `'S3'`, `'Magento 2'`, etc. + */ + nativelyNumberSuffixedDefaults(): string[] { + return this.allNodeTypes.reduce((acc, cur) => { + if (/\d$/.test(cur.defaults.name as string)) acc.push(cur.defaults.name as string); + return acc; + }, []); + }, }, actions: { setNodeTypes(newNodeTypes: INodeTypeDescription[] = []): void { diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index d1678f8d58..e32cf73e16 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -496,7 +496,7 @@ export default defineComponent({ useHistoryStore, ), nativelyNumberSuffixedDefaults(): string[] { - return this.rootStore.nativelyNumberSuffixedDefaults; + return this.nodeTypesStore.nativelyNumberSuffixedDefaults; }, currentUser(): IUser | null { return this.usersStore.currentUser; diff --git a/packages/editor-ui/vite.config.ts b/packages/editor-ui/vite.config.ts index 7521e01201..c65b9ea522 100644 --- a/packages/editor-ui/vite.config.ts +++ b/packages/editor-ui/vite.config.ts @@ -121,10 +121,10 @@ export default mergeConfig( include: [ // 'src/components/__tests__/SQLEditor.test.ts', // 'src/components/__tests__/BannersStack.test.ts', - 'src/components/__tests__/ExecutionFilter.test.ts', + // 'src/components/__tests__/ExecutionFilter.test.ts', // 'src/components/__tests__/ExecutionsList.test.ts', // 'src/components/__tests__/MainSidebarSourceControl.test.ts', - // 'src/components/__tests__/PersonalizationModal.spec.ts', + 'src/components/__tests__/PersonalizationModal.spec.ts', // 'src/components/__tests__/ResourceMapper.test.ts', // 'src/components/__tests__/RunData.test.ts', // 'src/components/__tests__/RunDataJson.test.ts',