mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
feat(editor): Update templates links (#9024)
This commit is contained in:
parent
aac77e1668
commit
4619dec285
|
@ -687,7 +687,8 @@ export type IPersonalizationLatestVersion = IPersonalizationSurveyAnswersV4;
|
||||||
export type IPersonalizationSurveyVersions =
|
export type IPersonalizationSurveyVersions =
|
||||||
| IPersonalizationSurveyAnswersV1
|
| IPersonalizationSurveyAnswersV1
|
||||||
| IPersonalizationSurveyAnswersV2
|
| IPersonalizationSurveyAnswersV2
|
||||||
| IPersonalizationSurveyAnswersV3;
|
| IPersonalizationSurveyAnswersV3
|
||||||
|
| IPersonalizationSurveyAnswersV4;
|
||||||
|
|
||||||
export type Roles = typeof ROLE;
|
export type Roles = typeof ROLE;
|
||||||
export type IRole = Roles[keyof Roles];
|
export type IRole = Roles[keyof Roles];
|
||||||
|
|
|
@ -243,7 +243,7 @@ export default defineComponent({
|
||||||
available:
|
available:
|
||||||
this.settingsStore.isTemplatesEnabled && !this.templatesStore.hasCustomTemplatesHost,
|
this.settingsStore.isTemplatesEnabled && !this.templatesStore.hasCustomTemplatesHost,
|
||||||
link: {
|
link: {
|
||||||
href: this.templatesStore.getWebsiteTemplateRepositoryURL,
|
href: this.templatesStore.websiteTemplateRepositoryURL,
|
||||||
target: '_blank',
|
target: '_blank',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -77,6 +77,7 @@ import {
|
||||||
faHandHoldingUsd,
|
faHandHoldingUsd,
|
||||||
faHandScissors,
|
faHandScissors,
|
||||||
faHandPointLeft,
|
faHandPointLeft,
|
||||||
|
faHandshake,
|
||||||
faHashtag,
|
faHashtag,
|
||||||
faHdd,
|
faHdd,
|
||||||
faHistory,
|
faHistory,
|
||||||
|
@ -240,6 +241,7 @@ export const FontAwesomePlugin: Plugin<{}> = {
|
||||||
addIcon(faGraduationCap);
|
addIcon(faGraduationCap);
|
||||||
addIcon(faHandHoldingUsd);
|
addIcon(faHandHoldingUsd);
|
||||||
addIcon(faHandScissors);
|
addIcon(faHandScissors);
|
||||||
|
addIcon(faHandshake);
|
||||||
addIcon(faHandPointLeft);
|
addIcon(faHandPointLeft);
|
||||||
addIcon(faHashtag);
|
addIcon(faHashtag);
|
||||||
addIcon(faHdd);
|
addIcon(faHdd);
|
||||||
|
|
|
@ -187,7 +187,7 @@ export const routes = [
|
||||||
beforeEnter: (_to, _from, next) => {
|
beforeEnter: (_to, _from, next) => {
|
||||||
const templatesStore = useTemplatesStore();
|
const templatesStore = useTemplatesStore();
|
||||||
if (!templatesStore.hasCustomTemplatesHost) {
|
if (!templatesStore.hasCustomTemplatesHost) {
|
||||||
window.location.href = templatesStore.getWebsiteTemplateRepositoryURL;
|
window.location.href = templatesStore.websiteTemplateRepositoryURL;
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ export const useTemplatesStore = defineStore(STORES.TEMPLATES, {
|
||||||
* Constructs URLSearchParams object based on the default parameters for the template repository
|
* Constructs URLSearchParams object based on the default parameters for the template repository
|
||||||
* and provided additional parameters
|
* and provided additional parameters
|
||||||
*/
|
*/
|
||||||
getWebsiteTemplateRepositoryParameters() {
|
websiteTemplateRepositoryParameters() {
|
||||||
const rootStore = useRootStore();
|
const rootStore = useRootStore();
|
||||||
const userStore = useUsersStore();
|
const userStore = useUsersStore();
|
||||||
const workflowsStore = useWorkflowsStore();
|
const workflowsStore = useWorkflowsStore();
|
||||||
|
@ -131,8 +131,10 @@ export const useTemplatesStore = defineStore(STORES.TEMPLATES, {
|
||||||
utm_n8n_version: rootStore.versionCli,
|
utm_n8n_version: rootStore.versionCli,
|
||||||
utm_awc: String(workflowsStore.activeWorkflows.length),
|
utm_awc: String(workflowsStore.activeWorkflows.length),
|
||||||
};
|
};
|
||||||
if (userStore.currentUserCloudInfo?.role) {
|
const userRole: string | undefined =
|
||||||
defaultParameters.utm_user_role = userStore.currentUserCloudInfo.role;
|
userStore.currentUserCloudInfo?.role ?? userStore.currentUser?.personalizationAnswers?.role;
|
||||||
|
if (userRole) {
|
||||||
|
defaultParameters.utm_user_role = userRole;
|
||||||
}
|
}
|
||||||
return (additionalParameters: Record<string, string> = {}) => {
|
return (additionalParameters: Record<string, string> = {}) => {
|
||||||
return new URLSearchParams({
|
return new URLSearchParams({
|
||||||
|
@ -145,28 +147,17 @@ export const useTemplatesStore = defineStore(STORES.TEMPLATES, {
|
||||||
* Construct the URL for the template repository on the website
|
* Construct the URL for the template repository on the website
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
getWebsiteTemplateRepositoryURL(): string {
|
websiteTemplateRepositoryURL(): string {
|
||||||
return `${
|
return `${
|
||||||
TEMPLATES_URLS.BASE_WEBSITE_URL
|
TEMPLATES_URLS.BASE_WEBSITE_URL
|
||||||
}?${this.getWebsiteTemplateRepositoryParameters().toString()}`;
|
}?${this.websiteTemplateRepositoryParameters().toString()}`;
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Construct the URL for the template page on the website for a given template id
|
|
||||||
* @returns {function(string): string}
|
|
||||||
*/
|
|
||||||
getWebsiteTemplatePageURL() {
|
|
||||||
return (id: string) => {
|
|
||||||
return `${
|
|
||||||
TEMPLATES_URLS.BASE_WEBSITE_URL
|
|
||||||
}/${id}?${this.getWebsiteTemplateRepositoryParameters().toString()}`;
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Construct the URL for the template category page on the website for a given category id
|
* Construct the URL for the template category page on the website for a given category id
|
||||||
*/
|
*/
|
||||||
getWebsiteCategoryURL() {
|
getWebsiteCategoryURL() {
|
||||||
return (id: string) => {
|
return (id: string) => {
|
||||||
return `${TEMPLATES_URLS.BASE_WEBSITE_URL}/?${this.getWebsiteTemplateRepositoryParameters({
|
return `${TEMPLATES_URLS.BASE_WEBSITE_URL}/?${this.websiteTemplateRepositoryParameters({
|
||||||
categories: id,
|
categories: id,
|
||||||
}).toString()}`;
|
}).toString()}`;
|
||||||
};
|
};
|
||||||
|
|
|
@ -85,8 +85,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!readOnlyEnv" :class="['text-center', 'mt-2xl', $style.actionsContainer]">
|
<div v-if="!readOnlyEnv" :class="['text-center', 'mt-2xl', $style.actionsContainer]">
|
||||||
<a
|
<a
|
||||||
v-if="userCloudAccount?.role === 'Sales'"
|
v-if="isSalesUser"
|
||||||
:href="getTemplateRepositoryURL('Sales')"
|
:href="getTemplateRepositoryURL()"
|
||||||
:class="$style.emptyStateCard"
|
:class="$style.emptyStateCard"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
data-test-id="browse-sales-templates-card"
|
data-test-id="browse-sales-templates-card"
|
||||||
@click="trackCategoryLinkClick('Sales')"
|
@click="trackCategoryLinkClick('Sales')"
|
||||||
>
|
>
|
||||||
<n8n-icon :class="$style.emptyStateCardIcon" icon="hand-holding-usd" />
|
<n8n-icon :class="$style.emptyStateCardIcon" icon="handshake" />
|
||||||
<n8n-text size="large" class="mt-xs" color="text-base">
|
<n8n-text size="large" class="mt-xs" color="text-base">
|
||||||
{{
|
{{
|
||||||
$locale.baseText('workflows.empty.browseTemplates', {
|
$locale.baseText('workflows.empty.browseTemplates', {
|
||||||
|
@ -261,8 +261,14 @@ const WorkflowsView = defineComponent({
|
||||||
suggestedTemplates() {
|
suggestedTemplates() {
|
||||||
return this.uiStore.suggestedTemplates;
|
return this.uiStore.suggestedTemplates;
|
||||||
},
|
},
|
||||||
userCloudAccount() {
|
userRole() {
|
||||||
return this.usersStore.currentUserCloudInfo;
|
const userRole: string | undefined =
|
||||||
|
this.usersStore.currentUserCloudInfo?.role ??
|
||||||
|
this.usersStore.currentUser?.personalizationAnswers?.role;
|
||||||
|
return userRole;
|
||||||
|
},
|
||||||
|
isSalesUser() {
|
||||||
|
return ['Sales', 'sales-and-marketing'].includes(this.userRole);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -299,8 +305,8 @@ const WorkflowsView = defineComponent({
|
||||||
source: 'Workflows list',
|
source: 'Workflows list',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getTemplateRepositoryURL(category: string) {
|
getTemplateRepositoryURL() {
|
||||||
return this.templatesStore.getWebsiteCategoryURL(category);
|
return this.templatesStore.websiteTemplateRepositoryURL;
|
||||||
},
|
},
|
||||||
trackCategoryLinkClick(category: string) {
|
trackCategoryLinkClick(category: string) {
|
||||||
this.$telemetry.track(`User clicked Browse ${category} Templates`, {
|
this.$telemetry.track(`User clicked Browse ${category} Templates`, {
|
||||||
|
|
Loading…
Reference in a new issue