mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat: Add Chat Trigger node (#7409)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com> Co-authored-by: Jesper Bylund <mail@jesperbylund.com> Co-authored-by: OlegIvaniv <me@olegivaniv.com> Co-authored-by: Deborah <deborah@starfallprojects.co.uk> Co-authored-by: Jan Oberhauser <janober@users.noreply.github.com> Co-authored-by: Jon <jonathan.bennetts@gmail.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Mason Geloso <Mason.geloso@gmail.com> Co-authored-by: Mason Geloso <hone@Masons-Mac-mini.local> Co-authored-by: Mutasem Aldmour <mutasem@n8n.io>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div :class="$style.container">
|
||||
<transition name="fade" mode="out-in">
|
||||
<div v-if="hasIssues" key="empty"></div>
|
||||
<div v-if="hasIssues || hideContent" key="empty"></div>
|
||||
<div v-else-if="isListeningForEvents" key="listening">
|
||||
<n8n-pulse>
|
||||
<NodeIcon :node-type="nodeType" :size="40"></NodeIcon>
|
||||
@@ -45,6 +45,12 @@
|
||||
{{ listeningHint }}
|
||||
</n8n-text>
|
||||
</div>
|
||||
<div v-if="displayChatButton">
|
||||
<n8n-button @click="openWebhookUrl()" class="mb-xl">
|
||||
{{ $locale.baseText('ndv.trigger.chatTrigger.openChat') }}
|
||||
</n8n-button>
|
||||
</div>
|
||||
|
||||
<NodeExecuteButton
|
||||
data-test-id="trigger-execute-button"
|
||||
:node-name="nodeName"
|
||||
@@ -105,6 +111,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import {
|
||||
CHAT_TRIGGER_NODE_TYPE,
|
||||
VIEWS,
|
||||
WEBHOOK_NODE_TYPE,
|
||||
WORKFLOW_SETTINGS_MODAL_KEY,
|
||||
@@ -156,6 +163,36 @@ export default defineComponent({
|
||||
|
||||
return null;
|
||||
},
|
||||
hideContent(): boolean {
|
||||
if (!this.nodeType?.triggerPanel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
this.nodeType?.triggerPanel &&
|
||||
this.nodeType?.triggerPanel.hasOwnProperty('hideContent')
|
||||
) {
|
||||
const hideContent = this.nodeType?.triggerPanel.hideContent;
|
||||
if (typeof hideContent === 'boolean') {
|
||||
return hideContent;
|
||||
}
|
||||
|
||||
if (this.node) {
|
||||
const hideContentValue = this.getCurrentWorkflow().expression.getSimpleParameterValue(
|
||||
this.node,
|
||||
hideContent,
|
||||
'internal',
|
||||
{},
|
||||
);
|
||||
|
||||
if (typeof hideContentValue === 'boolean') {
|
||||
return hideContentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
hasIssues(): boolean {
|
||||
return Boolean(
|
||||
this.node?.issues && (this.node.issues.parameters || this.node.issues.credentials),
|
||||
@@ -168,6 +205,13 @@ export default defineComponent({
|
||||
|
||||
return '';
|
||||
},
|
||||
displayChatButton(): boolean {
|
||||
return Boolean(
|
||||
this.node &&
|
||||
this.node.type === CHAT_TRIGGER_NODE_TYPE &&
|
||||
this.node.parameters.mode !== 'webhook',
|
||||
);
|
||||
},
|
||||
isWebhookNode(): boolean {
|
||||
return Boolean(this.node && this.node.type === WEBHOOK_NODE_TYPE);
|
||||
},
|
||||
@@ -219,11 +263,16 @@ export default defineComponent({
|
||||
: this.$locale.baseText('ndv.trigger.webhookNode.listening');
|
||||
},
|
||||
listeningHint(): string {
|
||||
return this.nodeType?.name === FORM_TRIGGER_NODE_TYPE
|
||||
? this.$locale.baseText('ndv.trigger.webhookBasedNode.formTrigger.serviceHint')
|
||||
: this.$locale.baseText('ndv.trigger.webhookBasedNode.serviceHint', {
|
||||
switch (this.nodeType?.name) {
|
||||
case CHAT_TRIGGER_NODE_TYPE:
|
||||
return this.$locale.baseText('ndv.trigger.webhookBasedNode.chatTrigger.serviceHint');
|
||||
case FORM_TRIGGER_NODE_TYPE:
|
||||
return this.$locale.baseText('ndv.trigger.webhookBasedNode.formTrigger.serviceHint');
|
||||
default:
|
||||
return this.$locale.baseText('ndv.trigger.webhookBasedNode.serviceHint', {
|
||||
interpolate: { service: this.serviceName },
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
header(): string {
|
||||
const serviceName = this.nodeType ? getTriggerNodeServiceName(this.nodeType) : '';
|
||||
@@ -349,6 +398,15 @@ export default defineComponent({
|
||||
this.executionsHelpEventBus.emit('expand');
|
||||
}
|
||||
},
|
||||
openWebhookUrl() {
|
||||
this.$telemetry.track('User clicked ndv link', {
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
session_id: this.sessionId,
|
||||
pane: 'input',
|
||||
type: 'open-chat',
|
||||
});
|
||||
window.open(this.webhookTestUrl, '_blank', 'noreferrer');
|
||||
},
|
||||
onLinkClick(e: MouseEvent) {
|
||||
if (!e.target) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user