From 9eeba131563c606b7522458c2e614f80e00a277d Mon Sep 17 00:00:00 2001 From: Csaba Tuncsik Date: Wed, 19 Apr 2023 11:00:09 +0200 Subject: [PATCH] refactor(editor): Go to upgrade page (#5994) * refactor(editor): Go to upgrade page * test(editor): add UI store upgrade link tests * fix(editor): update execution filter links * fix(editor): update unit test * fix(editor): update unit test * fix(editor): remove unused variables --- .../CredentialEdit/CredentialSharing.ee.vue | 12 +---- .../src/components/ExecutionFilter.vue | 18 +++---- .../components/MainHeader/WorkflowDetails.vue | 12 +---- .../src/components/WorkflowShareModal.ee.vue | 12 +---- .../__tests__/ExecutionFilter.test.ts | 28 ++++------ .../editor-ui/src/stores/__tests__/ui.test.ts | 53 +++++++++++++++++++ packages/editor-ui/src/stores/ui.ts | 21 ++++++++ .../editor-ui/src/views/SettingsUsersView.vue | 12 +---- 8 files changed, 97 insertions(+), 71 deletions(-) create mode 100644 packages/editor-ui/src/stores/__tests__/ui.test.ts diff --git a/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue b/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue index c33e049ee8..5bea9fa37d 100644 --- a/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue +++ b/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue @@ -181,17 +181,7 @@ export default mixins(showMessage).extend({ this.modalBus.emit('close'); }, goToUpgrade() { - const linkUrlTranslationKey = this.uiStore.contextBasedTranslationKeys - .upgradeLinkUrl as BaseTextKey; - let linkUrl = this.$locale.baseText(linkUrlTranslationKey); - - if (linkUrlTranslationKey.endsWith('.upgradeLinkUrl')) { - linkUrl = `${this.usageStore.viewPlansUrl}&source=credential_sharing`; - } else if (linkUrlTranslationKey.endsWith('.desktop')) { - linkUrl = `${linkUrl}&utm_campaign=upgrade-credentials-sharing`; - } - - window.open(linkUrl, '_blank'); + this.uiStore.goToUpgrade('credential_sharing', 'upgrade-credentials-sharing'); }, }, mounted() { diff --git a/packages/editor-ui/src/components/ExecutionFilter.vue b/packages/editor-ui/src/components/ExecutionFilter.vue index 371a5e43f5..1f76ddf99f 100644 --- a/packages/editor-ui/src/components/ExecutionFilter.vue +++ b/packages/editor-ui/src/components/ExecutionFilter.vue @@ -13,6 +13,7 @@ import { getObjectKeys, isEmpty } from '@/utils'; import { EnterpriseEditionFeature } from '@/constants'; import { useSettingsStore } from '@/stores/settings'; import { useUsageStore } from '@/stores/usage'; +import { useUIStore } from '@/stores/ui'; export type ExecutionFilterProps = { workflows?: IWorkflowShortResponse[]; @@ -20,10 +21,10 @@ export type ExecutionFilterProps = { }; const DATE_TIME_MASK = 'yyyy-MM-dd HH:mm'; -const CLOUD_UPGRADE_LINK = 'https://app.n8n.cloud/manage?edition=cloud'; const settingsStore = useSettingsStore(); const usageStore = useUsageStore(); +const uiStore = useUIStore(); const props = withDefaults(defineProps(), { popoverPlacement: 'bottom', }); @@ -32,11 +33,6 @@ const emit = defineEmits<{ }>(); const debouncedEmit = debounce(emit, 500); -const viewPlansLink = computed(() => - settingsStore.isCloudDeployment - ? CLOUD_UPGRADE_LINK - : `${usageStore.viewPlansUrl}&source=custom-data-filter`, -); const isAdvancedExecutionFilterEnabled = computed(() => settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.AdvancedExecutionFilters), ); @@ -128,6 +124,10 @@ const onFilterReset = () => { emit('filterChanged', filter); }; +const goToUpgrade = () => { + uiStore.goToUpgrade('custom-data-filter', 'upgrade-custom-data-filter'); +}; + onBeforeMount(() => { emit('filterChanged', filter); }); @@ -261,8 +261,8 @@ onBeforeMount(() => {