diff --git a/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue b/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue index 1c2242195c713..e54f247cea88b 100644 --- a/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue +++ b/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue @@ -1,6 +1,7 @@ diff --git a/packages/editor-ui/src/components/InviteUsersModal.vue b/packages/editor-ui/src/components/InviteUsersModal.vue index aa698371e62fb..e43fc7ab4a6f5 100644 --- a/packages/editor-ui/src/components/InviteUsersModal.vue +++ b/packages/editor-ui/src/components/InviteUsersModal.vue @@ -15,6 +15,7 @@ import { useSettingsStore } from '@/stores/settings.store'; import { useUIStore } from '@/stores/ui.store'; import { createFormEventBus, createEventBus } from 'n8n-design-system/utils'; import { useClipboard } from '@/composables/useClipboard'; +import { usePageRedirectionHelper } from '@/composables/usePageRedirectionHelper'; const NAME_EMAIL_FORMAT_REGEX = /^.* <(.*)>$/; @@ -43,6 +44,7 @@ export default defineComponent({ return { clipboard, ...useToast(), + ...usePageRedirectionHelper(), }; }, data() { @@ -277,7 +279,7 @@ export default defineComponent({ } }, goToUpgradeAdvancedPermissions() { - void this.uiStore.goToUpgrade('advanced-permissions', 'upgrade-advanced-permissions'); + void this.goToUpgrade('advanced-permissions', 'upgrade-advanced-permissions'); }, }, }); diff --git a/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue b/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue index 33a830af92440..e13f47b3ebdc4 100644 --- a/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue +++ b/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue @@ -56,6 +56,7 @@ import { useTelemetry } from '@/composables/useTelemetry'; import type { BaseTextKey } from '@/plugins/i18n'; import { useNpsSurveyStore } from '@/stores/npsSurvey.store'; import { useNodeViewVersionSwitcher } from '@/composables/useNodeViewVersionSwitcher'; +import { usePageRedirectionHelper } from '@/composables/usePageRedirectionHelper'; const props = defineProps<{ readOnly?: boolean; @@ -89,6 +90,7 @@ const message = useMessage(); const toast = useToast(); const documentTitle = useDocumentTitle(); const workflowHelpers = useWorkflowHelpers({ router }); +const pageRedirectionHelper = usePageRedirectionHelper(); const isTagsEditEnabled = ref(false); const isNameEditEnabled = ref(false); @@ -584,11 +586,11 @@ async function onWorkflowMenuSelect(action: WORKFLOW_MENU_ACTIONS): Promise { break; } case 'cloud-admin': { - void cloudPlanStore.redirectToDashboard(); + void pageRedirectionHelper.goToDashboard(); break; } case 'quickstart': diff --git a/packages/editor-ui/src/components/Projects/ProjectNavigation.test.ts b/packages/editor-ui/src/components/Projects/ProjectNavigation.test.ts index d6a760b1d9240..6b20301d66bc2 100644 --- a/packages/editor-ui/src/components/Projects/ProjectNavigation.test.ts +++ b/packages/editor-ui/src/components/Projects/ProjectNavigation.test.ts @@ -5,11 +5,11 @@ import { createRouter, createMemoryHistory, useRouter } from 'vue-router'; import { createProjectListItem } from '@/__tests__/data/projects'; import ProjectsNavigation from '@/components/Projects//ProjectNavigation.vue'; import { useProjectsStore } from '@/stores/projects.store'; -import { useUIStore } from '@/stores/ui.store'; import { mockedStore } from '@/__tests__/utils'; import type { Project } from '@/types/projects.types'; import { VIEWS } from '@/constants'; import { useToast } from '@/composables/useToast'; +import { usePageRedirectionHelper } from '@/composables/usePageRedirectionHelper'; vi.mock('vue-router', async () => { const actual = await vi.importActual('vue-router'); @@ -36,6 +36,15 @@ vi.mock('@/composables/useToast', () => { }; }); +vi.mock('@/composables/usePageRedirectionHelper', () => { + const goToUpgrade = vi.fn(); + return { + usePageRedirectionHelper: () => ({ + goToUpgrade, + }), + }; +}); + const renderComponent = createComponentRenderer(ProjectsNavigation, { global: { plugins: [ @@ -56,7 +65,7 @@ const renderComponent = createComponentRenderer(ProjectsNavigation, { let router: ReturnType; let toast: ReturnType; let projectsStore: ReturnType>; -let uiStore: ReturnType>; +let pageRedirectionHelper: ReturnType; const personalProjects = Array.from({ length: 3 }, createProjectListItem); const teamProjects = Array.from({ length: 3 }, () => createProjectListItem('team')); @@ -67,9 +76,9 @@ describe('ProjectsNavigation', () => { router = useRouter(); toast = useToast(); + pageRedirectionHelper = usePageRedirectionHelper(); projectsStore = mockedStore(useProjectsStore); - uiStore = mockedStore(useUIStore); }); it('should not throw an error', () => { @@ -144,7 +153,7 @@ describe('ProjectsNavigation', () => { expect(getByText(/You have reached the Free plan limit of 3/)).toBeVisible(); await userEvent.click(getByText('View plans')); - expect(uiStore.goToUpgrade).toHaveBeenCalledWith('rbac', 'upgrade-rbac'); + expect(pageRedirectionHelper.goToUpgrade).toHaveBeenCalledWith('rbac', 'upgrade-rbac'); }); it('should show "Projects" title and Personal project when the feature is enabled', async () => { diff --git a/packages/editor-ui/src/components/Projects/ProjectNavigation.vue b/packages/editor-ui/src/components/Projects/ProjectNavigation.vue index aa4fa6ab7c6dc..47513ea1d6b64 100644 --- a/packages/editor-ui/src/components/Projects/ProjectNavigation.vue +++ b/packages/editor-ui/src/components/Projects/ProjectNavigation.vue @@ -7,8 +7,8 @@ import { VIEWS } from '@/constants'; import { useProjectsStore } from '@/stores/projects.store'; import type { ProjectListItem } from '@/types/projects.types'; import { useToast } from '@/composables/useToast'; -import { useUIStore } from '@/stores/ui.store'; import { sortByProperty } from '@/utils/sortUtils'; +import { usePageRedirectionHelper } from '@/composables/usePageRedirectionHelper'; type Props = { collapsed: boolean; @@ -21,7 +21,7 @@ const router = useRouter(); const locale = useI18n(); const toast = useToast(); const projectsStore = useProjectsStore(); -const uiStore = useUIStore(); +const pageRedirectionHelper = usePageRedirectionHelper(); const isCreatingProject = ref(false); const isComponentMounted = ref(false); @@ -99,7 +99,7 @@ const canCreateProjects = computed( ); const goToUpgrade = async () => { - await uiStore.goToUpgrade('rbac', 'upgrade-rbac'); + await pageRedirectionHelper.goToUpgrade('rbac', 'upgrade-rbac'); }; onMounted(async () => { diff --git a/packages/editor-ui/src/components/Projects/ProjectRoleUpgradeDialog.vue b/packages/editor-ui/src/components/Projects/ProjectRoleUpgradeDialog.vue index 6a125181eb23a..4176c2e0c0ca5 100644 --- a/packages/editor-ui/src/components/Projects/ProjectRoleUpgradeDialog.vue +++ b/packages/editor-ui/src/components/Projects/ProjectRoleUpgradeDialog.vue @@ -1,6 +1,6 @@ diff --git a/packages/editor-ui/src/components/UpdatesPanel.vue b/packages/editor-ui/src/components/UpdatesPanel.vue index fb17fd34cadca..a5f1332bc433e 100644 --- a/packages/editor-ui/src/components/UpdatesPanel.vue +++ b/packages/editor-ui/src/components/UpdatesPanel.vue @@ -1,27 +1,16 @@