@@ -7,15 +7,13 @@ import SheetActionDialog from "@/components/sheet-action-dialog"
77import { config , setConfigItem } from "@/app/reducers/uiReducer"
88import { toast } from "@/hooks/use-toast"
99import { useAppDispatch , useAppSelector } from "@/app/hooks"
10- import { useEffect , useRef , useState } from "react"
10+ import { useCallback , useEffect , useRef , useState } from "react"
1111import ConfirmationDialogAction , {
1212 ConfirmationDialogActionType ,
1313} from "@/components/confirmationDialogAction"
14- import { DropdownMenuItem } from "@/components/ui/dropdown-menu"
15- import { jobActions } from "@/features/jobsTable/interfaces"
1614import { useHotkeys } from "react-hotkeys-hook"
17- import HotKeyButton from "@/components/custom/HotKeyButton"
1815import { verifyUserConnection } from "@/utils/authUtils"
16+ import { ButtonWithTooltip } from "@/components/custom/general/ButtonWithTooltip"
1917
2018export default function DrawerMenuConfigurator ( ) {
2119 useHotkeys (
@@ -63,6 +61,27 @@ export default function DrawerMenuConfigurator() {
6361 } )
6462 sideBarTriggerRef . current . click ( )
6563 }
64+ const hotKLeySaveTargetRef = useHotkeys < HTMLInputElement > (
65+ [ "meta+enter" ] ,
66+ ( ) => {
67+ return updateSavedTargets ( targetServer )
68+ } ,
69+ {
70+ enableOnFormTags : true ,
71+ enableOnContentEditable : true ,
72+ } ,
73+ )
74+
75+ const handleTargetServerRemoval = useCallback (
76+ ( action : ConfirmationDialogActionType , target ) => {
77+ if ( action === ConfirmationDialogActionType . CANCEL ) {
78+ return
79+ }
80+
81+ return removeSavedTarget ( target )
82+ } ,
83+ [ savedConfig ] ,
84+ )
6685
6786 return (
6887 < SheetActionDialog
@@ -90,6 +109,7 @@ export default function DrawerMenuConfigurator() {
90109 Current
91110 </ Label >
92111 < Input
112+ ref = { hotKLeySaveTargetRef }
93113 name = { "target" }
94114 placeholder = "..."
95115 className = "w-6/12"
@@ -121,7 +141,7 @@ export default function DrawerMenuConfigurator() {
121141 savedConfig . savedTargets . map ( ( e , i ) => (
122142 < div
123143 className = "flex items-center gap-4 justify-between w-full min-w-0 flex-1 overflow-hidden"
124- key = { i }
144+ key = { e + i }
125145 >
126146 < div
127147 className = {
@@ -146,26 +166,27 @@ export default function DrawerMenuConfigurator() {
146166 } }
147167 title = { `Delete Target server : ${ e } ` }
148168 description = {
149- "This action will delete the target server from your local browser storage. You can add it back again anytime "
169+ "This action will delete the target server from your local browser storage"
150170 }
151- takeAction = { action => {
152- if ( action === ConfirmationDialogActionType . CANCEL ) return
153- removeSavedTarget ( e )
154- } }
171+ extraTakeActionArgs = { [ e ] }
172+ takeAction = { handleTargetServerRemoval }
155173 confirmVariant = "destructive"
174+ autoFocus = { true }
156175 >
157176 < Button variant = { "destructive" } size = { "icon" } >
158177 < DeleteIcon />
159178 </ Button >
160179 </ ConfirmationDialogAction >
161- < HotKeyButton
162- hotKey = { [ "ctrl+alt+" + ( i + 1 ) , "meta+alt+" + ( i + 1 ) ] }
180+ < ButtonWithTooltip
181+ tooltipContent = { `(⌘⌥${ i + 1 } )` }
182+ keyBinding = { [ "ctrl+alt+" + ( i + 1 ) , "meta+alt+" + ( i + 1 ) ] }
183+ hideKeyboardShortcut = { true }
163184 variant = { "default" }
164185 size = { "icon" }
165186 onClick = { ( ) => setNewTargetServer ( e ) }
166187 >
167188 < PlayIcon />
168- </ HotKeyButton >
189+ </ ButtonWithTooltip >
169190 </ div >
170191 </ div >
171192 ) ) }
0 commit comments