LCOV - code coverage report
Current view: top level - src/platform/workflowErrors/nodeReplacement/components - SwapNodeGroupRow.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 27 27
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2           29 :   <div class="mb-1 flex w-full flex-col gap-0.5 last:mb-0">
       3              :     <div
       4              :       :aria-current="highlighted ? 'true' : undefined"
       5              :       :class="
       6              :         cn(
       7              :           'flex min-h-8 items-center gap-1',
       8              :           selectionEmphasisClass(highlighted)
       9              :         )
      10              :       "
      11              :     >
      12              :       <Button
      13              :         v-if="hasMultipleNodeTypes"
      14              :         data-testid="swap-node-group-expand"
      15              :         variant="textonly"
      16              :         size="unset"
      17              :         :aria-label="
      18              :           expanded
      19              :             ? t('rightSidePanel.missingNodePacks.collapse', 'Collapse')
      20              :             : t('rightSidePanel.missingNodePacks.expand', 'Expand')
      21              :         "
      22              :         :aria-expanded="expanded"
      23              :         class="h-8 w-4 shrink-0 p-0 hover:bg-transparent focus-visible:ring-inset"
      24              :         @click="toggleExpand"
      25              :       >
      26              :         <i
      27              :           aria-hidden="true"
      28              :           :class="
      29              :             cn(
      30              :               'icon-[lucide--chevron-right] text-muted-foreground transition-transform duration-200',
      31              :               expanded && 'rotate-90'
      32              :             )
      33              :           "
      34              :         />
      35              :       </Button>
      36              : 
      37              :       <span class="flex min-w-0 flex-1 flex-col gap-0">
      38              :         <span class="flex min-w-0 items-center gap-2">
      39              :           <span class="flex min-w-0 items-center gap-2.5">
      40              :             <button
      41              :               v-if="hasMultipleNodeTypes"
      42              :               type="button"
      43              :               class="m-0 inline max-w-full cursor-pointer appearance-none rounded-sm border-0 bg-transparent p-0 text-left text-xs/relaxed font-normal wrap-break-word outline-none hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-inset"
      44              :               :title="group.type"
      45              :               :aria-label="titleToggleAriaLabel"
      46              :               :aria-expanded="expanded"
      47              :               @click="toggleExpand"
      48              :             >
      49              :               {{ group.type }}
      50              :             </button>
      51              :             <button
      52              :               v-else-if="primaryLocatableNodeType"
      53              :               type="button"
      54              :               class="m-0 inline max-w-full cursor-pointer appearance-none rounded-sm border-0 bg-transparent p-0 text-left text-xs/relaxed font-normal wrap-break-word outline-none hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-inset"
      55              :               :title="group.type"
      56              :               @click="handleLocateNode(primaryLocatableNodeType)"
      57              :             >
      58              :               {{ group.type }}
      59              :             </button>
      60              :             <span
      61              :               v-else
      62              :               class="min-w-0 truncate text-xs/relaxed font-normal"
      63              :               :title="group.type"
      64              :             >
      65              :               {{ group.type }}
      66              :             </span>
      67              :             <span
      68              :               v-if="hasMultipleNodeTypes"
      69              :               data-testid="swap-node-group-count"
      70              :               role="img"
      71              :               class="flex h-4 min-w-4 shrink-0 items-center justify-center rounded-sm bg-accent px-1 text-2xs font-semibold"
      72              :               :aria-label="t('g.nodesCount', group.nodeTypes.length)"
      73              :             >
      74              :               {{ group.nodeTypes.length }}
      75              :             </span>
      76              :           </span>
      77              :         </span>
      78              :         <span class="min-w-0 text-xs/relaxed text-muted-foreground">
      79              :           {{
      80              :             t(
      81              :               'nodeReplacement.willBeReplacedBy',
      82              :               'This node will be replaced by:'
      83              :             )
      84              :           }}
      85              :           <Badge
      86              :             variant="square"
      87              :             severity="muted"
      88              :             class="text-xs/none text-foreground"
      89              :           >
      90              :             {{ replacementLabel }}
      91              :           </Badge>
      92              :         </span>
      93              :       </span>
      94              : 
      95              :       <Button
      96              :         variant="secondary"
      97              :         size="sm"
      98              :         class="shrink-0 focus-visible:ring-inset"
      99              :         @click="handleReplaceNode"
     100              :       >
     101              :         <i
     102              :           aria-hidden="true"
     103              :           class="mr-1 icon-[lucide--repeat] text-foreground"
     104              :         />
     105              :         <span class="min-w-0 truncate text-foreground">
     106              :           {{ t('nodeReplacement.replaceNode', 'Replace Node') }}
     107              :         </span>
     108              :       </Button>
     109              : 
     110              :       <Button
     111              :         v-if="primaryLocatableNodeType"
     112              :         variant="muted-textonly"
     113              :         size="icon-sm"
     114              :         class="size-8 shrink-0 hover:text-foreground focus-visible:ring-inset"
     115              :         :aria-label="locateNodeLabel"
     116              :         @click="handleLocateNode(primaryLocatableNodeType)"
     117              :       >
     118              :         <i aria-hidden="true" class="icon-[lucide--locate]" />
     119              :       </Button>
     120              :     </div>
     121              : 
     122              :     <TransitionCollapse>
     123              :       <ul v-if="expanded" class="m-0 list-none space-y-1 p-0 pl-5">
     124            4 :         <li
     125              :           v-for="(nodeType, index) in group.nodeTypes"
     126              :           :key="getKey(nodeType, index)"
     127              :           class="min-w-0"
     128              :         >
     129              :           <div class="flex min-w-0 items-center gap-2">
     130              :             <span
     131              :               class="flex min-w-0 flex-1 items-center gap-1 text-xs/relaxed text-muted-foreground"
     132              :             >
     133              :               <button
     134              :                 v-if="isLocatableNodeType(nodeType)"
     135              :                 type="button"
     136              :                 class="m-0 inline max-w-full cursor-pointer appearance-none rounded-sm border-0 bg-transparent p-0 text-left font-normal wrap-break-word outline-none hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-inset"
     137              :                 @click="handleLocateNode(nodeType)"
     138              :               >
     139              :                 {{ getLabel(nodeType) }}
     140              :               </button>
     141              :               <span v-else class="wrap-break-word">
     142              :                 {{ getLabel(nodeType) }}
     143              :               </span>
     144              :             </span>
     145              :             <Button
     146              :               v-if="isLocatableNodeType(nodeType)"
     147              :               variant="muted-textonly"
     148              :               size="icon-sm"
     149              :               class="size-8 shrink-0 hover:text-foreground focus-visible:ring-inset"
     150              :               :aria-label="locateNodeLabel"
     151              :               @click="handleLocateNode(nodeType)"
     152              :             >
     153              :               <i aria-hidden="true" class="icon-[lucide--locate]" />
     154              :             </Button>
     155              :           </div>
     156              :         </li>
     157              :       </ul>
     158              :     </TransitionCollapse>
     159              :   </div>
     160              : </template>
     161              : 
     162              : <script setup lang="ts">
     163              : import Badge from '@comfyorg/design-system/badge/Badge'
     164              : import { computed, ref } from 'vue'
     165              : import { cn } from '@comfyorg/tailwind-utils'
     166              : 
     167              : import { selectionEmphasisClass } from '@/platform/workflowErrors/panel/selectionEmphasis'
     168              : import { useI18n } from 'vue-i18n'
     169              : import Button from '@comfyorg/design-system/button/Button'
     170              : import TransitionCollapse from '@comfyorg/design-system/transition/TransitionCollapse'
     171              : import type { MissingNodeType } from '@/platform/workflowErrors/nodeReplacement/types'
     172              : import type { SwapNodeGroup } from '@/platform/workflowErrors/panel/useErrorGroups'
     173              : 
     174              : const { group, highlighted } = defineProps<{
     175              :   group: SwapNodeGroup
     176              :   /** Emphasize the header row (group containing the canvas selection). */
     177              :   highlighted?: boolean
     178              : }>()
     179              : 
     180           25 : const emit = defineEmits<{
     181              :   'locate-node': [nodeId: string]
     182              :   replace: [group: SwapNodeGroup]
     183              : }>()
     184              : 
     185           25 : const { t } = useI18n()
     186              : 
     187           25 : const expanded = ref(false)
     188           25 : const hasMultipleNodeTypes = computed(() => group.nodeTypes.length > 1)
     189           25 : const replacementLabel = computed(
     190              :   () => group.newNodeId ?? t('nodeReplacement.unknownNode', 'Unknown')
     191              : )
     192           25 : const locateNodeLabel = computed(() =>
     193              :   t('rightSidePanel.locateNode', 'Locate node on canvas')
     194              : )
     195           25 : const titleToggleAriaLabel = computed(
     196              :   () =>
     197              :     `${
     198              :       expanded.value
     199              :         ? t('rightSidePanel.missingNodePacks.collapse', 'Collapse')
     200              :         : t('rightSidePanel.missingNodePacks.expand', 'Expand')
     201              :     } ${group.type}`
     202              : )
     203           25 : const primaryLocatableNodeType = computed(() => {
     204           25 :   if (group.nodeTypes.length !== 1) return null
     205           23 :   const [nodeType] = group.nodeTypes
     206           25 :   return isLocatableNodeType(nodeType) ? nodeType : null
     207              : })
     208              : 
     209            4 : function toggleExpand() {
     210            4 :   expanded.value = !expanded.value
     211              : }
     212              : 
     213            4 : function getKey(nodeType: MissingNodeType, index: number): string {
     214            4 :   if (typeof nodeType === 'string') return `${nodeType}-${index}`
     215            4 :   return nodeType.nodeId != null
     216              :     ? String(nodeType.nodeId)
     217              :     : `${nodeType.type}-${index}`
     218              : }
     219              : 
     220            4 : function getLabel(nodeType: MissingNodeType): string {
     221            4 :   return typeof nodeType === 'string' ? nodeType : nodeType.type
     222              : }
     223              : 
     224           33 : function isLocatableNodeType(
     225              :   nodeType: MissingNodeType
     226              : ): nodeType is Exclude<MissingNodeType, string> & { nodeId: string | number } {
     227           33 :   return typeof nodeType !== 'string' && nodeType.nodeId != null
     228              : }
     229              : 
     230            2 : function handleLocateNode(nodeType: MissingNodeType) {
     231            2 :   if (!isLocatableNodeType(nodeType)) return
     232            2 :   emit('locate-node', String(nodeType.nodeId))
     233              : }
     234              : 
     235            8 : function handleReplaceNode() {
     236            8 :   emit('replace', group)
     237              : }
     238              : </script>
        

Generated by: LCOV version 2.0-1