mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 12:44:07 -08:00
feat(editor): Update Node Details View header tabs structure (#9425)
Co-authored-by: Elias Meire <elias@meire.dev>
This commit is contained in:
parent
a7d3e59aef
commit
2782534d78
|
@ -22,7 +22,7 @@
|
|||
v-if="tooltipText && label"
|
||||
:class="[$style.infoIcon, showTooltip ? $style.visible : $style.hidden]"
|
||||
>
|
||||
<N8nTooltip placement="top" :popper-class="$style.tooltipPopper">
|
||||
<N8nTooltip placement="top" :popper-class="$style.tooltipPopper" :show-after="300">
|
||||
<N8nIcon icon="question-circle" size="small" />
|
||||
<template #content>
|
||||
<div v-html="addTargetBlank(tooltipText)" />
|
||||
|
@ -90,6 +90,10 @@ const addTargetBlank = (html: string) =>
|
|||
.inputLabel:hover {
|
||||
.infoIcon {
|
||||
opacity: 1;
|
||||
|
||||
&:hover {
|
||||
color: var(--color-text-base);
|
||||
}
|
||||
}
|
||||
|
||||
.options {
|
||||
|
@ -117,7 +121,7 @@ const addTargetBlank = (html: string) =>
|
|||
display: flex;
|
||||
align-items: center;
|
||||
color: var(--color-text-light);
|
||||
padding-left: var(--spacing-4xs);
|
||||
margin-left: var(--spacing-4xs);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
>
|
||||
<div>
|
||||
{{ option.label }}
|
||||
<span :class="$style.external"
|
||||
><N8nIcon icon="external-link-alt" size="small"
|
||||
/></span>
|
||||
<span :class="$style.external">
|
||||
<N8nIcon icon="external-link-alt" size="xsmall" />
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
<RouterLink
|
||||
|
@ -45,7 +45,7 @@
|
|||
:data-test-id="`tab-${option.value}`"
|
||||
@click="() => handleTabClick(option.value)"
|
||||
>
|
||||
<N8nIcon v-if="option.icon" :icon="option.icon" size="medium" />
|
||||
<N8nIcon v-if="option.icon" :icon="option.icon" size="small" />
|
||||
<span v-if="option.label">{{ option.label }}</span>
|
||||
</div>
|
||||
</n8n-tooltip>
|
||||
|
@ -140,6 +140,7 @@ const scrollRight = () => scroll(50);
|
|||
color: var(--color-text-base);
|
||||
font-weight: var(--font-weight-bold);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
overflow-x: scroll;
|
||||
|
@ -155,9 +156,10 @@ const scrollRight = () => scroll(50);
|
|||
}
|
||||
|
||||
.tab {
|
||||
--active-tab-border-width: 2px;
|
||||
display: block;
|
||||
padding: 0 var(--spacing-s) var(--spacing-2xs) var(--spacing-s);
|
||||
padding-bottom: var(--spacing-2xs);
|
||||
padding: 0 var(--spacing-s);
|
||||
padding-bottom: calc(var(--spacing-2xs) + var(--active-tab-border-width));
|
||||
font-size: var(--font-size-s);
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
|
@ -165,14 +167,19 @@ const scrollRight = () => scroll(50);
|
|||
&:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
span + span {
|
||||
margin-left: var(--spacing-4xs);
|
||||
}
|
||||
}
|
||||
|
||||
.activeTab {
|
||||
color: var(--color-primary);
|
||||
border-bottom: var(--color-primary) 2px solid;
|
||||
padding-bottom: var(--spacing-2xs);
|
||||
border-bottom: var(--color-primary) var(--active-tab-border-width) solid;
|
||||
}
|
||||
|
||||
.alignRight {
|
||||
.alignRight:not(.alignRight + .alignRight) {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
|
@ -182,15 +189,12 @@ const scrollRight = () => scroll(50);
|
|||
|
||||
&:hover {
|
||||
color: var(--color-primary);
|
||||
|
||||
.external {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.external {
|
||||
display: none;
|
||||
display: inline-block;
|
||||
margin-left: var(--spacing-5xs);
|
||||
}
|
||||
|
||||
.button {
|
||||
|
|
|
@ -31,9 +31,10 @@
|
|||
</div>
|
||||
<NodeSettingsTabs
|
||||
v-if="node && nodeValid"
|
||||
v-model="openPanel"
|
||||
:model-value="openPanel"
|
||||
:node-type="nodeType"
|
||||
:push-ref="pushRef"
|
||||
@update:model-value="onTabSelect"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="node && !nodeValid" class="node-is-not-valid">
|
||||
|
@ -126,7 +127,7 @@
|
|||
<n8n-notice
|
||||
:content="
|
||||
$locale.baseText('nodeSettings.useTheHttpRequestNode', {
|
||||
interpolate: { nodeTypeDisplayName: nodeType.displayName },
|
||||
interpolate: { nodeTypeDisplayName: nodeType?.displayName ?? '' },
|
||||
})
|
||||
"
|
||||
/>
|
||||
|
@ -186,6 +187,7 @@ import type {
|
|||
INodeProperties,
|
||||
NodeParameterValue,
|
||||
ConnectionTypes,
|
||||
NodeParameterValueType,
|
||||
} from 'n8n-workflow';
|
||||
import {
|
||||
NodeHelpers,
|
||||
|
@ -357,16 +359,16 @@ export default defineComponent({
|
|||
return [];
|
||||
}
|
||||
|
||||
return this.nodeType.properties;
|
||||
return this.nodeType?.properties ?? [];
|
||||
},
|
||||
outputPanelEditMode(): { enabled: boolean; value: string } {
|
||||
return this.ndvStore.outputPanelEditMode;
|
||||
},
|
||||
isCommunityNode(): boolean {
|
||||
return isCommunityPackageName(this.node?.type);
|
||||
return !!this.node && isCommunityPackageName(this.node.type);
|
||||
},
|
||||
isTriggerNode(): boolean {
|
||||
return this.nodeTypesStore.isTriggerNode(this.node?.type);
|
||||
return !!this.node && this.nodeTypesStore.isTriggerNode(this.node.type);
|
||||
},
|
||||
workflowOwnerName(): string {
|
||||
return this.workflowsEEStore.getWorkflowOwnerName(`${this.workflowsStore.workflowId}`);
|
||||
|
@ -425,7 +427,7 @@ export default defineComponent({
|
|||
return {
|
||||
nodeValid: true,
|
||||
nodeColor: null,
|
||||
openPanel: 'params',
|
||||
openPanel: 'params' as 'params' | 'settings',
|
||||
nodeValues: {
|
||||
color: '#ff0000',
|
||||
alwaysOutputData: false,
|
||||
|
@ -466,10 +468,10 @@ export default defineComponent({
|
|||
importCurlEventBus.off('setHttpNodeParameters', this.setHttpNodeParameters);
|
||||
},
|
||||
methods: {
|
||||
setHttpNodeParameters(parameters: Record<string, unknown>) {
|
||||
setHttpNodeParameters(parameters: NodeParameterValueType) {
|
||||
try {
|
||||
this.valueChanged({
|
||||
node: this.node.name,
|
||||
node: this.node?.name,
|
||||
name: 'parameters',
|
||||
value: parameters,
|
||||
});
|
||||
|
@ -649,8 +651,10 @@ export default defineComponent({
|
|||
// Data is on top level
|
||||
if (value === null) {
|
||||
// Property should be deleted
|
||||
if (lastNamePart) {
|
||||
const { [lastNamePart]: removedNodeValue, ...remainingNodeValues } = this.nodeValues;
|
||||
this.nodeValues = remainingNodeValues;
|
||||
}
|
||||
} else {
|
||||
// Value should be set
|
||||
this.nodeValues = {
|
||||
|
@ -666,18 +670,22 @@ export default defineComponent({
|
|||
| INodeParameters
|
||||
| INodeParameters[];
|
||||
|
||||
if (lastNamePart && !Array.isArray(tempValue)) {
|
||||
const { [lastNamePart]: removedNodeValue, ...remainingNodeValues } = tempValue;
|
||||
tempValue = remainingNodeValues;
|
||||
}
|
||||
|
||||
if (isArray && (tempValue as INodeParameters[]).length === 0) {
|
||||
if (isArray && Array.isArray(tempValue) && tempValue.length === 0) {
|
||||
// If a value from an array got delete and no values are left
|
||||
// delete also the parent
|
||||
lastNamePart = nameParts.pop();
|
||||
tempValue = get(this.nodeValues, nameParts.join('.')) as INodeParameters;
|
||||
if (lastNamePart) {
|
||||
const { [lastNamePart]: removedArrayNodeValue, ...remainingArrayNodeValues } =
|
||||
tempValue;
|
||||
tempValue = remainingArrayNodeValues;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Value should be set
|
||||
if (typeof value === 'object') {
|
||||
|
@ -734,6 +742,11 @@ export default defineComponent({
|
|||
// Save the node name before we commit the change because
|
||||
// we need the old name to rename the node properly
|
||||
const nodeNameBefore = parameterData.node || this.node?.name;
|
||||
|
||||
if (!nodeNameBefore) {
|
||||
return;
|
||||
}
|
||||
|
||||
const node = this.workflowsStore.getNodeByName(nodeNameBefore);
|
||||
|
||||
if (node === null) {
|
||||
|
@ -776,6 +789,7 @@ export default defineComponent({
|
|||
// we do not edit it directly
|
||||
nodeParameters = deepCopy(nodeParameters);
|
||||
|
||||
if (parameterData.value && typeof parameterData.value === 'object') {
|
||||
for (const parameterName of Object.keys(parameterData.value)) {
|
||||
//@ts-ignore
|
||||
newValue = parameterData.value[parameterName];
|
||||
|
@ -815,6 +829,7 @@ export default defineComponent({
|
|||
oldNodeParameters,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Get the parameters with the now new defaults according to the
|
||||
// from the user actually defined parameters
|
||||
|
@ -1144,6 +1159,9 @@ export default defineComponent({
|
|||
openSettings() {
|
||||
this.openPanel = 'settings';
|
||||
},
|
||||
onTabSelect(tab: 'params' | 'settings') {
|
||||
this.openPanel = tab;
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<n8n-tabs
|
||||
<N8nTabs
|
||||
:options="options"
|
||||
:model-value="modelValue"
|
||||
@update:model-value="onTabSelect"
|
||||
|
@ -7,48 +7,60 @@
|
|||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
<script setup lang="ts">
|
||||
import type { ITab } from '@/Interface';
|
||||
import {
|
||||
BUILTIN_NODES_DOCS_URL,
|
||||
COMMUNITY_NODES_INSTALLATION_DOCS_URL,
|
||||
NPM_PACKAGE_DOCS_BASE_URL,
|
||||
} from '@/constants';
|
||||
import type { INodeUi, ITab } from '@/Interface';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import type { INodeTypeDescription } from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { isCommunityPackageName } from '@/utils/nodeTypesUtils';
|
||||
import { useExternalHooks } from '@/composables/useExternalHooks';
|
||||
import { useI18n } from '@/composables/useI18n';
|
||||
import { useTelemetry } from '@/composables/useTelemetry';
|
||||
import { isCommunityPackageName } from '@/utils/nodeTypesUtils';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'NodeSettingsTabs',
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
nodeType: {},
|
||||
pushRef: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
const externalHooks = useExternalHooks();
|
||||
return {
|
||||
externalHooks,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useNDVStore, useWorkflowsStore),
|
||||
activeNode(): INodeUi | null {
|
||||
return this.ndvStore.activeNode;
|
||||
},
|
||||
documentationUrl(): string {
|
||||
const nodeType = this.nodeType as INodeTypeDescription | null;
|
||||
type Tab = 'settings' | 'params';
|
||||
type Props = {
|
||||
modelValue?: Tab;
|
||||
nodeType?: INodeTypeDescription;
|
||||
pushRef?: string;
|
||||
};
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: 'params',
|
||||
nodeType: undefined,
|
||||
pushRef: '',
|
||||
});
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:model-value', tab: Tab): void;
|
||||
}>();
|
||||
|
||||
const externalHooks = useExternalHooks();
|
||||
const ndvStore = useNDVStore();
|
||||
const workflowsStore = useWorkflowsStore();
|
||||
const i18n = useI18n();
|
||||
const telemetry = useTelemetry();
|
||||
|
||||
const activeNode = computed(() => ndvStore.activeNode);
|
||||
|
||||
const isCommunityNode = computed(() => {
|
||||
const nodeType = props.nodeType;
|
||||
if (nodeType) {
|
||||
return isCommunityPackageName(nodeType.name);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
const packageName = computed(() => props.nodeType?.name.split('.')[0] ?? '');
|
||||
|
||||
const documentationUrl = computed(() => {
|
||||
const nodeType = props.nodeType;
|
||||
|
||||
if (!nodeType) {
|
||||
return '';
|
||||
|
@ -58,112 +70,104 @@ export default defineComponent({
|
|||
return nodeType.documentationUrl;
|
||||
}
|
||||
|
||||
const utmTags =
|
||||
'?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link' +
|
||||
'&utm_campaign=' +
|
||||
nodeType.name;
|
||||
const utmParams = new URLSearchParams({
|
||||
utm_source: 'n8n_app',
|
||||
utm_medium: 'node_settings_modal-credential_link',
|
||||
utm_campaign: nodeType.name,
|
||||
});
|
||||
|
||||
// Built-in node documentation available via its codex entry
|
||||
const primaryDocUrl = nodeType.codex?.resources?.primaryDocumentation?.[0]?.url;
|
||||
if (primaryDocUrl) {
|
||||
return primaryDocUrl + utmTags;
|
||||
return `${primaryDocUrl}?${utmParams.toString()}`;
|
||||
}
|
||||
|
||||
if (this.isCommunityNode) {
|
||||
return `${NPM_PACKAGE_DOCS_BASE_URL}${nodeType.name.split('.')[0]}`;
|
||||
if (isCommunityNode.value) {
|
||||
return `${NPM_PACKAGE_DOCS_BASE_URL}${packageName.value}`;
|
||||
}
|
||||
|
||||
// Fallback to the root of the node documentation
|
||||
return BUILTIN_NODES_DOCS_URL + utmTags;
|
||||
},
|
||||
isCommunityNode(): boolean {
|
||||
const nodeType = this.nodeType as INodeTypeDescription | null;
|
||||
if (nodeType) {
|
||||
return isCommunityPackageName(nodeType.name);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
packageName(): string {
|
||||
const nodeType = this.nodeType as INodeTypeDescription;
|
||||
return nodeType.name.split('.')[0];
|
||||
},
|
||||
options(): ITab[] {
|
||||
return `${BUILTIN_NODES_DOCS_URL}?${utmParams.toString()}`;
|
||||
});
|
||||
|
||||
const options = computed<ITab[]>(() => {
|
||||
const options: ITab[] = [
|
||||
{
|
||||
label: this.$locale.baseText('nodeSettings.parameters'),
|
||||
label: i18n.baseText('nodeSettings.parameters'),
|
||||
value: 'params',
|
||||
},
|
||||
{
|
||||
label: i18n.baseText('nodeSettings.settings'),
|
||||
value: 'settings',
|
||||
},
|
||||
];
|
||||
if (this.documentationUrl) {
|
||||
options.push({
|
||||
label: this.$locale.baseText('nodeSettings.docs'),
|
||||
value: 'docs',
|
||||
href: this.documentationUrl,
|
||||
});
|
||||
}
|
||||
if (this.isCommunityNode) {
|
||||
|
||||
if (isCommunityNode.value) {
|
||||
options.push({
|
||||
icon: 'cube',
|
||||
value: 'communityNode',
|
||||
align: 'right',
|
||||
tooltip: this.$locale.baseText('generic.communityNode.tooltip', {
|
||||
tooltip: i18n.baseText('generic.communityNode.tooltip', {
|
||||
interpolate: {
|
||||
docUrl: COMMUNITY_NODES_INSTALLATION_DOCS_URL,
|
||||
packageName: this.packageName,
|
||||
packageName: packageName.value,
|
||||
},
|
||||
}),
|
||||
});
|
||||
}
|
||||
// If both tabs have align right, both will have excessive left margin
|
||||
const pushCogRight = this.isCommunityNode ? false : true;
|
||||
|
||||
if (documentationUrl.value) {
|
||||
options.push({
|
||||
icon: 'cog',
|
||||
value: 'settings',
|
||||
align: pushCogRight ? 'right' : undefined,
|
||||
label: i18n.baseText('nodeSettings.docs'),
|
||||
value: 'docs',
|
||||
href: documentationUrl.value,
|
||||
align: 'right',
|
||||
});
|
||||
}
|
||||
|
||||
return options;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onTabSelect(tab: string) {
|
||||
if (tab === 'docs' && this.nodeType) {
|
||||
void this.externalHooks.run('dataDisplay.onDocumentationUrlClick', {
|
||||
nodeType: this.nodeType as INodeTypeDescription,
|
||||
documentationUrl: this.documentationUrl,
|
||||
});
|
||||
|
||||
function onTabSelect(tab: string) {
|
||||
if (tab === 'docs' && props.nodeType) {
|
||||
void externalHooks.run('dataDisplay.onDocumentationUrlClick', {
|
||||
nodeType: props.nodeType,
|
||||
documentationUrl: documentationUrl.value,
|
||||
});
|
||||
this.$telemetry.track('User clicked ndv link', {
|
||||
node_type: this.activeNode.type,
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
push_ref: this.pushRef,
|
||||
|
||||
telemetry.track('User clicked ndv link', {
|
||||
node_type: activeNode.value?.type,
|
||||
workflow_id: workflowsStore.workflowId,
|
||||
push_ref: props.pushRef,
|
||||
pane: NodeConnectionType.Main,
|
||||
type: 'docs',
|
||||
});
|
||||
}
|
||||
|
||||
if (tab === 'settings' && this.nodeType) {
|
||||
this.$telemetry.track('User viewed node settings', {
|
||||
node_type: (this.nodeType as INodeTypeDescription).name,
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
if (tab === 'settings' && props.nodeType) {
|
||||
telemetry.track('User viewed node settings', {
|
||||
node_type: props.nodeType.name,
|
||||
workflow_id: workflowsStore.workflowId,
|
||||
});
|
||||
}
|
||||
|
||||
if (tab === 'settings' || tab === 'params') {
|
||||
this.$emit('update:modelValue', tab);
|
||||
emit('update:model-value', tab);
|
||||
}
|
||||
},
|
||||
onTooltipClick(tab: string, event: MouseEvent) {
|
||||
}
|
||||
|
||||
function onTooltipClick(tab: string, event: MouseEvent) {
|
||||
if (tab === 'communityNode' && (event.target as Element).localName === 'a') {
|
||||
this.$telemetry.track('user clicked cnr docs link', { source: 'node details view' });
|
||||
telemetry.track('user clicked cnr docs link', { source: 'node details view' });
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
#communityNode > div {
|
||||
cursor: auto;
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
|
||||
&:hover {
|
||||
color: unset;
|
||||
|
|
|
@ -1122,6 +1122,7 @@
|
|||
"nodeSettings.notesInFlow.description": "If active, the note above will display in the flow as a subtitle",
|
||||
"nodeSettings.notesInFlow.displayName": "Display Note in Flow?",
|
||||
"nodeSettings.parameters": "Parameters",
|
||||
"nodeSettings.settings": "Settings",
|
||||
"nodeSettings.communityNodeTooltip": "This is a <a href=\"{docUrl}\" target=\"_blank\"/>community node</a>",
|
||||
"nodeSettings.retryOnFail.description": "If active, the node tries to execute again when it fails",
|
||||
"nodeSettings.retryOnFail.displayName": "Retry On Fail",
|
||||
|
|
Loading…
Reference in a new issue