@@ -447,7 +447,10 @@ function openModal(modalId) {
447
447
}
448
448
449
449
// Reset modal state
450
- resetModalState ( modalId ) ;
450
+ const resetModelVariable = false ;
451
+ if ( resetModelVariable ) {
452
+ resetModalState ( modalId ) ;
453
+ }
451
454
452
455
modal . classList . remove ( "hidden" ) ;
453
456
AppState . setModalActive ( modalId ) ;
@@ -1512,6 +1515,106 @@ async function editTool(toolId) {
1512
1515
requestTypeField . value = tool . requestType || "SSE" ;
1513
1516
}
1514
1517
1518
+ // Set auth type field
1519
+ const authTypeField = safeGetElement ( "edit-auth-type" ) ;
1520
+ if ( authTypeField ) {
1521
+ authTypeField . value = tool . auth ?. authType || "" ;
1522
+ }
1523
+
1524
+ // Auth containers
1525
+ const authBasicSection = safeGetElement ( "edit-auth-basic-fields" ) ;
1526
+ const authBearerSection = safeGetElement ( "edit-auth-bearer-fields" ) ;
1527
+ const authHeadersSection = safeGetElement ( "edit-auth-headers-fields" ) ;
1528
+
1529
+ // Individual fields
1530
+ const authUsernameField = authBasicSection ?. querySelector (
1531
+ "input[name='auth_username']" ,
1532
+ ) ;
1533
+ const authPasswordField = authBasicSection ?. querySelector (
1534
+ "input[name='auth_password']" ,
1535
+ ) ;
1536
+
1537
+ const authTokenField = authBearerSection ?. querySelector (
1538
+ "input[name='auth_token']" ,
1539
+ ) ;
1540
+
1541
+ const authHeaderKeyField = authHeadersSection ?. querySelector (
1542
+ "input[name='auth_header_key']" ,
1543
+ ) ;
1544
+ const authHeaderValueField = authHeadersSection ?. querySelector (
1545
+ "input[name='auth_header_value']" ,
1546
+ ) ;
1547
+
1548
+ // Hide all auth sections first
1549
+ if ( authBasicSection ) {
1550
+ authBasicSection . style . display = "none" ;
1551
+ }
1552
+ if ( authBearerSection ) {
1553
+ authBearerSection . style . display = "none" ;
1554
+ }
1555
+ if ( authHeadersSection ) {
1556
+ authHeadersSection . style . display = "none" ;
1557
+ }
1558
+
1559
+ // Clear old values
1560
+ if ( authUsernameField ) {
1561
+ authUsernameField . value = "" ;
1562
+ }
1563
+ if ( authPasswordField ) {
1564
+ authPasswordField . value = "" ;
1565
+ }
1566
+ if ( authTokenField ) {
1567
+ authTokenField . value = "" ;
1568
+ }
1569
+ if ( authHeaderKeyField ) {
1570
+ authHeaderKeyField . value = "" ;
1571
+ }
1572
+ if ( authHeaderValueField ) {
1573
+ authHeaderValueField . value = "" ;
1574
+ }
1575
+
1576
+ // Display appropriate auth section and populate values
1577
+ switch ( tool . auth ?. authType ) {
1578
+ case "basic" :
1579
+ if ( authBasicSection ) {
1580
+ authBasicSection . style . display = "block" ;
1581
+ if ( authUsernameField ) {
1582
+ authUsernameField . value = tool . auth . username || "" ;
1583
+ }
1584
+ if ( authPasswordField ) {
1585
+ authPasswordField . value = "*****" ; // masked
1586
+ }
1587
+ }
1588
+ break ;
1589
+
1590
+ case "bearer" :
1591
+ if ( authBearerSection ) {
1592
+ authBearerSection . style . display = "block" ;
1593
+ if ( authTokenField ) {
1594
+ authTokenField . value = "*****" ; // masked
1595
+ }
1596
+ }
1597
+ break ;
1598
+
1599
+ case "authheaders" :
1600
+ if ( authHeadersSection ) {
1601
+ authHeadersSection . style . display = "block" ;
1602
+ if ( authHeaderKeyField ) {
1603
+ authHeaderKeyField . value =
1604
+ tool . auth . authHeaderKey || "" ;
1605
+ }
1606
+ if ( authHeaderValueField ) {
1607
+ authHeaderValueField . value = "*****" ; // masked
1608
+ }
1609
+ }
1610
+ break ;
1611
+
1612
+ case "" :
1613
+ default :
1614
+ // No auth – keep everything hidden
1615
+ break ;
1616
+ }
1617
+
1515
1618
openModal ( "tool-edit-modal" ) ;
1516
1619
1517
1620
// Ensure editors are refreshed after modal display
@@ -2176,6 +2279,8 @@ async function editGateway(gatewayId) {
2176
2279
const urlField = safeGetElement ( "edit-gateway-url" ) ;
2177
2280
const descField = safeGetElement ( "edit-gateway-description" ) ;
2178
2281
2282
+ const transportField = safeGetElement ( "edit-gateway-transport" ) ;
2283
+
2179
2284
if ( nameField && nameValidation . valid ) {
2180
2285
nameField . value = nameValidation . value ;
2181
2286
}
@@ -2186,6 +2291,90 @@ async function editGateway(gatewayId) {
2186
2291
descField . value = gateway . description || "" ;
2187
2292
}
2188
2293
2294
+ if ( transportField ) {
2295
+ transportField . value = gateway . transport || "SSE" ; // falls back to SSE(default)
2296
+ }
2297
+
2298
+ const authTypeField = safeGetElement ( "auth-type-gw-edit" ) ;
2299
+
2300
+ if ( authTypeField ) {
2301
+ authTypeField . value = gateway . authType || "" ; // falls back to None
2302
+ }
2303
+
2304
+ // Auth containers
2305
+ const authBasicSection = safeGetElement ( "auth-basic-fields-gw-edit" ) ;
2306
+ const authBearerSection = safeGetElement ( "auth-bearer-fields-gw-edit" ) ;
2307
+ const authHeadersSection = safeGetElement (
2308
+ "auth-headers-fields-gw-edit" ,
2309
+ ) ;
2310
+
2311
+ // Individual fields
2312
+ const authUsernameField = safeGetElement (
2313
+ "auth-basic-fields-gw-edit" ,
2314
+ ) ?. querySelector ( "input[name='auth_username']" ) ;
2315
+ const authPasswordField = safeGetElement (
2316
+ "auth-basic-fields-gw-edit" ,
2317
+ ) ?. querySelector ( "input[name='auth_password']" ) ;
2318
+
2319
+ const authTokenField = safeGetElement (
2320
+ "auth-bearer-fields-gw-edit" ,
2321
+ ) ?. querySelector ( "input[name='auth_token']" ) ;
2322
+
2323
+ const authHeaderKeyField = safeGetElement (
2324
+ "auth-headers-fields-gw-edit" ,
2325
+ ) ?. querySelector ( "input[name='auth_header_key']" ) ;
2326
+ const authHeaderValueField = safeGetElement (
2327
+ "auth-headers-fields-gw-edit" ,
2328
+ ) ?. querySelector ( "input[name='auth_header_value']" ) ;
2329
+
2330
+ // Hide all auth sections first
2331
+ if ( authBasicSection ) {
2332
+ authBasicSection . style . display = "none" ;
2333
+ }
2334
+ if ( authBearerSection ) {
2335
+ authBearerSection . style . display = "none" ;
2336
+ }
2337
+ if ( authHeadersSection ) {
2338
+ authHeadersSection . style . display = "none" ;
2339
+ }
2340
+
2341
+ switch ( gateway . authType ) {
2342
+ case "basic" :
2343
+ if ( authBasicSection ) {
2344
+ authBasicSection . style . display = "block" ;
2345
+ if ( authUsernameField ) {
2346
+ authUsernameField . value = gateway . authUsername || "" ;
2347
+ }
2348
+ if ( authPasswordField ) {
2349
+ authPasswordField . value = "*****" ; // mask password
2350
+ }
2351
+ }
2352
+ break ;
2353
+ case "bearer" :
2354
+ if ( authBearerSection ) {
2355
+ authBearerSection . style . display = "block" ;
2356
+ if ( authTokenField ) {
2357
+ authTokenField . value = gateway . authValue || "" ; // show full token
2358
+ }
2359
+ }
2360
+ break ;
2361
+ case "authheaders" :
2362
+ if ( authHeadersSection ) {
2363
+ authHeadersSection . style . display = "block" ;
2364
+ if ( authHeaderKeyField ) {
2365
+ authHeaderKeyField . value = gateway . authHeaderKey || "" ;
2366
+ }
2367
+ if ( authHeaderValueField ) {
2368
+ authHeaderValueField . value = "*****" ; // mask header value
2369
+ }
2370
+ }
2371
+ break ;
2372
+ case "" :
2373
+ default :
2374
+ // No auth – keep everything hidden
2375
+ break ;
2376
+ }
2377
+
2189
2378
openModal ( "gateway-edit-modal" ) ;
2190
2379
console . log ( "✓ Gateway edit modal loaded successfully" ) ;
2191
2380
} catch ( error ) {
0 commit comments