LCOV - code coverage report
Current view: top level - src/components/builder - BuilderMenu.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 47.6 % 21 10
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2           93 :   <Menu v-model:open="open" :items="menuItems" class="min-w-56">
       3              :     <template #trigger>
       4              :       <Button
       5              :         size="lg"
       6              :         class="absolute top-[calc(var(--workflow-tabs-height)+16px)] left-4 gap-2.5 pr-2 pl-3 shadow-md data-[state=open]:bg-muted"
       7              :         :aria-label="t('linearMode.appModeToolbar.appBuilder')"
       8              :       >
       9              :         <i class="icon-[lucide--hammer]" />
      10              :         <span class="text-sm font-medium">
      11              :           {{ t('linearMode.appModeToolbar.appBuilder') }}
      12              :         </span>
      13              :         <i class="icon-[lucide--chevron-down] text-muted-foreground" />
      14              :       </Button>
      15              :     </template>
      16              :   </Menu>
      17              : </template>
      18              : 
      19              : <script setup lang="ts">
      20              : import { computed, ref } from 'vue'
      21              : import { storeToRefs } from 'pinia'
      22              : import { useI18n } from 'vue-i18n'
      23              : 
      24              : import Button from '@comfyorg/design-system/button/Button'
      25              : import Menu from '@comfyorg/design-system/menu/Menu'
      26              : import type {
      27              :   MenuItem,
      28              :   MenuItemCommandEvent
      29              : } from '@comfyorg/design-system/lib/menu/types'
      30              : import { useAppMode } from '@/composables/useAppMode'
      31              : import { useErrorHandling } from '@/composables/useErrorHandling'
      32              : import { useWorkflowService } from '@/platform/workflow/core/services/workflowService'
      33              : import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
      34              : import { useAppModeStore } from '@/stores/appModeStore'
      35              : 
      36           59 : const { t } = useI18n()
      37           59 : const appModeStore = useAppModeStore()
      38           59 : const { hasOutputs } = storeToRefs(appModeStore)
      39           59 : const { setMode } = useAppMode()
      40           59 : const workflowService = useWorkflowService()
      41           59 : const workflowStore = useWorkflowStore()
      42           59 : const { toastErrorHandler } = useErrorHandling()
      43           59 : const open = ref(false)
      44              : 
      45           59 : const menuItems = computed<MenuItem[]>(() => [
      46              :   {
      47              :     label: t('g.save'),
      48              :     icon: 'icon-[lucide--save]',
      49              :     disabled: !hasOutputs.value,
      50              :     command: onSave
      51              :   },
      52              :   { separator: true },
      53              :   {
      54              :     label: t('builderMenu.enterAppMode'),
      55              :     icon: 'icon-[lucide--panels-top-left]',
      56              :     command: onEnterAppMode
      57              :   },
      58              :   { separator: true },
      59              :   {
      60              :     label: t('builderMenu.exitAppBuilder'),
      61              :     icon: 'icon-[lucide--x]',
      62              :     command: onExitBuilder
      63              :   }
      64              : ])
      65              : 
      66            0 : async function onSave({ originalEvent }: MenuItemCommandEvent) {
      67            0 :   originalEvent.preventDefault()
      68            0 :   const workflow = workflowStore.activeWorkflow
      69            0 :   if (!workflow) return
      70            0 :   try {
      71              :     const saved = await workflowService.saveWorkflow(workflow)
      72            0 :     if (saved) open.value = false
      73              :   } catch (error) {
      74            0 :     toastErrorHandler(error)
      75              :   }
      76              : }
      77              : 
      78            0 : function onEnterAppMode() {
      79            0 :   setMode('app')
      80              : }
      81              : 
      82            0 : function onExitBuilder() {
      83            0 :   appModeStore.exitBuilder()
      84              : }
      85              : </script>
        

Generated by: LCOV version 2.0-1