From 02b77367bdb14d5760678753ec1057bbfd90c0fb Mon Sep 17 00:00:00 2001 From: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:23:41 +0100 Subject: [PATCH] refactor: Clean up hooks and fake doors (no-changelog) (#11498) --- packages/editor-ui/src/Interface.ts | 20 ----- packages/editor-ui/src/__tests__/init.test.ts | 3 - .../CredentialEdit/CredentialEdit.vue | 7 +- .../src/components/FeatureComingSoon.vue | 82 ------------------- .../src/components/SettingsSidebar.vue | 34 +------- packages/editor-ui/src/constants.ts | 7 -- packages/editor-ui/src/hooks/cloud.ts | 13 --- packages/editor-ui/src/hooks/register.ts | 40 --------- packages/editor-ui/src/hooks/types.ts | 6 -- .../hooks/utils/hooksAddFakeDoorFeatures.ts | 34 -------- packages/editor-ui/src/hooks/utils/index.ts | 1 - packages/editor-ui/src/init.ts | 9 -- .../src/plugins/i18n/locales/en.json | 6 -- packages/editor-ui/src/router.ts | 19 ----- packages/editor-ui/src/stores/ui.store.ts | 34 -------- .../src/views/SettingsFakeDoorView.vue | 49 ----------- 16 files changed, 2 insertions(+), 362 deletions(-) delete mode 100644 packages/editor-ui/src/components/FeatureComingSoon.vue delete mode 100644 packages/editor-ui/src/hooks/cloud.ts delete mode 100644 packages/editor-ui/src/hooks/register.ts delete mode 100644 packages/editor-ui/src/hooks/types.ts delete mode 100644 packages/editor-ui/src/hooks/utils/hooksAddFakeDoorFeatures.ts delete mode 100644 packages/editor-ui/src/hooks/utils/index.ts delete mode 100644 packages/editor-ui/src/views/SettingsFakeDoorView.vue diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index e639f537df..b6691ac76b 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -52,7 +52,6 @@ import type { AI_NODE_CREATOR_VIEW, CREDENTIAL_EDIT_MODAL_KEY, SignInType, - FAKE_DOOR_FEATURES, TRIGGER_NODE_CREATOR_VIEW, REGULAR_NODE_CREATOR_VIEW, AI_OTHERS_NODE_CREATOR_VIEW, @@ -62,7 +61,6 @@ import type { BulkCommand, Undoable } from '@/models/history'; import type { PartialBy, TupleToUnion } from '@/utils/typeHelpers'; import type { ProjectSharingData } from '@/types/projects.types'; -import type { BaseTextKey } from './plugins/i18n'; export * from 'n8n-design-system/types'; @@ -1036,24 +1034,6 @@ export interface NotificationOptions extends Partial message: string | ElementNotificationOptions['message']; } -export type IFakeDoor = { - id: FAKE_DOOR_FEATURES; - featureName: BaseTextKey; - icon?: string; - infoText?: BaseTextKey; - actionBoxTitle: BaseTextKey; - actionBoxDescription: BaseTextKey; - actionBoxButtonLabel?: BaseTextKey; - linkURL: string; - uiLocations: IFakeDoorLocation[]; -}; - -export type IFakeDoorLocation = - | 'settings' - | 'settings/users' - | 'credentialsModal' - | 'workflowShareModal'; - export type NodeFilterType = | typeof REGULAR_NODE_CREATOR_VIEW | typeof TRIGGER_NODE_CREATOR_VIEW diff --git a/packages/editor-ui/src/__tests__/init.test.ts b/packages/editor-ui/src/__tests__/init.test.ts index f41e3abc52..d7b381e3f5 100644 --- a/packages/editor-ui/src/__tests__/init.test.ts +++ b/packages/editor-ui/src/__tests__/init.test.ts @@ -66,9 +66,6 @@ describe('Init', () => { vi.mocked(useRootStore).mockReturnValue({ defaultLocale: 'es' } as ReturnType< typeof useRootStore >); - vi.mock('@/hooks/register', () => ({ - initializeCloudHooks: vi.fn(), - })); }); afterEach(() => { diff --git a/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue b/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue index efbde8d1fb..c6d5ee07ec 100644 --- a/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue +++ b/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue @@ -22,7 +22,6 @@ import { NodeHelpers } from 'n8n-workflow'; import CredentialConfig from '@/components/CredentialEdit/CredentialConfig.vue'; import CredentialInfo from '@/components/CredentialEdit/CredentialInfo.vue'; import CredentialSharing from '@/components/CredentialEdit/CredentialSharing.ee.vue'; -import FeatureComingSoon from '@/components/FeatureComingSoon.vue'; import InlineNameEdit from '@/components/InlineNameEdit.vue'; import Modal from '@/components/Modal.vue'; import SaveButton from '@/components/SaveButton.vue'; @@ -518,14 +517,13 @@ async function loadCurrentCredential() { function onTabSelect(tab: string) { activeTab.value = tab; - const tabName: string = tab.replaceAll('coming-soon/', ''); const credType: string = credentialType.value ? credentialType.value.name : ''; const activeNode: INode | null = ndvStore.activeNode; telemetry.track('User viewed credential tab', { credential_type: credType, node_type: activeNode ? activeNode.type : null, - tab: tabName, + tab, workflow_id: workflowsStore.workflowId, credential_id: credentialId.value, sharing_enabled: EnterpriseEditionFeature.Sharing, @@ -1130,9 +1128,6 @@ function resetCredentialData(): void {
-
- -
diff --git a/packages/editor-ui/src/components/FeatureComingSoon.vue b/packages/editor-ui/src/components/FeatureComingSoon.vue deleted file mode 100644 index fd24a35196..0000000000 --- a/packages/editor-ui/src/components/FeatureComingSoon.vue +++ /dev/null @@ -1,82 +0,0 @@ - - - - - diff --git a/packages/editor-ui/src/components/SettingsSidebar.vue b/packages/editor-ui/src/components/SettingsSidebar.vue index 5409620e45..41a7de813e 100644 --- a/packages/editor-ui/src/components/SettingsSidebar.vue +++ b/packages/editor-ui/src/components/SettingsSidebar.vue @@ -2,9 +2,7 @@ import { computed } from 'vue'; import { ABOUT_MODAL_KEY, VIEWS } from '@/constants'; import { useUserHelpers } from '@/composables/useUserHelpers'; -import type { IFakeDoor } from '@/Interface'; import type { IMenuItem } from 'n8n-design-system'; -import type { BaseTextKey } from '@/plugins/i18n'; import { useUIStore } from '@/stores/ui.store'; import { useSettingsStore } from '@/stores/settings.store'; import { useRootStore } from '@/stores/root.store'; @@ -26,23 +24,6 @@ const rootStore = useRootStore(); const settingsStore = useSettingsStore(); const uiStore = useUIStore(); -const settingsFakeDoorFeatures = computed(() => - Object.keys(uiStore.fakeDoorsByLocation) - .filter((location: string) => location.includes('settings')) - .map((location) => uiStore.fakeDoorsByLocation[location]), -); - -const handleSelect = (key: string) => { - switch (key) { - case 'users': // Fakedoor feature added via hooks when user management is disabled on cloud - case 'logging': - router.push({ name: VIEWS.FAKE_DOOR, params: { featureId: key } }).catch(() => {}); - break; - default: - break; - } -}; - const sidebarMenuItems = computed(() => { const menuItems: IMenuItem[] = [ { @@ -122,19 +103,6 @@ const sidebarMenuItems = computed(() => { }, ]; - for (const item of settingsFakeDoorFeatures.value) { - if (item.uiLocations.includes('settings')) { - menuItems.push({ - id: item.id, - icon: item.icon ?? 'question', - label: i18n.baseText(item.featureName as BaseTextKey), - position: 'top', - available: true, - activateOnRoutePaths: [`/settings/coming-soon/${item.id}`], - }); - } - } - menuItems.push({ id: 'settings-log-streaming', icon: 'sign-in-alt', @@ -159,7 +127,7 @@ const sidebarMenuItems = computed(() => {