From 9a25a7fc12de45277c600b5a3fe4b6d0012717ab Mon Sep 17 00:00:00 2001 From: Csaba Tuncsik Date: Wed, 28 Dec 2022 14:16:15 +0100 Subject: [PATCH 1/2] fix(editor): Usage and plans page on Desktop --- .../src/plugins/i18n/locales/en.json | 2 + packages/editor-ui/src/stores/usage.ts | 3 +- .../src/views/SettingsUsageAndPlan.vue | 223 ++++++++++-------- 3 files changed, 128 insertions(+), 100 deletions(-) diff --git a/packages/editor-ui/src/plugins/i18n/locales/en.json b/packages/editor-ui/src/plugins/i18n/locales/en.json index c9d002f201294..c7be218a25637 100644 --- a/packages/editor-ui/src/plugins/i18n/locales/en.json +++ b/packages/editor-ui/src/plugins/i18n/locales/en.json @@ -1148,6 +1148,8 @@ "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.", "showMessage.cancel": "@:_reusableBaseText.cancel", "showMessage.ok": "OK", "showMessage.showDetails": "Show Details", diff --git a/packages/editor-ui/src/stores/usage.ts b/packages/editor-ui/src/stores/usage.ts index 26104dd9e9ef6..e9e1b7dc77df2 100644 --- a/packages/editor-ui/src/stores/usage.ts +++ b/packages/editor-ui/src/stores/usage.ts @@ -8,7 +8,7 @@ import { useUsersStore } from '@/stores/users'; export type UsageTelemetry = { instance_id: string; - action: 'view_plans' | 'manage_plan' | 'add_activation_key'; + action: 'view_plans' | 'manage_plan' | 'add_activation_key' | 'desktop_view_plans'; plan_name_current: string; usage: number; quota: number; @@ -120,5 +120,6 @@ export const useUsageStore = defineStore('usage', () => { usage: executionCount.value, quota: executionLimit.value, })), + isDesktop: computed(() => settingsStore.isDesktopDeployment), }; }); diff --git a/packages/editor-ui/src/views/SettingsUsageAndPlan.vue b/packages/editor-ui/src/views/SettingsUsageAndPlan.vue index efd75677eadc5..7574fce16293f 100644 --- a/packages/editor-ui/src/views/SettingsUsageAndPlan.vue +++ b/packages/editor-ui/src/views/SettingsUsageAndPlan.vue @@ -53,34 +53,36 @@ const onLicenseActivation = async () => { }; onMounted(async () => { - usageStore.setLoading(true); - if (route.query.key) { + 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); + } + } try { - await usageStore.activateLicense(route.query.key as string); - await router.replace({ query: {} }); - showActivationSuccess(); + if (!route.query.key && usageStore.canUserActivateLicense) { + await usageStore.refreshLicenseManagementToken(); + } else { + await usageStore.getLicenseInfo(); + } usageStore.setLoading(false); - return; } catch (error) { - 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'); + if (!error.name) { + error.name = locale.baseText('settings.usageAndPlan.error'); + } + Notification.error({ + title: error.name, + message: error.message, + position: 'bottom-right', + }); } - Notification.error({ - title: error.name, - message: error.message, - position: 'bottom-right', - }); } }); @@ -110,99 +112,122 @@ const onDialogClosed = () => { const onDialogOpened = () => { activationKeyInput.value?.focus(); }; + +const openPricingPage = () => { + sendUsageTelemetry('desktop_view_plans'); + window.open('https://n8n.io/pricing', '_blank'); +};