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

            Line data    Source code
       1              : <template>
       2           62 :   <Dialog v-model:open="visible">
       3              :     <DialogPortal>
       4              :       <DialogOverlay />
       5              :       <DialogContent size="md" :aria-labelledby="titleId">
       6              :         <DialogHeader>
       7              :           <DialogTitle :id="titleId">
       8              :             {{ $t('g.customizeFolder') }}
       9              :           </DialogTitle>
      10              :           <DialogClose :aria-label="$t('g.close')" />
      11              :         </DialogHeader>
      12              :         <div class="flex flex-col gap-4 px-4 py-2">
      13              :           <div class="flex flex-col gap-2">
      14              :             <label for="customization-icon" class="text-sm font-medium">
      15              :               {{ $t('g.icon') }}
      16              :             </label>
      17              :             <ToggleGroup
      18              :               id="customization-icon"
      19              :               v-model="selectedIconValue"
      20              :               type="single"
      21              :               :allow-empty="false"
      22              :               class="justify-start"
      23              :             >
      24          136 :               <ToggleGroupItem
      25              :                 v-for="option in iconOptions"
      26              :                 :key="option.value"
      27              :                 :value="option.value"
      28              :                 :aria-label="option.name"
      29              :                 class="p-2"
      30              :               >
      31              :                 <i
      32              :                   :class="cn('pi text-lg', option.value)"
      33              :                   :style="{ color: finalColor }"
      34              :                 />
      35              :               </ToggleGroupItem>
      36              :             </ToggleGroup>
      37              :           </div>
      38              :           <hr class="border-t border-border/50" />
      39              :           <div class="flex flex-col gap-2">
      40              :             <label for="customization-color" class="text-sm font-medium">
      41              :               {{ $t('g.color') }}
      42              :             </label>
      43              :             <ColorCustomizationSelector
      44              :               id="customization-color"
      45              :               v-model="finalColor"
      46              :               :color-options="colorOptions"
      47              :             />
      48              :           </div>
      49              :         </div>
      50              :         <DialogFooter>
      51              :           <Button variant="textonly" @click="resetCustomization">
      52              :             <i class="pi pi-refresh" />
      53              :             {{ $t('g.reset') }}
      54              :           </Button>
      55              :           <Button autofocus @click="confirmCustomization">
      56              :             <i class="pi pi-check" />
      57              :             {{ $t('g.confirm') }}
      58              :           </Button>
      59              :         </DialogFooter>
      60              :       </DialogContent>
      61              :     </DialogPortal>
      62              :   </Dialog>
      63              : </template>
      64              : 
      65              : <script setup lang="ts">
      66              : import { ref, useId, watch } from 'vue'
      67              : import { useI18n } from 'vue-i18n'
      68              : 
      69              : import ColorCustomizationSelector from '@/components/common/ColorCustomizationSelector.vue'
      70              : import Button from '@comfyorg/design-system/button/Button'
      71              : import Dialog from '@comfyorg/design-system/dialog/Dialog'
      72              : import DialogClose from '@comfyorg/design-system/dialog/DialogClose'
      73              : import DialogContent from '@comfyorg/design-system/dialog/DialogContent'
      74              : import DialogFooter from '@comfyorg/design-system/dialog/DialogFooter'
      75              : import DialogHeader from '@comfyorg/design-system/dialog/DialogHeader'
      76              : import DialogOverlay from '@comfyorg/design-system/dialog/DialogOverlay'
      77              : import DialogPortal from '@comfyorg/design-system/dialog/DialogPortal'
      78              : import DialogTitle from '@comfyorg/design-system/dialog/DialogTitle'
      79              : import ToggleGroup from '@comfyorg/design-system/toggle-group/ToggleGroup'
      80              : import ToggleGroupItem from '@comfyorg/design-system/toggle-group/ToggleGroupItem'
      81              : import { useNodeBookmarkStore } from '@/stores/nodeBookmarkStore'
      82              : import { cn } from '@comfyorg/tailwind-utils'
      83              : 
      84           56 : const { t } = useI18n()
      85              : 
      86              : const { initialIcon, initialColor } = defineProps<{
      87              :   initialIcon?: string
      88              :   initialColor?: string
      89              : }>()
      90              : 
      91           56 : const visible = defineModel<boolean>({ default: false })
      92              : 
      93           56 : const emit = defineEmits<{
      94              :   (e: 'confirm', icon: string, color: string): void
      95              : }>()
      96              : 
      97           56 : const titleId = useId()
      98              : 
      99           56 : const nodeBookmarkStore = useNodeBookmarkStore()
     100              : 
     101           56 : const iconOptions = [
     102              :   { name: t('icon.bookmark'), value: nodeBookmarkStore.defaultBookmarkIcon },
     103              :   { name: t('icon.folder'), value: 'pi-folder' },
     104              :   { name: t('icon.star'), value: 'pi-star' },
     105              :   { name: t('icon.heart'), value: 'pi-heart' },
     106              :   { name: t('icon.file'), value: 'pi-file' },
     107              :   { name: t('icon.inbox'), value: 'pi-inbox' },
     108              :   { name: t('icon.box'), value: 'pi-box' },
     109              :   { name: t('icon.briefcase'), value: 'pi-briefcase' }
     110              : ]
     111              : 
     112           56 : const colorOptions = [
     113              :   { name: t('color.default'), value: nodeBookmarkStore.defaultBookmarkColor },
     114              :   { name: t('color.blue'), value: '#007bff' },
     115              :   { name: t('color.green'), value: '#28a745' },
     116              :   { name: t('color.red'), value: '#dc3545' },
     117              :   { name: t('color.pink'), value: '#e83e8c' },
     118              :   { name: t('color.yellow'), value: '#ffc107' }
     119              : ]
     120              : 
     121           56 : const defaultIcon = iconOptions.find(
     122              :   (option) => option.value === nodeBookmarkStore.defaultBookmarkIcon
     123              : )
     124              : 
     125           56 : const selectedIconValue = ref((defaultIcon ?? iconOptions[0]).value)
     126           56 : const finalColor = ref(initialColor || nodeBookmarkStore.defaultBookmarkColor)
     127              : 
     128           56 : const resetCustomization = () => {
     129            3 :   selectedIconValue.value =
     130              :     iconOptions.find((option) => option.value === initialIcon)?.value ??
     131              :     iconOptions[0].value
     132            3 :   finalColor.value = initialColor || nodeBookmarkStore.defaultBookmarkColor
     133              : }
     134              : 
     135           56 : const confirmCustomization = () => {
     136            3 :   emit('confirm', selectedIconValue.value, finalColor.value)
     137            3 :   visible.value = false
     138              : }
     139              : 
     140           56 : watch(
     141              :   visible,
     142              :   (newValue) => {
     143           62 :     if (newValue) {
     144            3 :       resetCustomization()
     145              :     }
     146              :   },
     147              :   { immediate: true }
     148              : )
     149              : </script>
        

Generated by: LCOV version 2.0-1