From 26a653a79a738bf4b3d7aa8b742b5af2cfd0175c Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Fri, 20 Sep 2024 08:24:08 -0400 Subject: [PATCH] refactor(editor): Clean all instances of `isDesktopDeployment` (#10884) --- packages/cli/src/services/frontend.service.ts | 4 +--- .../components/PersonalizationModal.test.ts | 18 +---------------- .../src/components/PersonalizationModal.vue | 12 ----------- .../src/plugins/i18n/locales/en.json | 18 ----------------- packages/editor-ui/src/router.ts | 12 ++--------- .../editor-ui/src/stores/settings.store.ts | 5 ----- packages/editor-ui/src/stores/ui.store.ts | 4 +--- packages/editor-ui/src/stores/usage.store.ts | 1 - .../src/views/SettingsCommunityNodesView.vue | 18 +---------------- .../src/views/SettingsUsageAndPlan.vue | 20 +------------------ packages/editor-ui/src/views/SigninView.vue | 8 -------- 11 files changed, 7 insertions(+), 113 deletions(-) diff --git a/packages/cli/src/services/frontend.service.ts b/packages/cli/src/services/frontend.service.ts index ee9e0dabf3..25758e9537 100644 --- a/packages/cli/src/services/frontend.service.ts +++ b/packages/cli/src/services/frontend.service.ts @@ -261,9 +261,7 @@ export class FrontendService { Object.assign(this.settings.userManagement, { quota: this.license.getUsersLimit(), authenticationMethod: getCurrentAuthenticationMethod(), - showSetupOnFirstLoad: - !config.getEnv('userManagement.isInstanceOwnerSetUp') && - !config.getEnv('deployment.type').startsWith('desktop_'), + showSetupOnFirstLoad: !config.getEnv('userManagement.isInstanceOwnerSetUp'), }); let dismissedBanners: string[] = []; diff --git a/packages/editor-ui/src/components/PersonalizationModal.test.ts b/packages/editor-ui/src/components/PersonalizationModal.test.ts index 160beefccd..a4de7db0fc 100644 --- a/packages/editor-ui/src/components/PersonalizationModal.test.ts +++ b/packages/editor-ui/src/components/PersonalizationModal.test.ts @@ -1,14 +1,10 @@ import userEvent from '@testing-library/user-event'; import { createComponentRenderer } from '@/__tests__/render'; -import { getDropdownItems, mockedStore } from '@/__tests__/utils'; -import { createUser } from '@/__tests__/data/users'; -import { useSettingsStore } from '@/stores/settings.store'; +import { getDropdownItems } from '@/__tests__/utils'; import PersonalizationModal from '@/components/PersonalizationModal.vue'; -import { useUsersStore } from '@/stores/users.store'; import { createTestingPinia } from '@pinia/testing'; import { COMPANY_TYPE_KEY, - EMAIL_KEY, COMPANY_INDUSTRY_EXTENDED_KEY, OTHER_COMPANY_INDUSTRY_EXTENDED_KEY, MARKETING_AUTOMATION_GOAL_KEY, @@ -42,18 +38,6 @@ describe('PersonalizationModal', () => { expect(getByTitle('Customize n8n to you')).toBeInTheDocument(); }); - it('shows user input when needed for desktop deployment', () => { - const pinia = createTestingPinia(); - const usersStore = mockedStore(useUsersStore); - usersStore.currentUser = createUser({ firstName: undefined }); - - const settingsStore = mockedStore(useSettingsStore); - settingsStore.isDesktopDeployment = true; - - const { getByTestId } = renderModal({ pinia }); - expect(getByTestId(EMAIL_KEY)).toBeInTheDocument(); - }); - describe('Company field', () => { it('allows completion of company related fields', async () => { const { getByTestId } = renderModal({ pinia: createTestingPinia() }); diff --git a/packages/editor-ui/src/components/PersonalizationModal.vue b/packages/editor-ui/src/components/PersonalizationModal.vue index 1eab5e4b20..6be5286618 100644 --- a/packages/editor-ui/src/components/PersonalizationModal.vue +++ b/packages/editor-ui/src/components/PersonalizationModal.vue @@ -25,7 +25,6 @@ import { TELECOMS_INDUSTRY, OTHER_AUTOMATION_GOAL, COMPANY_TYPE_KEY, - EMAIL_KEY, SAAS_COMPANY_TYPE, ECOMMERCE_COMPANY_TYPE, MSP_INDUSTRY, @@ -85,7 +84,6 @@ import { import { useToast } from '@/composables/useToast'; import Modal from '@/components/Modal.vue'; import type { IFormInputs, IPersonalizationLatestVersion } from '@/Interface'; -import { useSettingsStore } from '@/stores/settings.store'; import { useRootStore } from '@/stores/root.store'; import { useUsersStore } from '@/stores/users.store'; import { createEventBus, createFormEventBus } from 'n8n-design-system/utils'; @@ -102,7 +100,6 @@ const formBus = createFormEventBus(); const { showError } = useToast(); const i18n = useI18n(); const rootStore = useRootStore(); -const settingsStore = useSettingsStore(); const usersStore = useUsersStore(); const posthogStore = usePostHog(); const route = useRoute(); @@ -112,15 +109,6 @@ const formValues = ref>({}); const isSaving = ref(false); const survey = computed(() => [ - { - name: EMAIL_KEY, - properties: { - label: i18n.baseText('personalizationModal.yourEmailAddress'), - type: 'text', - placeholder: i18n.baseText('personalizationModal.email'), - }, - shouldDisplay: () => settingsStore.isDesktopDeployment && !usersStore.currentUser?.firstName, - }, { name: COMPANY_TYPE_KEY, properties: { diff --git a/packages/editor-ui/src/plugins/i18n/locales/en.json b/packages/editor-ui/src/plugins/i18n/locales/en.json index c3886da761..6159437d8a 100644 --- a/packages/editor-ui/src/plugins/i18n/locales/en.json +++ b/packages/editor-ui/src/plugins/i18n/locales/en.json @@ -1597,7 +1597,6 @@ "settings.communityNodes.empty.description.no-packages": "Install node packages contributed by our community.", "settings.communityNodes.empty.installPackageLabel": "Install a community node", "settings.communityNodes.npmUnavailable.warning": "To use this feature, please install npm and restart n8n.", - "settings.communityNodes.notAvailableOnDesktop": "Feature unavailable on desktop. Please self-host to use community nodes.", "settings.communityNodes.packageNodes.label": "{count} node | {count} nodes", "settings.communityNodes.updateAvailable.tooltip": "A newer version is available", "settings.communityNodes.viewDocsAction.label": "Documentation", @@ -1788,8 +1787,6 @@ "settings.usageAndPlan.license.activation.error.title": "Activation failed", "settings.usageAndPlan.license.activation.success.title": "License activated", "settings.usageAndPlan.license.activation.success.message": "Your {name} {type} has been successfully activated.", - "settings.usageAndPlan.desktop.title": "Upgrade to n8n Cloud for the full experience", - "settings.usageAndPlan.desktop.description": "Cloud plans allow you to collaborate with teammates. Plus you don’t need to leave this app open all the time for your workflows to run.", "settings.externalSecrets.title": "External Secrets", "settings.externalSecrets.info": "Connect external secrets tools for centralized credentials management across environments, and to enhance system security.", "settings.externalSecrets.info.link": "More info", @@ -2317,47 +2314,32 @@ "variables.modals.deleteConfirm.cancelButton": "Cancel", "contextual.credentials.sharing.unavailable.title": "Upgrade to collaborate", "contextual.credentials.sharing.unavailable.title.cloud": "Upgrade to collaborate", - "contextual.credentials.sharing.unavailable.title.desktop": "Upgrade to n8n Cloud to collaborate", "contextual.credentials.sharing.unavailable.description": "You can share credentials with others when you upgrade your plan.", "contextual.credentials.sharing.unavailable.description.cloud": "You can share credentials with others when you upgrade your plan.", - "contextual.credentials.sharing.unavailable.description.desktop": "Sharing features are available on selected Cloud plans", "contextual.credentials.sharing.unavailable.button": "View plans", "contextual.credentials.sharing.unavailable.button.cloud": "Upgrade now", - "contextual.credentials.sharing.unavailable.button.desktop": "View plans", "contextual.workflows.sharing.title": "Sharing", "contextual.workflows.sharing.unavailable.title": "Sharing", "contextual.workflows.sharing.unavailable.title.cloud": "Upgrade to collaborate", - "contextual.workflows.sharing.unavailable.title.desktop": "Upgrade to n8n Cloud to collaborate", "contextual.workflows.sharing.unavailable.description.modal": "You can collaborate with others on workflows when you upgrade your plan.", "contextual.workflows.sharing.unavailable.description.modal.cloud": "You can collaborate with others on workflows when you upgrade your plan.", - "contextual.workflows.sharing.unavailable.description.modal.desktop": "Upgrade to n8n Cloud to collaborate on workflows: sharing features are available on selected plans.", "contextual.workflows.sharing.unavailable.description.tooltip": "You can collaborate with others on workflows when you upgrade your plan. {action}", "contextual.workflows.sharing.unavailable.description.tooltip.cloud": "You can collaborate with others on workflows when you upgrade your plan. {action}", - "contextual.workflows.sharing.unavailable.description.tooltip.desktop": "Upgrade to n8n Cloud to collaborate on workflows: sharing features are available on selected plans. {action}", "contextual.workflows.sharing.unavailable.button": "View plans", "contextual.workflows.sharing.unavailable.button.cloud": "Upgrade now", - "contextual.workflows.sharing.unavailable.button.desktop": "View plans", "contextual.variables.unavailable.title": "Available on the Enterprise plan", "contextual.variables.unavailable.title.cloud": "Available on Pro plan", - "contextual.variables.unavailable.title.desktop": "Upgrade to n8n Cloud to collaborate", "contextual.variables.unavailable.description": "Variables can be used to store and access data across workflows. Reference them in n8n using the prefix $vars (e.g. $vars.myVariable). Variables are immutable and cannot be modified within your workflows.
Learn more in the docs.", "contextual.variables.unavailable.button": "View plans", "contextual.variables.unavailable.button.cloud": "Upgrade now", - "contextual.variables.unavailable.button.desktop": "View plans", "contextual.users.settings.unavailable.title": "Upgrade to add users", "contextual.users.settings.unavailable.title.cloud": "Upgrade to add users", - "contextual.users.settings.unavailable.title.desktop": "Upgrade to add users", "contextual.users.settings.unavailable.description": "Create multiple users on our higher plans and share workflows and credentials to collaborate", "contextual.users.settings.unavailable.description.cloud": "Create multiple users on our higher plans and share workflows and credentials to collaborate", - "contextual.users.settings.unavailable.description.desktop": "Create multiple users on our higher plans and share workflows and credentials to collaborate", "contextual.users.settings.unavailable.button": "View plans", "contextual.users.settings.unavailable.button.cloud": "Upgrade now", - "contextual.users.settings.unavailable.button.desktop": "View plans", - "contextual.communityNodes.unavailable.description.desktop": "Community nodes feature is unavailable on desktop. Please choose one of our available self-hosting plans.", - "contextual.communityNodes.unavailable.button.desktop": "View plans", "contextual.feature.unavailable.title": "Available on the Enterprise Plan", "contextual.feature.unavailable.title.cloud": "Available on the Pro Plan", - "contextual.feature.unavailable.title.desktop": "Available on cloud hosting", "settings.ldap": "LDAP", "settings.ldap.note": "LDAP allows users to authenticate with their centralized account. It's compatible with services that provide an LDAP interface like Active Directory, Okta and Jumpcloud.", "settings.ldap.infoTip": "Learn more about LDAP in the Docs", diff --git a/packages/editor-ui/src/router.ts b/packages/editor-ui/src/router.ts index c304d6bd75..cbcc0dc1ce 100644 --- a/packages/editor-ui/src/router.ts +++ b/packages/editor-ui/src/router.ts @@ -576,12 +576,8 @@ export const routes: RouteRecordRaw[] = [ settingsView: SettingsSso, }, meta: { - middleware: ['authenticated', 'rbac', 'custom'], + middleware: ['authenticated', 'rbac'], middlewareOptions: { - custom: () => { - const settingsStore = useSettingsStore(); - return !settingsStore.isDesktopDeployment; - }, rbac: { scope: 'saml:manage', }, @@ -693,11 +689,7 @@ export const routes: RouteRecordRaw[] = [ custom: () => { const settingsStore = useSettingsStore(); const ssoStore = useSSOStore(); - return ( - ssoStore.isEnterpriseSamlEnabled && - !settingsStore.isCloudDeployment && - !settingsStore.isDesktopDeployment - ); + return ssoStore.isEnterpriseSamlEnabled && !settingsStore.isCloudDeployment; }, }, telemetry: { diff --git a/packages/editor-ui/src/stores/settings.store.ts b/packages/editor-ui/src/stores/settings.store.ts index 69cd665e84..d9601479d4 100644 --- a/packages/editor-ui/src/stores/settings.store.ts +++ b/packages/editor-ui/src/stores/settings.store.ts @@ -92,10 +92,6 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => { const deploymentType = computed(() => settings.value.deployment?.type || 'default'); - const isDesktopDeployment = computed(() => - settings.value.deployment?.type.startsWith('desktop_'), - ); - const isCloudDeployment = computed(() => settings.value.deployment?.type === 'cloud'); const isSmtpSetup = computed(() => userManagement.value.smtpSetup); @@ -395,7 +391,6 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => { isSamlLoginEnabled, showSetupPage, deploymentType, - isDesktopDeployment, isCloudDeployment, isSmtpSetup, isPersonalizationSurveyEnabled, diff --git a/packages/editor-ui/src/stores/ui.store.ts b/packages/editor-ui/src/stores/ui.store.ts index e854ac656c..79220796f0 100644 --- a/packages/editor-ui/src/stores/ui.store.ts +++ b/packages/editor-ui/src/stores/ui.store.ts @@ -224,11 +224,9 @@ export const useUIStore = defineStore(STORES.UI, () => { const contextBasedTranslationKeys = computed(() => { const deploymentType = settingsStore.deploymentType; - let contextKey: '' | '.cloud' | '.desktop' = ''; + let contextKey: '' | '.cloud' = ''; if (deploymentType === 'cloud') { contextKey = '.cloud'; - } else if (deploymentType === 'desktop_mac' || deploymentType === 'desktop_win') { - contextKey = '.desktop'; } return { diff --git a/packages/editor-ui/src/stores/usage.store.ts b/packages/editor-ui/src/stores/usage.store.ts index be80fd4b4e..ae2965529d 100644 --- a/packages/editor-ui/src/stores/usage.store.ts +++ b/packages/editor-ui/src/stores/usage.store.ts @@ -122,6 +122,5 @@ export const useUsageStore = defineStore('usage', () => { usage: executionCount.value, quota: executionLimit.value, })), - isDesktop: computed(() => settingsStore.isDesktopDeployment), }; }); diff --git a/packages/editor-ui/src/views/SettingsCommunityNodesView.vue b/packages/editor-ui/src/views/SettingsCommunityNodesView.vue index 8d51c9eb9d..c443ad2e9a 100644 --- a/packages/editor-ui/src/views/SettingsCommunityNodesView.vue +++ b/packages/editor-ui/src/views/SettingsCommunityNodesView.vue @@ -41,10 +41,6 @@ const uiStore = useUIStore(); const getEmptyStateDescription = computed(() => { const packageCount = communityNodesStore.availablePackageCount; - if (settingsStore.isDesktopDeployment) { - return i18n.baseText('contextual.communityNodes.unavailable.description.desktop'); - } - return packageCount < PACKAGE_COUNT_THRESHOLD ? i18n.baseText('settings.communityNodes.empty.description.no-packages', { interpolate: { @@ -60,14 +56,10 @@ const getEmptyStateDescription = computed(() => { }); const shouldShowInstallButton = computed(() => { - return settingsStore.isDesktopDeployment || settingsStore.isNpmAvailable; + return settingsStore.isNpmAvailable; }); const getEmptyStateButtonText = computed(() => { - if (settingsStore.isDesktopDeployment) { - return i18n.baseText('contextual.communityNodes.unavailable.button.desktop'); - } - return shouldShowInstallButton.value ? i18n.baseText('settings.communityNodes.empty.installPackageLabel') : ''; @@ -91,15 +83,7 @@ const actionBoxConfig = computed(() => { }; }); -const goToUpgrade = () => { - void uiStore.goToUpgrade('community-nodes', 'upgrade-community-nodes'); -}; - const onClickEmptyStateButton = () => { - if (settingsStore.isDesktopDeployment) { - return goToUpgrade(); - } - openInstallModal(); }; diff --git a/packages/editor-ui/src/views/SettingsUsageAndPlan.vue b/packages/editor-ui/src/views/SettingsUsageAndPlan.vue index ea8f8ebf88..85ac34af9a 100644 --- a/packages/editor-ui/src/views/SettingsUsageAndPlan.vue +++ b/packages/editor-ui/src/views/SettingsUsageAndPlan.vue @@ -6,7 +6,6 @@ import { useUsageStore } from '@/stores/usage.store'; import { telemetry } from '@/plugins/telemetry'; import { i18n as locale } from '@/plugins/i18n'; import { useUIStore } from '@/stores/ui.store'; -import { N8N_PRICING_PAGE_URL } from '@/constants'; import { useToast } from '@/composables/useToast'; import { hasPermission } from '@/utils/rbac/permissions'; @@ -65,10 +64,6 @@ const onLicenseActivation = async () => { }; onMounted(async () => { - if (usageStore.isDesktop) { - return; - } - usageStore.setLoading(true); if (route.query.key) { try { @@ -123,25 +118,12 @@ const onDialogClosed = () => { const onDialogOpened = () => { activationKeyInput.value?.focus(); }; - -const openPricingPage = () => { - sendUsageTelemetry('desktop_view_plans'); - window.open(N8N_PRICING_PAGE_URL, '_blank'); -};