2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
|
|
|
<div v-if="webhooksNode.length" class="webhoooks">
|
2021-12-07 08:28:10 -08:00
|
|
|
<div class="clickable headline" :class="{expanded: !isMinimized}" @click="isMinimized=!isMinimized" :title="isMinimized ? $i.baseText('nodeWebhooks.clickToDisplayWebhookUrls') : $i.baseText('nodeWebhooks.clickToHideWebhookUrls')">
|
2021-07-23 08:42:46 -07:00
|
|
|
<font-awesome-icon icon="angle-down" class="minimize-button minimize-icon" />
|
2021-12-07 08:28:10 -08:00
|
|
|
{{ $i.baseText('nodeWebhooks.webhookUrls') }}
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
|
|
|
<el-collapse-transition>
|
|
|
|
<div class="node-webhooks" v-if="!isMinimized">
|
|
|
|
<div class="url-selection">
|
|
|
|
<el-row>
|
2021-07-23 08:42:46 -07:00
|
|
|
<el-col :span="24">
|
2019-06-23 03:35:23 -07:00
|
|
|
<el-radio-group v-model="showUrlFor" size="mini">
|
2021-12-07 08:28:10 -08:00
|
|
|
<el-radio-button label="test">{{ $i.baseText('nodeWebhooks.testUrl') }}</el-radio-button>
|
|
|
|
<el-radio-button label="production">{{ $i.baseText('nodeWebhooks.productionUrl') }}</el-radio-button>
|
2019-06-23 03:35:23 -07:00
|
|
|
</el-radio-group>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</div>
|
|
|
|
|
2021-12-07 08:28:10 -08:00
|
|
|
<n8n-tooltip v-for="(webhook, index) in webhooksNode" :key="index" class="item" :content="$i.baseText('nodeWebhooks.clickToCopyWebhookUrls')" placement="left">
|
2019-06-23 03:35:23 -07:00
|
|
|
<div class="webhook-wrapper">
|
|
|
|
<div class="http-field">
|
|
|
|
<div class="http-method">
|
|
|
|
{{getValue(webhook, 'httpMethod')}}<br />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="url-field">
|
|
|
|
<div class="webhook-url left-ellipsis clickable" @click="copyWebhookUrl(webhook)">
|
2021-08-21 05:11:32 -07:00
|
|
|
{{getWebhookUrlDisplay(webhook)}}<br />
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-29 04:36:17 -07:00
|
|
|
</n8n-tooltip>
|
2019-06-23 03:35:23 -07:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</el-collapse-transition>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import {
|
2021-08-21 05:11:32 -07:00
|
|
|
INodeTypeDescription,
|
2019-06-23 03:35:23 -07:00
|
|
|
IWebhookDescription,
|
|
|
|
NodeHelpers,
|
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
2021-10-18 20:57:49 -07:00
|
|
|
import { WEBHOOK_NODE_TYPE } from '@/constants';
|
2019-06-23 03:35:23 -07:00
|
|
|
import { copyPaste } from '@/components/mixins/copyPaste';
|
|
|
|
import { showMessage } from '@/components/mixins/showMessage';
|
|
|
|
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
|
|
|
|
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
|
|
|
|
export default mixins(
|
|
|
|
copyPaste,
|
2019-12-16 18:27:56 -08:00
|
|
|
showMessage,
|
2019-06-23 03:35:23 -07:00
|
|
|
workflowHelpers,
|
|
|
|
)
|
|
|
|
.extend({
|
|
|
|
name: 'NodeWebhooks',
|
|
|
|
props: [
|
|
|
|
'node', // NodeUi
|
2021-08-21 05:11:32 -07:00
|
|
|
'nodeType', // INodeTypeDescription
|
2019-06-23 03:35:23 -07:00
|
|
|
],
|
|
|
|
data () {
|
|
|
|
return {
|
2021-11-19 01:17:13 -08:00
|
|
|
isMinimized: this.nodeType && this.nodeType.name !== WEBHOOK_NODE_TYPE,
|
2021-07-23 08:42:46 -07:00
|
|
|
showUrlFor: 'test',
|
2019-06-23 03:35:23 -07:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
webhooksNode (): IWebhookDescription[] {
|
|
|
|
if (this.nodeType === null || this.nodeType.webhooks === undefined) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2021-08-21 05:11:32 -07:00
|
|
|
return (this.nodeType as INodeTypeDescription).webhooks!.filter(webhookData => webhookData.restartWebhook !== true);
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
copyWebhookUrl (webhookData: IWebhookDescription): void {
|
|
|
|
const webhookUrl = this.getWebhookUrl(webhookData);
|
|
|
|
this.copyToClipboard(webhookUrl);
|
|
|
|
|
|
|
|
this.$showMessage({
|
2021-12-07 08:28:10 -08:00
|
|
|
title: this.$i.baseText('nodeWebhooks.showMessage.title'),
|
|
|
|
message: this.$i.baseText('nodeWebhooks.showMessage.message'),
|
2019-06-23 03:35:23 -07:00
|
|
|
type: 'success',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getValue (webhookData: IWebhookDescription, key: string): string {
|
|
|
|
if (webhookData[key] === undefined) {
|
|
|
|
return 'empty';
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
return this.resolveExpression(webhookData[key] as string) as string;
|
|
|
|
} catch (e) {
|
2021-12-07 08:28:10 -08:00
|
|
|
return this.$i.baseText('nodeWebhooks.invalidExpression');
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getWebhookUrl (webhookData: IWebhookDescription): string {
|
2021-08-21 05:11:32 -07:00
|
|
|
if (webhookData.restartWebhook === true) {
|
|
|
|
return '$resumeWebhookUrl';
|
|
|
|
}
|
2019-06-23 03:35:23 -07:00
|
|
|
let baseUrl = this.$store.getters.getWebhookUrl;
|
2021-07-23 08:42:46 -07:00
|
|
|
if (this.showUrlFor === 'test') {
|
2019-06-23 03:35:23 -07:00
|
|
|
baseUrl = this.$store.getters.getWebhookTestUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
const workflowId = this.$store.getters.workflowId;
|
|
|
|
const path = this.getValue(webhookData, 'path');
|
2020-06-10 06:39:15 -07:00
|
|
|
const isFullPath = this.getValue(webhookData, 'isFullPath') as unknown as boolean || false;
|
2019-06-23 03:35:23 -07:00
|
|
|
|
2020-06-10 06:39:15 -07:00
|
|
|
return NodeHelpers.getNodeWebhookUrl(baseUrl, workflowId, this.node, path, isFullPath);
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
2021-08-21 05:11:32 -07:00
|
|
|
getWebhookUrlDisplay (webhookData: IWebhookDescription): string {
|
|
|
|
return this.getWebhookUrl(webhookData);
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
node () {
|
2021-10-18 20:57:49 -07:00
|
|
|
this.isMinimized = this.nodeType.name !== WEBHOOK_NODE_TYPE;
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
|
|
.webhoooks {
|
2021-10-27 12:55:37 -07:00
|
|
|
padding-bottom: var(--spacing-xs);
|
|
|
|
margin: var(--spacing-xs) 0;
|
2019-06-23 03:35:23 -07:00
|
|
|
border-bottom: 1px solid #ccc;
|
|
|
|
|
|
|
|
.headline {
|
|
|
|
color: $--color-primary;
|
|
|
|
font-weight: 600;
|
2021-10-27 12:55:37 -07:00
|
|
|
font-size: var(--font-size-2xs);
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.http-field {
|
|
|
|
position: absolute;
|
|
|
|
width: 50px;
|
|
|
|
display: inline-block;
|
|
|
|
top: calc(50% - 8px)
|
|
|
|
}
|
|
|
|
|
|
|
|
.http-method {
|
|
|
|
background-color: green;
|
|
|
|
width: 40px;
|
|
|
|
height: 16px;
|
|
|
|
line-height: 16px;
|
|
|
|
margin-left: 5px;
|
|
|
|
text-align: center;
|
|
|
|
border-radius: 2px;
|
2021-10-27 12:55:37 -07:00
|
|
|
font-size: var(--font-size-2xs);
|
|
|
|
font-weight: var(--font-weight-bold);
|
2019-06-23 03:35:23 -07:00
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
.minimize-icon {
|
|
|
|
font-size: 1.3em;
|
|
|
|
margin-right: 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.mode-selection-headline {
|
|
|
|
line-height: 1.8em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.node-webhooks {
|
|
|
|
margin-left: 1em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.url-field {
|
|
|
|
display: inline-block;
|
|
|
|
width: calc(100% - 60px);
|
2021-10-27 12:55:37 -07:00
|
|
|
margin-left: 55px;
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
.url-selection {
|
2021-10-27 12:55:37 -07:00
|
|
|
margin-top: var(--spacing-xs);
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
.minimize-button {
|
|
|
|
display: inline-block;
|
|
|
|
-webkit-transition-duration: 0.5s;
|
|
|
|
-moz-transition-duration: 0.5s;
|
|
|
|
-o-transition-duration: 0.5s;
|
|
|
|
transition-duration: 0.5s;
|
|
|
|
|
|
|
|
-webkit-transition-property: -webkit-transform;
|
|
|
|
-moz-transition-property: -moz-transform;
|
|
|
|
-o-transition-property: -o-transform;
|
|
|
|
transition-property: transform;
|
|
|
|
}
|
|
|
|
.expanded .minimize-button {
|
|
|
|
-webkit-transform: rotate(180deg);
|
|
|
|
-moz-transform: rotate(180deg);
|
|
|
|
-o-transform: rotate(180deg);
|
|
|
|
transform: rotate(180deg);
|
|
|
|
}
|
|
|
|
|
|
|
|
.webhook-url {
|
|
|
|
position: relative;
|
|
|
|
top: 0;
|
|
|
|
width: 100%;
|
2021-10-27 12:55:37 -07:00
|
|
|
font-size: var(--font-size-2xs);
|
2019-06-23 03:35:23 -07:00
|
|
|
white-space: normal;
|
|
|
|
overflow: visible;
|
|
|
|
text-overflow: initial;
|
|
|
|
color: #404040;
|
|
|
|
text-align: left;
|
|
|
|
direction: ltr;
|
|
|
|
word-break: break-all;
|
|
|
|
}
|
|
|
|
|
|
|
|
.webhook-wrapper {
|
2021-08-29 04:36:17 -07:00
|
|
|
line-height: 1.5;
|
2019-06-23 03:35:23 -07:00
|
|
|
position: relative;
|
2021-10-27 12:55:37 -07:00
|
|
|
margin-top: var(--spacing-xs);
|
2019-06-23 03:35:23 -07:00
|
|
|
background-color: #fff;
|
|
|
|
border-radius: 3px;
|
|
|
|
}
|
|
|
|
</style>
|