|
| 1 | +<template> |
| 2 | + <div class="flex flex-col w-full mb-4"> |
| 3 | + <!-- Type header row: type name + chevron --> |
| 4 | + <div class="flex h-8 items-center w-full"> |
| 5 | + <p |
| 6 | + class="flex-1 min-w-0 text-sm font-medium overflow-hidden text-ellipsis whitespace-nowrap text-foreground" |
| 7 | + > |
| 8 | + {{ `${group.type} (${group.nodeTypes.length})` }} |
| 9 | + </p> |
| 10 | + |
| 11 | + <Button |
| 12 | + variant="textonly" |
| 13 | + size="icon-sm" |
| 14 | + :class=" |
| 15 | + cn( |
| 16 | + 'size-8 shrink-0 transition-transform duration-200 hover:bg-transparent', |
| 17 | + { 'rotate-180': expanded } |
| 18 | + ) |
| 19 | + " |
| 20 | + :aria-label=" |
| 21 | + expanded |
| 22 | + ? t('rightSidePanel.missingNodePacks.collapse', 'Collapse') |
| 23 | + : t('rightSidePanel.missingNodePacks.expand', 'Expand') |
| 24 | + " |
| 25 | + @click="toggleExpand" |
| 26 | + > |
| 27 | + <i |
| 28 | + class="icon-[lucide--chevron-down] size-4 text-muted-foreground group-hover:text-base-foreground" |
| 29 | + /> |
| 30 | + </Button> |
| 31 | + </div> |
| 32 | + |
| 33 | + <!-- Sub-labels: individual node instances, each with their own Locate button --> |
| 34 | + <TransitionCollapse> |
| 35 | + <div |
| 36 | + v-if="expanded" |
| 37 | + class="flex flex-col gap-0.5 pl-2 mb-2 overflow-hidden" |
| 38 | + > |
| 39 | + <div |
| 40 | + v-for="nodeType in group.nodeTypes" |
| 41 | + :key="getKey(nodeType)" |
| 42 | + class="flex h-7 items-center" |
| 43 | + > |
| 44 | + <span |
| 45 | + v-if=" |
| 46 | + showNodeIdBadge && |
| 47 | + typeof nodeType !== 'string' && |
| 48 | + nodeType.nodeId != null |
| 49 | + " |
| 50 | + class="shrink-0 rounded-md bg-secondary-background-selected px-2 py-0.5 text-xs font-mono text-muted-foreground font-bold mr-1" |
| 51 | + > |
| 52 | + #{{ nodeType.nodeId }} |
| 53 | + </span> |
| 54 | + <p class="flex-1 min-w-0 text-xs text-muted-foreground truncate"> |
| 55 | + {{ getLabel(nodeType) }} |
| 56 | + </p> |
| 57 | + <Button |
| 58 | + v-if="typeof nodeType !== 'string' && nodeType.nodeId != null" |
| 59 | + variant="textonly" |
| 60 | + size="icon-sm" |
| 61 | + class="size-6 text-muted-foreground hover:text-base-foreground shrink-0 mr-1" |
| 62 | + :aria-label="t('rightSidePanel.locateNode', 'Locate Node')" |
| 63 | + @click="handleLocateNode(nodeType)" |
| 64 | + > |
| 65 | + <i class="icon-[lucide--locate] size-3" /> |
| 66 | + </Button> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + </TransitionCollapse> |
| 70 | + |
| 71 | + <!-- Description rows: what it is replaced by --> |
| 72 | + <div class="flex flex-col text-[13px] mb-2 mt-1 px-1 gap-0.5"> |
| 73 | + <span class="text-muted-foreground">{{ |
| 74 | + t('nodeReplacement.willBeReplacedBy', 'This node will be replaced by:') |
| 75 | + }}</span> |
| 76 | + <span class="font-bold text-foreground">{{ |
| 77 | + group.newNodeId ?? t('nodeReplacement.unknownNode', 'Unknown') |
| 78 | + }}</span> |
| 79 | + </div> |
| 80 | + |
| 81 | + <!-- Replace Action Button --> |
| 82 | + <div class="flex items-start w-full pt-1 pb-1"> |
| 83 | + <Button |
| 84 | + variant="secondary" |
| 85 | + size="md" |
| 86 | + class="flex flex-1 w-full" |
| 87 | + @click="handleReplaceNode" |
| 88 | + > |
| 89 | + <i class="icon-[lucide--repeat] size-4 text-foreground shrink-0 mr-1" /> |
| 90 | + <span class="text-sm text-foreground truncate min-w-0"> |
| 91 | + {{ t('nodeReplacement.replaceNode', 'Replace Node') }} |
| 92 | + </span> |
| 93 | + </Button> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | +</template> |
| 97 | + |
| 98 | +<script setup lang="ts"> |
| 99 | +import { ref } from 'vue' |
| 100 | +import { cn } from '@/utils/tailwindUtil' |
| 101 | +import { useI18n } from 'vue-i18n' |
| 102 | +import Button from '@/components/ui/button/Button.vue' |
| 103 | +import TransitionCollapse from '@/components/rightSidePanel/layout/TransitionCollapse.vue' |
| 104 | +import type { MissingNodeType } from '@/types/comfy' |
| 105 | +import type { SwapNodeGroup } from './useErrorGroups' |
| 106 | +import { useNodeReplacement } from '@/platform/nodeReplacement/useNodeReplacement' |
| 107 | +import { useExecutionErrorStore } from '@/stores/executionErrorStore' |
| 108 | +
|
| 109 | +const props = defineProps<{ |
| 110 | + group: SwapNodeGroup |
| 111 | + showNodeIdBadge: boolean |
| 112 | +}>() |
| 113 | +
|
| 114 | +const emit = defineEmits<{ |
| 115 | + 'locate-node': [nodeId: string] |
| 116 | +}>() |
| 117 | +
|
| 118 | +const { t } = useI18n() |
| 119 | +const { replaceNodesInPlace } = useNodeReplacement() |
| 120 | +const executionErrorStore = useExecutionErrorStore() |
| 121 | +
|
| 122 | +const expanded = ref(false) |
| 123 | +
|
| 124 | +function toggleExpand() { |
| 125 | + expanded.value = !expanded.value |
| 126 | +} |
| 127 | +
|
| 128 | +function getKey(nodeType: MissingNodeType): string { |
| 129 | + if (typeof nodeType === 'string') return nodeType |
| 130 | + return nodeType.nodeId != null ? String(nodeType.nodeId) : nodeType.type |
| 131 | +} |
| 132 | +
|
| 133 | +function getLabel(nodeType: MissingNodeType): string { |
| 134 | + return typeof nodeType === 'string' ? nodeType : nodeType.type |
| 135 | +} |
| 136 | +
|
| 137 | +function handleLocateNode(nodeType: MissingNodeType) { |
| 138 | + if (typeof nodeType === 'string') return |
| 139 | + if (nodeType.nodeId != null) { |
| 140 | + emit('locate-node', String(nodeType.nodeId)) |
| 141 | + } |
| 142 | +} |
| 143 | +
|
| 144 | +function handleReplaceNode() { |
| 145 | + const replaced = replaceNodesInPlace(props.group.nodeTypes) |
| 146 | + if (replaced.length > 0) { |
| 147 | + executionErrorStore.removeMissingNodesByType([props.group.type]) |
| 148 | + } |
| 149 | +} |
| 150 | +</script> |
0 commit comments