@@ -109,7 +109,8 @@ const EndpointsPage: React.FC = () => {
109109 const [ apiKey , setApiKey ] = useState ( '' ) ;
110110 const [ endpointStatus , setEndpointStatus ] = useState ( unknownModelEndpointStatus ) ;
111111 const [ endpointOptionsOpen , setEndpointOptionsOpen ] = React . useState < boolean > ( false ) ;
112- const [ deleteEndpointModalOpen , setDeleteEndpointModalOpen ] = useState ( false )
112+ const [ deleteEndpointModalOpen , setDeleteEndpointModalOpen ] = React . useState < boolean > ( false ) ;
113+ const [ deleteEndpointName , setDeleteEndpointName ] = useState ( '' ) ;
113114
114115 useEffect ( ( ) => {
115116 const storedEndpoints = localStorage . getItem ( 'endpoints' ) ;
@@ -187,10 +188,16 @@ const validateEndpointData = (endpoint: ExtendedEndpoint): boolean => {
187188 }
188189 } ;
189190
190- const handleDeleteEndpoint = ( id : string ) => {
191- const updatedEndpoints = endpoints . filter ( ( ep ) => ep . id !== id ) ;
192- setEndpoints ( updatedEndpoints ) ;
193- localStorage . setItem ( 'endpoints' , JSON . stringify ( updatedEndpoints ) ) ;
191+ const handleDeleteEndpoint = ( id : string , endpointName : string ) => {
192+ if ( deleteEndpointName && deleteEndpointName == endpointName ) {
193+ const updatedEndpoints = endpoints . filter ( ( ep ) => ep . id !== id ) ;
194+ setEndpoints ( updatedEndpoints ) ;
195+ localStorage . setItem ( 'endpoints' , JSON . stringify ( updatedEndpoints ) ) ;
196+ setDeleteEndpointModalOpen ( false )
197+ setDeleteEndpointName ( '' )
198+ } else {
199+ alert ( "error: endpoint name did not match!" )
200+ }
194201 } ;
195202
196203 async function handleEditEndpoint ( endpoint : ExtendedEndpoint ) {
@@ -312,26 +319,49 @@ const validateEndpointData = (endpoint: ExtendedEndpoint): boolean => {
312319 ] }
313320 />
314321 < DataListAction aria-labelledby = "endpoint-actions" id = "endpoint-actions" aria-label = "Actions" >
315- < Button variant = "secondary" onClick = { ( ) => console . log ( "stubbing disable" ) } >
322+ < Button variant = "secondary" onClick = { ( ) => {
323+ setDeleteEndpointModalOpen ( true )
324+ } } >
316325 disable
317326 </ Button >
318327 < Button variant = "secondary" onClick = { ( ) => setEndpointOptionsOpen ( true ) } >
319328 < EllipsisVIcon />
320329 </ Button >
321- { /* { deleteEndpointModalOpen ? (
330+ { deleteEndpointModalOpen ? (
322331 < Modal
323332 variant = { ModalVariant . medium }
324- isOpen={isModalOpen}
325- onClose={handleModalToggle}
333+ title = "Delete custom model endpoint?"
334+ isOpen = { deleteEndpointModalOpen }
335+ onClose = { ( ) => setDeleteEndpointModalOpen ( false ) }
326336 aria-labelledby = "confirm-delete-custom-model-endpoint"
327337 aria-describedby = "show-yaml-body-variant"
328338 >
329339 < ModalHeader titleIconVariant = "warning" title = "Delete custom model endpoint?" labelId = "confirm-delete-custom-model-endpoint-title" />
330340 < ModalBody id = "delete-custom-model-endpoint" >
331- some text here
341+ < p style = { { fontSize : "1.25em" } } > The < strong > { endpoint . name } </ strong > custom model endpoint will be deleted.</ p >
342+ < br />
343+ < p > Type < strong > { endpoint . name } </ strong > to confirm. </ p >
344+ < TextInput
345+ isRequired
346+ type = "text"
347+ id = "deleteEndpointByName"
348+ name = "deleteEndpointByName"
349+ title = "type {endpoint.name} to confirm."
350+ value = { deleteEndpointName }
351+ onChange = { ( _ , value ) => setDeleteEndpointName ( value ) }
352+ />
332353 </ ModalBody >
354+ < ModalFooter >
355+ < Button key = "confirm" variant = "primary" onClick = { ( ) => { handleDeleteEndpoint ( endpoint . id , endpoint . name ) } } >
356+ Delete
357+ </ Button >
358+ ,
359+ < Button key = "cancel" variant = "secondary" onClick = { ( ) => { setDeleteEndpointName ( '' ) ; setDeleteEndpointModalOpen ( false ) } } >
360+ Cancel
361+ </ Button >
362+ </ ModalFooter >
333363 </ Modal >
334- ) : null} */ }
364+ ) : null }
335365 { endpointOptionsOpen ? (
336366 < Dropdown
337367 onOpenChange = { ( ) => setEndpointOptionsOpen ( true ) }
@@ -353,10 +383,6 @@ const validateEndpointData = (endpoint: ExtendedEndpoint): boolean => {
353383 isOpen = { endpointOptionsOpen }
354384 ouiaId = "ModelEndpointDropdown"
355385 >
356- { /* <DropdownList>
357- <DropdownItem >Clear chat</DropdownItem>
358- {onClose ? <DropdownItem onClick={onClose}>Close chat</DropdownItem> : null}
359- </DropdownList> */ }
360386 </ Dropdown >
361387 ) : null }
362388 </ DataListAction >
0 commit comments