@@ -12,7 +12,7 @@ import {
1212 scrollviewSetChild ,
1313 textfieldSetString , textfieldGetString , textfieldSetNextKeyView ,
1414 textareaSetString , textareaGetString ,
15- menuCreate , menuAddItem , menuAddSeparator , menuAddSubmenu ,
15+ menuCreate , menuAddItem , menuAddSeparator , menuAddSubmenu , menuAddStandardAction ,
1616 menuBarCreate , menuBarAddMenu , menuBarAttach ,
1717 Window ,
1818} from 'perry/ui' ;
@@ -587,7 +587,6 @@ function refreshConnectionList(): void {
587587 connecting = true ;
588588 buttonSetTitle ( connectBtn , t ( 'Connecting...' ) ) ;
589589 const uri = connectionUris [ connIdx ] || `mongodb://${ connectionHosts [ connIdx ] } :${ connectionPorts [ connIdx ] } ` ;
590- showStatus ( 'Connecting to: ' + uri , false ) ;
591590 const ok = await connectToMongo ( uri ) ;
592591 if ( ok ) {
593592 widgetSetHidden ( statusText , 1 ) ;
@@ -712,17 +711,26 @@ function showConnectionForm(): void {
712711
713712 const saveBtn = Button ( 'Save Connection' , ( ) => {
714713 try {
715- const name = textfieldGetString ( nameField ) || formName || t ( 'Untitled' ) ;
716- const host = textfieldGetString ( hostField ) || formHost || 'localhost' ;
717- const port = textfieldGetString ( portField ) || formPort || '27017' ;
718- const user = textfieldGetString ( userField ) || formUser ;
719- const pass = textfieldGetString ( passField ) || formPass ;
720- const rawUri = textfieldGetString ( uriField ) || formUri ;
714+ const nameRaw = textfieldGetString ( nameField ) ;
715+ const name = ( typeof nameRaw === 'string' && nameRaw . length > 0 ) ? nameRaw : ( formName || t ( 'Untitled' ) ) ;
716+ const hostRaw = textfieldGetString ( hostField ) ;
717+ const host = ( typeof hostRaw === 'string' && hostRaw . length > 0 ) ? hostRaw : ( formHost || 'localhost' ) ;
718+ const portRaw = textfieldGetString ( portField ) ;
719+ const port = ( typeof portRaw === 'string' && portRaw . length > 0 ) ? portRaw : ( formPort || '27017' ) ;
720+ const user = textfieldGetString ( userField ) || '' ;
721+ const pass = textfieldGetString ( passField ) || '' ;
722+ const rawUri = textfieldGetString ( uriField ) || '' ;
721723
722724 // Build URI from fields if no explicit URI provided
723725 let uri = rawUri ;
724726 if ( ! uri ) {
725- if ( user && pass ) {
727+ // Only include auth if BOTH user and pass are non-empty real strings
728+ let hasAuth = false ;
729+ if ( user ) {
730+ const uTest = encodeURIComponent ( user ) ;
731+ if ( uTest . indexOf ( 'undef' ) < 0 && uTest . length > 0 ) hasAuth = true ;
732+ }
733+ if ( hasAuth && pass ) {
726734 uri = 'mongodb://' + encodeURIComponent ( user ) + ':' + encodeURIComponent ( pass ) + '@' + host + ':' + port ;
727735 } else {
728736 uri = 'mongodb://' + host + ':' + port ;
@@ -1770,8 +1778,19 @@ if (!mobile) {
17701778 const appMenu = menuCreate ( ) ;
17711779 menuAddItem ( appMenu , 'About Mango' , ( ) => { aboutWindow . show ( ) ; } ) ;
17721780
1781+ // Edit menu — standard actions routed to first responder for CMD+A/C/V/X
1782+ const editMenu = menuCreate ( ) ;
1783+ menuAddStandardAction ( editMenu , 'Undo' , 'undo:' , 'z' ) ;
1784+ menuAddStandardAction ( editMenu , 'Redo' , 'redo:' , 'Cmd+Shift+z' ) ;
1785+ menuAddSeparator ( editMenu ) ;
1786+ menuAddStandardAction ( editMenu , 'Cut' , 'cut:' , 'x' ) ;
1787+ menuAddStandardAction ( editMenu , 'Copy' , 'copy:' , 'c' ) ;
1788+ menuAddStandardAction ( editMenu , 'Paste' , 'paste:' , 'v' ) ;
1789+ menuAddStandardAction ( editMenu , 'Select All' , 'selectAll:' , 'a' ) ;
1790+
17731791 const menuBar = menuBarCreate ( ) ;
17741792 menuBarAddMenu ( menuBar , 'Mango' , appMenu ) ;
1793+ menuBarAddMenu ( menuBar , 'Edit' , editMenu ) ;
17751794 menuBarAttach ( menuBar ) ;
17761795}
17771796
0 commit comments