n8n/packages/editor-ui/src/composables/useUpgradeLink.ts
Iván Ovejero 71ae6c66ef
fix(editor): Fix unique names for node duplication (#6134)
* 🐛 Fix unique names for node duplication

* 🐛 Fix i18n references
2023-04-28 15:53:59 +02:00

26 lines
820 B
TypeScript

import type { BaseTextKey } from '@/plugins/i18n';
import { useUIStore, useUsageStore } from '@/stores';
import { useI18n } from '@/composables';
import { computed } from 'vue';
export function useUpgradeLink(queryParams = { default: '', desktop: '' }) {
const uiStore = useUIStore();
const usageStore = useUsageStore();
const { i18n } = useI18n();
const upgradeLinkUrl = computed(() => {
const linkUrlTranslationKey = uiStore.contextBasedTranslationKeys.upgradeLinkUrl as BaseTextKey;
let url = i18n.baseText(linkUrlTranslationKey);
if (linkUrlTranslationKey.endsWith('.upgradeLinkUrl')) {
url = `${usageStore.viewPlansUrl}${queryParams.default}`;
} else if (linkUrlTranslationKey.endsWith('.desktop')) {
url = `${url}${queryParams.desktop}`;
}
return url;
});
return { upgradeLinkUrl };
}