feat(selection): Conditionally hide "Convert to Subgraph" button

Implements the feature from issue #4866.

The "Convert to Subgraph" button in the selection toolbox is now hidden under the following conditions:
- The selection consists only of group nodes.
- A single SubgraphNode is selected.

This prevents users from attempting to convert invalid selections into subgraphs.
This commit is contained in:
bymyself
2025-08-12 15:15:21 -07:00
parent ef1852d551
commit 6fcf5c8348

View File

@@ -34,7 +34,7 @@ import Button from 'primevue/button'
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { SubgraphNode } from '@/lib/litegraph/src/litegraph'
import { LGraphGroup, SubgraphNode } from '@/lib/litegraph/src/litegraph'
import { useCommandStore } from '@/stores/commandStore'
import { useCanvasStore } from '@/stores/graphStore'
@@ -48,7 +48,25 @@ const isUnpackVisible = computed(() => {
canvasStore.selectedItems[0] instanceof SubgraphNode
)
})
const isConvertVisible = computed(() => {
const items = canvasStore.selectedItems
if (!items || items.length === 0) {
return false
}
// Unpack button takes precedence for single subgraph node
if (items.length === 1 && items[0] instanceof SubgraphNode) {
return false
}
// Hide if ALL selected items are groups
const allAreGroups = items.every((item) => item instanceof LGraphGroup)
if (allAreGroups) {
return false
}
// Otherwise, show it, assuming there's some selection
return (
canvasStore.groupSelected ||
canvasStore.rerouteSelected ||