@@ -18,7 +18,7 @@ import {
1818 removeConnectionBrackets ,
1919} from '@openops/shared' ;
2020import { t } from 'i18next' ;
21- import { Plus } from 'lucide-react' ;
21+ import { PencilLine , Plus , X } from 'lucide-react' ;
2222import { memo , useCallback , useState } from 'react' ;
2323import { ControllerRenderProps , useFormContext } from 'react-hook-form' ;
2424
@@ -68,9 +68,9 @@ const ConnectionSelect = memo((params: ConnectionSelectProps) => {
6868 ) ;
6969
7070 const handleReconnectClick = useCallback (
71- ( e : React . MouseEvent < HTMLButtonElement > ) => {
72- e . preventDefault ( ) ;
73- e . stopPropagation ( ) ;
71+ ( e ? : React . MouseEvent < HTMLElement > ) => {
72+ e ? .preventDefault ?. ( ) ;
73+ e ? .stopPropagation ?. ( ) ;
7474 const currentValue = form . getValues ( params . name ) ;
7575 const connectionName = removeConnectionBrackets ( currentValue ?? '' ) ;
7676
@@ -138,45 +138,84 @@ const ConnectionSelect = memo((params: ConnectionSelectProps) => {
138138 } }
139139 disabled = { params . disabled }
140140 >
141- < div className = "relative" >
142- { field . value && ! field . disabled && (
143- < Button
144- type = "button"
145- variant = "ghost"
146- size = "xs"
147- className = "z-50 absolute right-8 top-2 "
148- onClick = { handleReconnectClick }
149- >
150- { t ( 'Reconnect' ) }
151- </ Button >
152- ) }
153-
154- < SelectTrigger className = "flex gap-2 items-center" >
141+ < SelectTrigger
142+ className = "h-14 flex items-center gap-2"
143+ iconClassName = "size-5"
144+ >
145+ < div className = "flex-1 min-w-0 overflow-hidden" >
155146 < SelectValue
156- className = "truncate flex-grow flex-shrink"
157- placeholder = { t ( 'Select a connection' ) }
147+ placeholder = {
148+ < span className = "text-start block" >
149+ { t ( 'Select a connection' ) }
150+ </ span >
151+ }
158152 >
159153 { ! ! field . value && (
160- < div className = "truncate flex-grow flex-shrink " >
154+ < span className = "text-start block truncate text-primary-700 text-base font-medium " >
161155 { removeConnectionBrackets ( field . value ) }
162- </ div >
156+ </ span >
163157 ) }
164158 </ SelectValue >
165- < div className = "grow" > </ div >
166- { /* Hidden Button to take same space as shown button */ }
167- { field . value && (
159+ </ div >
160+
161+ { field . value && ! field . disabled && (
162+ < div className = "shrink-0 flex items-center gap-1" >
168163 < Button
169164 type = "button"
170165 variant = "ghost"
171166 size = "xs"
172- className = "z-50 opacity-0 pointer-events-none"
167+ className = "text-primary-700 text-base font-medium"
168+ onPointerDown = { ( e ) => {
169+ e . stopPropagation ( ) ;
170+ e . preventDefault ( ) ;
171+ } }
172+ onMouseDown = { ( e ) => {
173+ e . stopPropagation ( ) ;
174+ e . preventDefault ( ) ;
175+ } }
176+ onKeyDown = { ( e ) => {
177+ if ( e . key === ' ' || e . key === 'Enter' ) {
178+ e . stopPropagation ( ) ;
179+ e . preventDefault ( ) ;
180+ }
181+ } }
182+ onClick = { ( e ) => {
183+ handleReconnectClick ( e ) ;
184+ } }
173185 >
174- { t ( 'Reconnect' ) }
186+ < PencilLine size = { 16 } />
187+ { t ( 'Edit' ) }
175188 </ Button >
176- ) }
177- </ SelectTrigger >
178- </ div >
179189
190+ < Button
191+ type = "button"
192+ variant = "ghost"
193+ size = "xs"
194+ className = "text-primary-700 text-base font-medium"
195+ onPointerDown = { ( e ) => {
196+ e . stopPropagation ( ) ;
197+ e . preventDefault ( ) ;
198+ } }
199+ onMouseDown = { ( e ) => {
200+ e . stopPropagation ( ) ;
201+ e . preventDefault ( ) ;
202+ } }
203+ onKeyDown = { ( e ) => {
204+ if ( e . key === ' ' || e . key === 'Enter' ) {
205+ e . stopPropagation ( ) ;
206+ e . preventDefault ( ) ;
207+ }
208+ } }
209+ onClick = { ( ) => {
210+ field . onChange ( '' ) ;
211+ } }
212+ >
213+ < X size = { 16 } />
214+ { t ( 'Clear' ) }
215+ </ Button >
216+ </ div >
217+ ) }
218+ </ SelectTrigger >
180219 < SelectContent >
181220 < SelectAction
182221 onClick = { ( ) => {
@@ -187,7 +226,7 @@ const ConnectionSelect = memo((params: ConnectionSelectProps) => {
187226 >
188227 < span className = "flex items-center gap-1 text-primary w-full" >
189228 < Plus size = { 16 } />
190- { t ( 'Create Connection ' ) }
229+ { t ( 'Create new connection ' ) }
191230 </ span >
192231 </ SelectAction >
193232
0 commit comments