refactor(editor): Fix types issues in src/components/Node/* (no-changelog) (#9444)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="data"
|
||||
:id="nodeId"
|
||||
:ref="data.name"
|
||||
:class="nodeWrapperClass"
|
||||
@@ -262,6 +263,16 @@ export default defineComponent({
|
||||
callDebounced,
|
||||
};
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isTouchActive: false,
|
||||
nodeSubtitle: '',
|
||||
showTriggerNodeTooltip: false,
|
||||
pinDataDiscoveryTooltipVisible: false,
|
||||
dragging: false,
|
||||
unwatchWorkflowDataItems: () => {},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useNodeTypesStore, useNDVStore, useUIStore, useWorkflowsStore),
|
||||
showPinnedDataInfo(): boolean {
|
||||
@@ -325,6 +336,7 @@ export default defineComponent({
|
||||
return !!this.nodeType?.polling;
|
||||
},
|
||||
isExecuting(): boolean {
|
||||
if (!this.data) return false;
|
||||
return this.workflowsStore.isNodeExecuting(this.data.name);
|
||||
},
|
||||
isSingleActiveTriggerNode(): boolean {
|
||||
@@ -336,12 +348,15 @@ export default defineComponent({
|
||||
return nodes.length === 1;
|
||||
},
|
||||
isManualTypeNode(): boolean {
|
||||
return this.data.type === MANUAL_TRIGGER_NODE_TYPE;
|
||||
return this.data?.type === MANUAL_TRIGGER_NODE_TYPE;
|
||||
},
|
||||
isConfigNode(): boolean {
|
||||
return this.nodeTypesStore.isConfigNode(this.workflow, this.data, this.data?.type ?? '');
|
||||
if (!this.data) return false;
|
||||
return this.nodeTypesStore.isConfigNode(this.workflow, this.data, this.data.type ?? '');
|
||||
},
|
||||
isConfigurableNode(): boolean {
|
||||
if (!this.data) return false;
|
||||
|
||||
return this.nodeTypesStore.isConfigurableNode(
|
||||
this.workflow,
|
||||
this.data,
|
||||
@@ -365,10 +380,10 @@ export default defineComponent({
|
||||
return this.workflowsStore.nodesByName[this.name] as INodeUi | undefined;
|
||||
},
|
||||
sameTypeNodes(): INodeUi[] {
|
||||
return this.workflowsStore.allNodes.filter((node: INodeUi) => node.type === this.data.type);
|
||||
return this.workflowsStore.allNodes.filter((node: INodeUi) => node.type === this.data?.type);
|
||||
},
|
||||
nodeWrapperClass(): object {
|
||||
const classes = {
|
||||
nodeWrapperClass() {
|
||||
const classes: Record<string, boolean> = {
|
||||
'node-wrapper': true,
|
||||
'node-wrapper--trigger': this.isTriggerNode,
|
||||
'node-wrapper--configurable': this.isConfigurableNode,
|
||||
@@ -389,7 +404,7 @@ export default defineComponent({
|
||||
|
||||
return classes;
|
||||
},
|
||||
nodeWrapperStyles(): object {
|
||||
nodeWrapperStyles() {
|
||||
const styles: {
|
||||
[key: string]: string | number;
|
||||
} = {
|
||||
@@ -435,7 +450,7 @@ export default defineComponent({
|
||||
nodeClass(): object {
|
||||
return {
|
||||
'node-box': true,
|
||||
disabled: this.data.disabled,
|
||||
disabled: this.data?.disabled,
|
||||
executing: this.isExecuting,
|
||||
};
|
||||
},
|
||||
@@ -466,7 +481,7 @@ export default defineComponent({
|
||||
return issues;
|
||||
},
|
||||
nodeDisabledTitle(): string {
|
||||
return this.data.disabled
|
||||
return this.data?.disabled
|
||||
? this.$locale.baseText('node.enable')
|
||||
: this.$locale.baseText('node.disable');
|
||||
},
|
||||
@@ -476,21 +491,21 @@ export default defineComponent({
|
||||
showDisabledLinethrough(): boolean {
|
||||
return (
|
||||
!this.isConfigurableNode &&
|
||||
!!(this.data.disabled && this.inputs.length === 1 && this.outputs.length === 1)
|
||||
!!(this.data?.disabled && this.inputs.length === 1 && this.outputs.length === 1)
|
||||
);
|
||||
},
|
||||
shortNodeType(): string {
|
||||
return this.$locale.shortNodeType(this.data.type);
|
||||
return this.$locale.shortNodeType(this.data?.type ?? '');
|
||||
},
|
||||
nodeTitle(): string {
|
||||
if (this.data.name === 'Start') {
|
||||
if (this.data?.name === 'Start') {
|
||||
return this.$locale.headerText({
|
||||
key: 'headers.start.displayName',
|
||||
fallback: 'Start',
|
||||
});
|
||||
}
|
||||
|
||||
return this.data.name;
|
||||
return this.data?.name ?? '';
|
||||
},
|
||||
waiting(): string | undefined {
|
||||
const workflowExecution = this.workflowsStore.getWorkflowExecution as ExecutionSummary;
|
||||
@@ -518,7 +533,7 @@ export default defineComponent({
|
||||
workflowRunning(): boolean {
|
||||
return this.uiStore.isActionActive('workflowRunning');
|
||||
},
|
||||
nodeStyle(): object {
|
||||
nodeStyle() {
|
||||
const returnStyles: {
|
||||
[key: string]: string;
|
||||
} = {};
|
||||
@@ -529,7 +544,7 @@ export default defineComponent({
|
||||
borderColor = '--color-foreground-dark';
|
||||
}
|
||||
|
||||
if (this.data.disabled) {
|
||||
if (this.data?.disabled) {
|
||||
borderColor = '--color-foreground-base';
|
||||
} else if (!this.isExecuting) {
|
||||
if (this.hasIssues && !this.hideNodeIssues) {
|
||||
@@ -559,7 +574,7 @@ export default defineComponent({
|
||||
},
|
||||
isSelected(): boolean {
|
||||
return (
|
||||
this.uiStore.getSelectedNodes.find((node: INodeUi) => node.name === this.data.name) !==
|
||||
this.uiStore.getSelectedNodes.find((node: INodeUi) => node.name === this.data?.name) !==
|
||||
undefined
|
||||
);
|
||||
},
|
||||
@@ -668,23 +683,13 @@ export default defineComponent({
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isTouchActive: false,
|
||||
nodeSubtitle: '',
|
||||
showTriggerNodeTooltip: false,
|
||||
pinDataDiscoveryTooltipVisible: false,
|
||||
dragging: false,
|
||||
unwatchWorkflowDataItems: () => {},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
showPinDataDiscoveryTooltip(dataItemsCount: number): void {
|
||||
if (
|
||||
!this.isTriggerNode ||
|
||||
this.isManualTypeNode ||
|
||||
this.isScheduledGroup ||
|
||||
this.uiStore.isModalActive ||
|
||||
this.uiStore.isAnyModalOpen ||
|
||||
dataItemsCount === 0
|
||||
)
|
||||
return;
|
||||
@@ -695,13 +700,14 @@ export default defineComponent({
|
||||
this.unwatchWorkflowDataItems();
|
||||
},
|
||||
setSubtitle() {
|
||||
if (!this.data || !this.nodeType) return;
|
||||
// why is this not a computed property? because it's a very expensive operation
|
||||
// it requires expressions to resolve each subtitle...
|
||||
// and ends up bogging down the UI with big workflows, for example when pasting a workflow or even opening a node...
|
||||
// so we only update it when necessary (when node is mounted and when it's opened and closed (isActive))
|
||||
try {
|
||||
const nodeSubtitle =
|
||||
this.nodeHelpers.getNodeSubtitle(this.data, this.nodeType, this.workflow) || '';
|
||||
this.nodeHelpers.getNodeSubtitle(this.data, this.nodeType, this.workflow) ?? '';
|
||||
|
||||
this.nodeSubtitle = nodeSubtitle.includes(CUSTOM_API_CALL_KEY) ? '' : nodeSubtitle;
|
||||
} catch (e) {
|
||||
@@ -727,9 +733,9 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
executeNode() {
|
||||
this.$emit('runWorkflow', this.data.name, 'Node.executeNode');
|
||||
this.$emit('runWorkflow', this.data?.name, 'Node.executeNode');
|
||||
this.$telemetry.track('User clicked node hover button', {
|
||||
node_type: this.data.type,
|
||||
node_type: this.data?.type,
|
||||
button_name: 'execute',
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
});
|
||||
@@ -737,18 +743,18 @@ export default defineComponent({
|
||||
|
||||
deleteNode() {
|
||||
this.$telemetry.track('User clicked node hover button', {
|
||||
node_type: this.data.type,
|
||||
node_type: this.data?.type,
|
||||
button_name: 'delete',
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
});
|
||||
|
||||
this.$emit('removeNode', this.data.name);
|
||||
this.$emit('removeNode', this.data?.name);
|
||||
},
|
||||
|
||||
toggleDisableNode(event: MouseEvent) {
|
||||
(event.currentTarget as HTMLButtonElement).blur();
|
||||
this.$telemetry.track('User clicked node hover button', {
|
||||
node_type: this.data.type,
|
||||
node_type: this.data?.type,
|
||||
button_name: 'disable',
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
});
|
||||
@@ -759,7 +765,8 @@ export default defineComponent({
|
||||
void this.callDebounced(this.onClickDebounced, { debounceTime: 50, trailing: true }, event);
|
||||
},
|
||||
|
||||
onClickDebounced(event: MouseEvent) {
|
||||
onClickDebounced(...args: unknown[]) {
|
||||
const event = args[0] as MouseEvent;
|
||||
const isDoubleClick = event.detail >= 2;
|
||||
if (isDoubleClick) {
|
||||
this.setNodeActive();
|
||||
|
||||
Reference in New Issue
Block a user