feat(editor): Add item selector to expression output (#9281)

This commit is contained in:
Elias Meire
2024-05-09 14:45:31 +02:00
committed by GitHub
parent 1c1e4443f4
commit dc5994b185
20 changed files with 313 additions and 98 deletions

View File

@@ -10,6 +10,7 @@ import { useStorage } from '@/composables/useStorage';
import {
LOCAL_STORAGE_AUTOCOMPLETE_IS_ONBOARDED,
LOCAL_STORAGE_MAPPING_IS_ONBOARDED,
LOCAL_STORAGE_TABLE_HOVER_IS_ONBOARDED,
STORES,
} from '@/constants';
import type { INodeExecutionData, INodeIssues } from 'n8n-workflow';
@@ -47,6 +48,7 @@ export const useNDVStore = defineStore(STORES.NDV, {
focusedInputPath: '',
mappingTelemetry: {},
hoveringItem: null,
expressionOutputItemIndex: 0,
draggable: {
isDragging: false,
type: '',
@@ -55,6 +57,7 @@ export const useNDVStore = defineStore(STORES.NDV, {
activeTarget: null,
},
isMappingOnboarded: useStorage(LOCAL_STORAGE_MAPPING_IS_ONBOARDED).value === 'true',
isTableHoverOnboarded: useStorage(LOCAL_STORAGE_TABLE_HOVER_IS_ONBOARDED).value === 'true',
isAutocompleteOnboarded: useStorage(LOCAL_STORAGE_AUTOCOMPLETE_IS_ONBOARDED).value === 'true',
highlightDraggables: false,
}),
@@ -79,14 +82,20 @@ export const useNDVStore = defineStore(STORES.NDV, {
return [];
}
return executionData.data?.resultData?.runData?.[inputNodeName]?.[inputRunIndex]?.data
?.main?.[inputBranchIndex];
return (
executionData.data?.resultData?.runData?.[inputNodeName]?.[inputRunIndex]?.data?.main?.[
inputBranchIndex
] ?? []
);
},
ndvInputDataWithPinnedData(): INodeExecutionData[] {
const data = this.ndvInputData;
return this.ndvInputNodeName
? useWorkflowsStore().pinDataByNodeName(this.ndvInputNodeName) ?? data
: data;
},
hasInputData(): boolean {
const data = this.ndvInputData;
const pinData =
this.ndvInputNodeName && useWorkflowsStore().pinDataByNodeName(this.ndvInputNodeName);
return !!(data && data.length > 0) || !!(pinData && pinData.length > 0);
return this.ndvInputDataWithPinnedData.length > 0;
},
getPanelDisplayMode() {
return (panel: NodePanelType) => this[panel].displayMode;
@@ -237,6 +246,7 @@ export const useNDVStore = defineStore(STORES.NDV, {
this.mappingTelemetry = {};
},
setHoveringItem(item: null | NDVState['hoveringItem']): void {
if (item) this.setTableHoverOnboarded();
this.hoveringItem = item;
},
setNDVBranchIndex(e: { pane: 'input' | 'output'; branchIndex: number }): void {
@@ -249,6 +259,10 @@ export const useNDVStore = defineStore(STORES.NDV, {
this.isMappingOnboarded = true;
useStorage(LOCAL_STORAGE_MAPPING_IS_ONBOARDED).value = 'true';
},
setTableHoverOnboarded() {
this.isTableHoverOnboarded = true;
useStorage(LOCAL_STORAGE_TABLE_HOVER_IS_ONBOARDED).value = 'true';
},
setAutocompleteOnboarded() {
this.isAutocompleteOnboarded = true;
useStorage(LOCAL_STORAGE_AUTOCOMPLETE_IS_ONBOARDED).value = 'true';