Skip to content

Commit ceaf47c

Browse files
committed
Fix convert to subgraph shown on IO node
1 parent 085ed03 commit ceaf47c

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/components/graph/selectionToolbox/ConvertToSubgraphButton.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<Button
3+
v-show="isVisible"
34
v-tooltip.top="{
45
value: t('commands.Comfy_Graph_ConvertToSubgraph.label'),
56
showDelay: 1000
@@ -13,10 +14,21 @@
1314

1415
<script setup lang="ts">
1516
import Button from 'primevue/button'
17+
import { computed } from 'vue'
1618
import { useI18n } from 'vue-i18n'
1719
1820
import { useCommandStore } from '@/stores/commandStore'
21+
import { useCanvasStore } from '@/stores/graphStore'
1922
2023
const { t } = useI18n()
2124
const commandStore = useCommandStore()
25+
const canvasStore = useCanvasStore()
26+
27+
const isVisible = computed(() => {
28+
return (
29+
canvasStore.groupSelected ||
30+
canvasStore.rerouteSelected ||
31+
canvasStore.nodeSelected
32+
)
33+
})
2234
</script>

src/stores/graphStore.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Positionable } from '@comfyorg/litegraph/dist/interfaces'
33
import { defineStore } from 'pinia'
44
import { type Raw, computed, markRaw, ref, shallowRef } from 'vue'
55

6-
import { isLGraphGroup, isLGraphNode } from '@/utils/litegraphUtil'
6+
import { isLGraphGroup, isLGraphNode, isReroute } from '@/utils/litegraphUtil'
77

88
export const useTitleEditorStore = defineStore('titleEditor', () => {
99
const titleEditorTarget = shallowRef<LGraphNode | LGraphGroup | null>(null)
@@ -31,6 +31,7 @@ export const useCanvasStore = defineStore('canvas', () => {
3131

3232
const nodeSelected = computed(() => selectedItems.value.some(isLGraphNode))
3333
const groupSelected = computed(() => selectedItems.value.some(isLGraphGroup))
34+
const rerouteSelected = computed(() => selectedItems.value.some(isReroute))
3435

3536
const getCanvas = () => {
3637
if (!canvas.value) throw new Error('getCanvas: canvas is null')
@@ -42,6 +43,7 @@ export const useCanvasStore = defineStore('canvas', () => {
4243
selectedItems,
4344
nodeSelected,
4445
groupSelected,
46+
rerouteSelected,
4547
updateSelectedItems,
4648
getCanvas
4749
}

src/utils/litegraphUtil.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ColorOption, LGraph } from '@comfyorg/litegraph'
1+
import { ColorOption, LGraph, Reroute } from '@comfyorg/litegraph'
22
import { LGraphGroup, LGraphNode, isColorable } from '@comfyorg/litegraph'
33
import type { ISerialisedGraph } from '@comfyorg/litegraph/dist/types/serialisation'
44
import type {
@@ -50,6 +50,10 @@ export const isLGraphGroup = (item: unknown): item is LGraphGroup => {
5050
return item instanceof LGraphGroup
5151
}
5252

53+
export const isReroute = (item: unknown): item is Reroute => {
54+
return item instanceof Reroute
55+
}
56+
5357
/**
5458
* Get the color option of all canvas items if they are all the same.
5559
* @param items - The items to get the color option of.

0 commit comments

Comments
 (0)