Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(editor): Usage and plans page on Desktop #5051

Merged
merged 2 commits into from
Dec 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 additions & 27 deletions packages/editor-ui/src/views/SettingsUsageAndPlan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
cstuncsik marked this conversation as resolved.
Show resolved Hide resolved

const usageStore = useUsageStore();
const route = useRoute();
const router = useRouter();
Expand Down Expand Up @@ -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',
});
}
});

Expand Down Expand Up @@ -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');
};
</script>

Expand Down