LCOV - code coverage report
Current view: top level - src/platform/keybindings/components - EditKeybindingFooter.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 83.3 % 18 15
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1           16 : <template>
       2           30 :   <div class="flex w-full justify-end gap-2 px-4 py-2">
       3              :     <Button variant="muted-textonly" size="md" @click="handleCancel">
       4              :       {{ $t('g.cancel') }}
       5              :     </Button>
       6              :     <Button
       7              :       :variant="
       8              :         existingKeybindingOnCombo
       9              :           ? 'destructive'
      10              :           : dialogState.newCombo?.isBrowserReserved
      11              :             ? 'secondary'
      12              :             : 'primary'
      13              :       "
      14              :       size="md"
      15              :       :disabled="!dialogState.newCombo"
      16              :       class="px-4 py-2"
      17              :       @click="handleSave"
      18              :     >
      19              :       {{
      20              :         existingKeybindingOnCombo
      21              :           ? $t('g.overwrite')
      22              :           : dialogState.newCombo?.isBrowserReserved
      23              :             ? $t('g.saveAnyway')
      24              :             : $t('g.save')
      25              :       }}
      26              :     </Button>
      27              :   </div>
      28              : </template>
      29              : 
      30              : <script setup lang="ts">
      31              : import type { Reactive } from 'vue'
      32              : 
      33              : import Button from '@comfyorg/design-system/button/Button'
      34              : import { KeybindingImpl } from '@comfyorg/keybindings/keybinding'
      35              : import { useKeybindingService } from '@/platform/keybindings/keybindingService'
      36              : import { useKeybindingStore } from '@comfyorg/keybindings/keybindingStore'
      37              : import { useDialogStore } from '@/stores/dialogStore'
      38              : 
      39              : import type { EditKeybindingDialogState } from '@/platform/keybindings/components/editKeybindingDialogState'
      40              : import { EDIT_KEYBINDING_DIALOG_KEY } from '@/platform/keybindings/components/editKeybindingDialogState'
      41              : 
      42              : const { dialogState, existingKeybindingOnCombo } = defineProps<{
      43              :   dialogState: Reactive<EditKeybindingDialogState>
      44              :   existingKeybindingOnCombo: KeybindingImpl | null
      45              : }>()
      46              : 
      47           13 : const keybindingStore = useKeybindingStore()
      48           13 : const keybindingService = useKeybindingService()
      49           13 : const dialogStore = useDialogStore()
      50              : 
      51            7 : function handleCancel() {
      52            7 :   dialogStore.closeDialog({ key: EDIT_KEYBINDING_DIALOG_KEY })
      53              : }
      54              : 
      55            6 : async function handleSave() {
      56            6 :   const combo = dialogState.newCombo
      57            6 :   const commandId = dialogState.commandId
      58            6 :   if (!combo || !commandId) return
      59              : 
      60            6 :   dialogStore.closeDialog({ key: EDIT_KEYBINDING_DIALOG_KEY })
      61              : 
      62            6 :   if (dialogState.mode === 'add') {
      63            6 :     keybindingStore.addUserKeybinding(new KeybindingImpl({ commandId, combo }))
      64            0 :   } else if (dialogState.existingBinding) {
      65            0 :     keybindingStore.updateSpecificKeybinding(
      66              :       dialogState.existingBinding,
      67              :       new KeybindingImpl({ commandId, combo })
      68              :     )
      69              :   } else {
      70            0 :     keybindingStore.updateKeybindingOnCommand(
      71              :       new KeybindingImpl({ commandId, combo })
      72              :     )
      73              :   }
      74            6 :   await keybindingService.persistUserKeybindings()
      75              : }
      76              : </script>
        

Generated by: LCOV version 2.0-1