From b00aca1af0b3009b82bf41daa77e3e3215452823 Mon Sep 17 00:00:00 2001 From: AustinMroz Date: Fri, 10 Oct 2025 14:07:39 -0700 Subject: [PATCH] [Backport 1.28] Allow reordering of linked subgraph widgets (#6009) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Manual backport of #5981 to `core/1.28` Requires minor styling change since theme code will not be backported. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6009-Backport-1-28-Allow-reordering-of-linked-subgraph-widgets-2886d73d36508125a125e8acc8ae08a7) by [Unito](https://www.unito.io) --- src/core/graph/subgraph/SubgraphNode.vue | 62 +++++++++---------- .../graph/subgraph/SubgraphNodeWidget.vue | 16 +++-- src/core/graph/subgraph/proxyWidget.ts | 48 +++++++++----- src/core/graph/subgraph/proxyWidgetUtils.ts | 8 ++- tests-ui/tests/widgets/proxyWidget.test.ts | 23 ++++--- 5 files changed, 92 insertions(+), 65 deletions(-) diff --git a/src/core/graph/subgraph/SubgraphNode.vue b/src/core/graph/subgraph/SubgraphNode.vue index f163df53f..a582f6d3f 100644 --- a/src/core/graph/subgraph/SubgraphNode.vue +++ b/src/core/graph/subgraph/SubgraphNode.vue @@ -66,15 +66,21 @@ const activeNode = computed(() => { const activeWidgets = computed({ get() { + if (!activeNode.value) return [] const node = activeNode.value - if (!node) return [] - return proxyWidgets.value.flatMap(([id, name]: [string, string]) => { + function mapWidgets([id, name]: [string, string]): WidgetItem[] { + if (id === '-1') { + const widget = node.widgets.find((w) => w.name === name) + if (!widget) return [] + return [[{ id: -1, title: '(Linked)', type: '' }, widget]] + } const wNode = node.subgraph._nodes_by_id[id] if (!wNode?.widgets) return [] - const w = wNode.widgets.find((w) => w.name === name) - if (!w) return [] - return [[wNode, w]] - }) + const widget = wNode.widgets.find((w) => w.name === name) + if (!widget) return [] + return [[wNode, widget]] + } + return proxyWidgets.value.flatMap(mapWidgets) }, set(value: WidgetItem[]) { const node = activeNode.value @@ -82,9 +88,7 @@ const activeWidgets = computed({ console.error('Attempted to toggle widgets with no node selected') return } - //map back to id/name - const widgets: ProxyWidgetsProperty = value.map(widgetItemToProperty) - proxyWidgets.value = widgets + proxyWidgets.value = value.map(widgetItemToProperty) } }) @@ -167,10 +171,10 @@ function showAll() { function hideAll() { const node = activeNode.value if (!node) return //Not reachable - //Not great from a nesting perspective, but path is cold - //and it cleans up potential error states proxyWidgets.value = proxyWidgets.value.filter( - (widgetItem) => !filteredActive.value.some(matchesWidgetItem(widgetItem)) + (propertyItem) => + !filteredActive.value.some(matchesWidgetItem(propertyItem)) || + propertyItem[0] === '-1' ) } function showRecommended() { @@ -260,20 +264,16 @@ onBeforeUnmount(() => { >
-
- -
+ :node-title="node.title" + :widget-name="widget.name" + :is-shown="true" + :is-draggable="!debouncedQuery" + :is-physical="node.id === -1" + @toggle-visibility="demote([node, widget])" + />
@@ -288,17 +288,13 @@ onBeforeUnmount(() => { {{ $t('subgraphStore.showAll') }}
-
- -
+ :node-title="node.title" + :widget-name="widget.name" + @toggle-visibility="promote([node, widget])" + />
() defineEmits<{ (e: 'toggleVisibility'): void @@ -17,11 +18,17 @@ function classes() { return cn( 'flex py-1 pr-4 pl-0 break-all rounded items-center gap-1', 'bg-pure-white dark-theme:bg-charcoal-800', - props.isDraggable - ? 'drag-handle cursor-grab [.is-draggable]:cursor-grabbing' - : '' + props.isDraggable && + 'draggable-item drag-handle cursor-grab [.is-draggable]:cursor-grabbing' ) } +function getIcon() { + return props.isPhysical + ? 'icon-[lucide--link]' + : props.isDraggable + ? 'icon-[lucide--eye]' + : 'icon-[lucide--eye-off]' +}