From bbe493896ca2c721fec49db5b4c4b653b3dd124d Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Fri, 16 Jun 2023 10:30:57 +0300 Subject: [PATCH] fix: Remove Vue.component usage and refactor plugins into Vue Plugins (no-changelog) (#6445) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: remove Vue.component usage and refactor plugins into Vue Plugins system (no-changelog) * fix linting issues --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ --- packages/editor-ui/src/__tests__/setup.ts | 13 +- .../src/components/CredentialCard.vue | 2 + .../src/components/CredentialIcon.vue | 4 + .../editor-ui/src/components/NodeTitle.vue | 4 + .../editor-ui/src/components/TemplateCard.vue | 2 + .../editor-ui/src/components/VersionCard.vue | 7 +- .../editor-ui/src/components/WorkflowCard.vue | 2 + packages/editor-ui/src/main.ts | 15 +- packages/editor-ui/src/plugins/components.ts | 38 +-- packages/editor-ui/src/plugins/directives.ts | 11 +- packages/editor-ui/src/plugins/i18n/index.ts | 59 ++-- packages/editor-ui/src/plugins/icons/index.ts | 275 +++++++++--------- .../src/stores/communityNodes.store.ts | 1 - .../editor-ui/src/stores/credentials.store.ts | 1 - packages/editor-ui/src/stores/tags.store.ts | 1 - .../editor-ui/src/stores/workflows.store.ts | 1 - 16 files changed, 231 insertions(+), 205 deletions(-) diff --git a/packages/editor-ui/src/__tests__/setup.ts b/packages/editor-ui/src/__tests__/setup.ts index 28fef7c5d7..172da286a7 100644 --- a/packages/editor-ui/src/__tests__/setup.ts +++ b/packages/editor-ui/src/__tests__/setup.ts @@ -3,17 +3,26 @@ import { configure } from '@testing-library/vue'; import Vue from 'vue'; import '../plugins'; import { I18nPlugin } from '@/plugins/i18n'; +import { config } from '@vue/test-utils'; +import { GlobalComponentsPlugin } from '@/plugins/components'; +import { GlobalDirectivesPlugin } from '@/plugins/directives'; +import { FontAwesomePlugin } from '@/plugins/icons'; configure({ testIdAttribute: 'data-test-id' }); Vue.config.productionTip = false; Vue.config.devtools = false; +Vue.use(I18nPlugin); +Vue.use(FontAwesomePlugin); +Vue.use(GlobalComponentsPlugin); +Vue.use(GlobalDirectivesPlugin); + // TODO: Investigate why this is needed // Without having this 3rd party library imported like this, any component test using 'vue-json-pretty' fail with: // [Vue warn]: Failed to mount component: template or render function not defined. -Vue.component('vue-json-pretty', require('vue-json-pretty').default); -Vue.use((vue) => I18nPlugin(vue)); +// Vue.component('vue-json-pretty', require('vue-json-pretty').default); +config.stubs['vue-json-pretty'] = require('vue-json-pretty').default; window.ResizeObserver = window.ResizeObserver || diff --git a/packages/editor-ui/src/components/CredentialCard.vue b/packages/editor-ui/src/components/CredentialCard.vue index 3fdde8bd7a..338aef999e 100644 --- a/packages/editor-ui/src/components/CredentialCard.vue +++ b/packages/editor-ui/src/components/CredentialCard.vue @@ -44,6 +44,7 @@ import { mapStores } from 'pinia'; import { useUIStore } from '@/stores/ui.store'; import { useUsersStore } from '@/stores/users.store'; import { useCredentialsStore } from '@/stores/credentials.store'; +import TimeAgo from '@/components/TimeAgo.vue'; export const CREDENTIAL_LIST_ITEM_ACTIONS = { OPEN: 'open', @@ -62,6 +63,7 @@ export default defineComponent({ }; }, components: { + TimeAgo, CredentialIcon, }, props: { diff --git a/packages/editor-ui/src/components/CredentialIcon.vue b/packages/editor-ui/src/components/CredentialIcon.vue index a72744256c..b20750e924 100644 --- a/packages/editor-ui/src/components/CredentialIcon.vue +++ b/packages/editor-ui/src/components/CredentialIcon.vue @@ -14,8 +14,12 @@ import { useCredentialsStore } from '@/stores/credentials.store'; import { useRootStore } from '@/stores/n8nRoot.store'; import { useNodeTypesStore } from '@/stores/nodeTypes.store'; import type { ICredentialType, INodeTypeDescription } from 'n8n-workflow'; +import NodeIcon from '@/components/NodeIcon.vue'; export default defineComponent({ + components: { + NodeIcon, + }, props: { credentialTypeName: { type: String, diff --git a/packages/editor-ui/src/components/NodeTitle.vue b/packages/editor-ui/src/components/NodeTitle.vue index 87b9c352c6..7e344c115c 100644 --- a/packages/editor-ui/src/components/NodeTitle.vue +++ b/packages/editor-ui/src/components/NodeTitle.vue @@ -41,9 +41,13 @@