From b4e459a6373ef64f724577878149bd2e0948eece Mon Sep 17 00:00:00 2001 From: Csaba Tuncsik Date: Wed, 28 Dec 2022 20:17:19 +0100 Subject: [PATCH 1/2] refactor(editor): Usage and plans page on Desktop apply Ivan's review --- .../src/views/SettingsUsageAndPlan.vue | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/packages/editor-ui/src/views/SettingsUsageAndPlan.vue b/packages/editor-ui/src/views/SettingsUsageAndPlan.vue index 080069e797278..d9eae3db0db04 100644 --- a/packages/editor-ui/src/views/SettingsUsageAndPlan.vue +++ b/packages/editor-ui/src/views/SettingsUsageAndPlan.vue @@ -6,6 +6,8 @@ import { UsageTelemetry, useUsageStore } from '@/stores/usage'; import { telemetry } from '@/plugins/telemetry'; import { i18n as locale } from '@/plugins/i18n'; +const PRICING_PAGE_URL = 'https://n8n.io/pricing'; + const usageStore = useUsageStore(); const route = useRoute(); const router = useRouter(); @@ -53,36 +55,38 @@ const onLicenseActivation = async () => { }; onMounted(async () => { - if (!usageStore.isDesktop) { - usageStore.setLoading(true); - if (route.query.key) { - try { - await usageStore.activateLicense(route.query.key as string); - await router.replace({ query: {} }); - showActivationSuccess(); - usageStore.setLoading(false); - return; - } catch (error) { - showActivationError(error); - } - } + if (usageStore.isDesktop) { + return; + } + + usageStore.setLoading(true); + if (route.query.key) { try { - if (!route.query.key && usageStore.canUserActivateLicense) { - await usageStore.refreshLicenseManagementToken(); - } else { - await usageStore.getLicenseInfo(); - } + await usageStore.activateLicense(route.query.key as string); + await router.replace({ query: {} }); + showActivationSuccess(); usageStore.setLoading(false); + return; } catch (error) { - if (!error.name) { - error.name = locale.baseText('settings.usageAndPlan.error'); - } - Notification.error({ - title: error.name, - message: error.message, - position: 'bottom-right', - }); + showActivationError(error); + } + } + try { + if (!route.query.key && usageStore.canUserActivateLicense) { + await usageStore.refreshLicenseManagementToken(); + } else { + await usageStore.getLicenseInfo(); + } + usageStore.setLoading(false); + } catch (error) { + if (!error.name) { + error.name = locale.baseText('settings.usageAndPlan.error'); } + Notification.error({ + title: error.name, + message: error.message, + position: 'bottom-right', + }); } }); @@ -115,7 +119,7 @@ const onDialogOpened = () => { const openPricingPage = () => { sendUsageTelemetry('desktop_view_plans'); - window.open('https://n8n.io/pricing', '_blank'); + window.open(PRICING_PAGE_URL, '_blank'); }; From 7421862694e1b23974273444589d8eb925802804 Mon Sep 17 00:00:00 2001 From: Csaba Tuncsik Date: Thu, 29 Dec 2022 09:31:35 +0100 Subject: [PATCH 2/2] fix(editor): Usage and plans page on Desktop apply Ivan's review --- packages/editor-ui/src/constants.ts | 1 + packages/editor-ui/src/views/SettingsUsageAndPlan.vue | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/editor-ui/src/constants.ts b/packages/editor-ui/src/constants.ts index cc6a706bf1e9c..4f734e6207686 100644 --- a/packages/editor-ui/src/constants.ts +++ b/packages/editor-ui/src/constants.ts @@ -73,6 +73,7 @@ export const COMMUNITY_NODES_RISKS_DOCS_URL = `https://${DOCS_DOMAIN}/integratio export const COMMUNITY_NODES_BLOCKLIST_DOCS_URL = `https://${DOCS_DOMAIN}/integrations/community-nodes/blocklist/`; export const CUSTOM_NODES_DOCS_URL = `https://${DOCS_DOMAIN}/integrations/creating-nodes/code/create-n8n-nodes-module/`; export const EXPRESSIONS_DOCS_URL = `https://${DOCS_DOMAIN}/code-examples/expressions/`; +export const N8N_PRICING_PAGE_URL = `https://n8n.io/pricing`; // node types export const BAMBOO_HR_NODE_TYPE = 'n8n-nodes-base.bambooHr'; diff --git a/packages/editor-ui/src/views/SettingsUsageAndPlan.vue b/packages/editor-ui/src/views/SettingsUsageAndPlan.vue index d9eae3db0db04..d5e1eeaa23a57 100644 --- a/packages/editor-ui/src/views/SettingsUsageAndPlan.vue +++ b/packages/editor-ui/src/views/SettingsUsageAndPlan.vue @@ -5,8 +5,7 @@ import { Notification } from 'element-ui'; import { UsageTelemetry, useUsageStore } from '@/stores/usage'; import { telemetry } from '@/plugins/telemetry'; import { i18n as locale } from '@/plugins/i18n'; - -const PRICING_PAGE_URL = 'https://n8n.io/pricing'; +import { N8N_PRICING_PAGE_URL } from '@/constants'; const usageStore = useUsageStore(); const route = useRoute(); @@ -119,7 +118,7 @@ const onDialogOpened = () => { const openPricingPage = () => { sendUsageTelemetry('desktop_view_plans'); - window.open(PRICING_PAGE_URL, '_blank'); + window.open(N8N_PRICING_PAGE_URL, '_blank'); };