2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
|
|
|
<div v-if="webhooksNode.length" class="webhoooks">
|
2021-12-15 04:16:53 -08:00
|
|
|
<div class="clickable headline" :class="{expanded: !isMinimized}" @click="isMinimized=!isMinimized" :title="isMinimized ? $locale.baseText('nodeWebhooks.clickToDisplayWebhookUrls') : $locale.baseText('nodeWebhooks.clickToHideWebhookUrls')">
|
2021-07-23 08:42:46 -07:00
|
|
|
<font-awesome-icon icon="angle-down" class="minimize-button minimize-icon" />
|
2021-12-15 04:16:53 -08:00
|
|
|
{{ $locale.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">
|
2022-06-20 12:39:24 -07:00
|
|
|
<n8n-radio-buttons
|
|
|
|
v-model="showUrlFor"
|
|
|
|
:options="[
|
|
|
|
{ label: this.$locale.baseText('nodeWebhooks.testUrl'), value: 'test'},
|
|
|
|
{ label: this.$locale.baseText('nodeWebhooks.productionUrl'), value: 'production'},
|
|
|
|
]"
|
|
|
|
/>
|
2019-06-23 03:35:23 -07:00
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</div>
|
|
|
|
|
2021-12-15 04:16:53 -08:00
|
|
|
<n8n-tooltip v-for="(webhook, index) in webhooksNode" :key="index" class="item" :content="$locale.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">
|
2022-06-20 12:39:24 -07:00
|
|
|
{{getWebhookExpressionValue(webhook, 'httpMethod')}}<br />
|
2019-06-23 03:35:23 -07:00
|
|
|
</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,
|
|
|
|
} 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 {
|
2022-06-20 12:39:24 -07:00
|
|
|
const webhookUrl = this.getWebhookUrlDisplay(webhookData);
|
2019-06-23 03:35:23 -07:00
|
|
|
this.copyToClipboard(webhookUrl);
|
|
|
|
|
|
|
|
this.$showMessage({
|
2021-12-15 04:16:53 -08:00
|
|
|
title: this.$locale.baseText('nodeWebhooks.showMessage.title'),
|
2019-06-23 03:35:23 -07:00
|
|
|
type: 'success',
|
|
|
|
});
|
2022-06-20 12:39:24 -07:00
|
|
|
this.$telemetry.track('User copied webhook URL', {
|
|
|
|
pane: 'parameters',
|
|
|
|
type: `${this.showUrlFor} url`,
|
|
|
|
});
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
2021-08-21 05:11:32 -07:00
|
|
|
getWebhookUrlDisplay (webhookData: IWebhookDescription): string {
|
2022-06-20 12:39:24 -07:00
|
|
|
if (this.node) {
|
|
|
|
return this.getWebhookUrl(webhookData, this.node, this.showUrlFor);
|
|
|
|
}
|
|
|
|
return '';
|
2021-08-21 05:11:32 -07:00
|
|
|
},
|
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;
|
2022-07-26 03:45:55 -07:00
|
|
|
border-bottom: 1px solid var(--color-text-lighter);
|
2019-06-23 03:35:23 -07:00
|
|
|
|
|
|
|
.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 {
|
2022-06-20 12:39:24 -07:00
|
|
|
background-color: var(--color-foreground-xdark);
|
2019-06-23 03:35:23 -07:00
|
|
|
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);
|
2022-07-26 03:45:55 -07:00
|
|
|
color: var(--color-foreground-xlight);
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
.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;
|
2022-07-26 03:45:55 -07:00
|
|
|
color: var(--color-text-dark);
|
2019-06-23 03:35:23 -07:00
|
|
|
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);
|
2022-07-26 03:45:55 -07:00
|
|
|
background-color: var(--color-foreground-xlight);
|
2019-06-23 03:35:23 -07:00
|
|
|
border-radius: 3px;
|
|
|
|
}
|
|
|
|
</style>
|