## Summary Provide details about your pull request and what it adds, fixes, or changes. Photos and videos are recommended. As part of NodeView refactor, this PR migrates all externalHooks calls to `useExternalHooks` composable. #### How to test the change: 1. Run using env `export N8N_DEPLOYMENT_TYPE=cloud` 2. Hooks should still run as expected ## Issues fixed Include links to Github issue or Community forum post or **Linear ticket**: > Important in order to close automatically and provide context to reviewers https://linear.app/n8n/issue/N8N-6349/externalhooks ## Review / Merge checklist - [x] PR title and summary are descriptive. **Remember, the title automatically goes into the changelog. Use `(no-changelog)` otherwise.** ([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md)) - [x] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up ticket created. - [x] Tests included. > A bug is not considered fixed, unless a test is added to prevent it from happening again. A feature is not complete without tests. > > *(internal)* You can use Slack commands to trigger [e2e tests](https://www.notion.so/n8n/How-to-use-Test-Instances-d65f49dfc51f441ea44367fb6f67eb0a?pvs=4#a39f9e5ba64a48b58a71d81c837e8227) or [deploy test instance](https://www.notion.so/n8n/How-to-use-Test-Instances-d65f49dfc51f441ea44367fb6f67eb0a?pvs=4#f6a177d32bde4b57ae2da0b8e454bfce) or [deploy early access version on Cloud](https://www.notion.so/n8n/Cloudbot-3dbe779836004972b7057bc989526998?pvs=4#fef2d36ab02247e1a0f65a74f6fb534e).
184 lines
4.6 KiB
Vue
184 lines
4.6 KiB
Vue
<template>
|
|
<div class="item">
|
|
<div v-if="item.options" class="options">
|
|
<div v-if="item.options.length" class="headline clickable" @click="extended = !extended">
|
|
<div class="options-toggle" v-if="extendAll !== true">
|
|
<font-awesome-icon v-if="extended" icon="angle-down" />
|
|
<font-awesome-icon v-else icon="angle-right" />
|
|
</div>
|
|
<div class="option-title" :title="item.key">
|
|
{{ item.name }}
|
|
|
|
<el-dropdown
|
|
trigger="click"
|
|
@click.stop
|
|
@command="optionSelected($event, item)"
|
|
v-if="allowParentSelect === true"
|
|
>
|
|
<span class="el-dropdown-link clickable" @click.stop>
|
|
<font-awesome-icon
|
|
icon="dot-circle"
|
|
:title="$locale.baseText('variableSelectorItem.selectItem')"
|
|
/>
|
|
</span>
|
|
<template #dropdown>
|
|
<el-dropdown-menu>
|
|
<el-dropdown-item
|
|
:command="operation.command"
|
|
v-for="operation in itemAddOperations"
|
|
:key="operation.command"
|
|
>{{ operation.displayName }}</el-dropdown-item
|
|
>
|
|
</el-dropdown-menu>
|
|
</template>
|
|
</el-dropdown>
|
|
</div>
|
|
</div>
|
|
<div v-if="item.options && (extended === true || extendAll === true)">
|
|
<variable-selector-item
|
|
v-for="option in item.options"
|
|
:item="option"
|
|
:key="option.key"
|
|
:extendAll="extendAll"
|
|
:allowParentSelect="option.allowParentSelect"
|
|
:redactValues="redactValues"
|
|
class="sub-level"
|
|
@itemSelected="forwardItemSelected"
|
|
></variable-selector-item>
|
|
</div>
|
|
</div>
|
|
<div v-else class="value clickable" @click="selectItem(item)">
|
|
<div class="item-title" :title="item.key">
|
|
{{ item.name }}:
|
|
<font-awesome-icon icon="dot-circle" title="Select Item" />
|
|
</div>
|
|
<div :class="{ 'ph-no-capture': redactValues, 'item-value': true }">
|
|
{{ item.value !== undefined ? item.value : $locale.baseText('variableSelectorItem.empty') }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent } from 'vue';
|
|
import type { IVariableSelectorOption, IVariableItemSelected } from '@/Interface';
|
|
|
|
export default defineComponent({
|
|
name: 'VariableSelectorItem',
|
|
props: ['allowParentSelect', 'extendAll', 'item', 'redactValues'],
|
|
mounted() {
|
|
if (this.extended) return;
|
|
|
|
const shouldAutoExtend =
|
|
[
|
|
this.$locale.baseText('variableSelectorItem.currentNode'),
|
|
this.$locale.baseText('variableSelectorItem.inputData'),
|
|
this.$locale.baseText('variableSelectorItem.binary'),
|
|
this.$locale.baseText('variableSelectorItem.json'),
|
|
].includes(this.item.name) && this.item.key === undefined;
|
|
|
|
if (shouldAutoExtend) {
|
|
this.extended = true;
|
|
}
|
|
},
|
|
computed: {
|
|
itemAddOperations() {
|
|
const returnOptions = [
|
|
{
|
|
command: 'raw',
|
|
displayName: 'Raw value',
|
|
},
|
|
];
|
|
if (this.item.dataType === 'array') {
|
|
returnOptions.push({
|
|
command: 'arrayLength',
|
|
displayName: 'Length',
|
|
});
|
|
returnOptions.push({
|
|
command: 'arrayValues',
|
|
displayName: 'Values',
|
|
});
|
|
} else if (this.item.dataType === 'object') {
|
|
returnOptions.push({
|
|
command: 'objectKeys',
|
|
displayName: 'Keys',
|
|
});
|
|
returnOptions.push({
|
|
command: 'objectValues',
|
|
displayName: 'Values',
|
|
});
|
|
}
|
|
|
|
return returnOptions;
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
extended: false,
|
|
};
|
|
},
|
|
methods: {
|
|
optionSelected(command: string, item: IVariableSelectorOption) {
|
|
// By default it is raw
|
|
let variable = item.key;
|
|
if (command === 'arrayValues') {
|
|
variable = `${item.key}.join(', ')`;
|
|
} else if (command === 'arrayLength') {
|
|
variable = `${item.key}.length`;
|
|
} else if (command === 'objectKeys') {
|
|
variable = `Object.keys(${item.key}).join(', ')`;
|
|
} else if (command === 'objectValues') {
|
|
variable = `Object.values(${item.key}).join(', ')`;
|
|
}
|
|
this.$emit('itemSelected', { variable });
|
|
},
|
|
selectItem(item: IVariableSelectorOption) {
|
|
this.$emit('itemSelected', { variable: item.key });
|
|
},
|
|
forwardItemSelected(eventData: IVariableItemSelected) {
|
|
this.$emit('itemSelected', eventData);
|
|
},
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.option-title {
|
|
position: relative;
|
|
display: inline-block;
|
|
font-size: 0.9em;
|
|
font-weight: 600;
|
|
padding: 0.2em 1em 0.2em 0.4em;
|
|
}
|
|
.item-title {
|
|
font-weight: 600;
|
|
font-size: 0.8em;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.headline {
|
|
position: relative;
|
|
margin: 2px;
|
|
margin-top: 10px;
|
|
color: $color-primary;
|
|
}
|
|
.options-toggle {
|
|
position: relative;
|
|
top: 1px;
|
|
margin: 0 3px 0 8px;
|
|
display: inline;
|
|
}
|
|
.value {
|
|
margin: 0.2em;
|
|
padding: 0.1em 0.3em;
|
|
}
|
|
.item-value {
|
|
font-size: 0.6em;
|
|
overflow-x: auto;
|
|
}
|
|
.sub-level {
|
|
padding-left: 20px;
|
|
}
|
|
</style>
|