@@ -189,6 +189,21 @@ var ConnectView = View.extend({
189189 onAuthTabClicked : function ( evt ) {
190190 this . authMethod = $ ( evt . target ) . data ( 'method' ) ;
191191 } ,
192+ createNewConnection : function ( ) {
193+ debug ( 'new connection requested' ) ;
194+ this . reset ( ) ;
195+ this . form . connection_id = '' ;
196+ this . form . reset ( ) ;
197+ this . authMethod = null ;
198+ this . authOpen = false ;
199+ } ,
200+ onConnectionDestroyed : function ( ) {
201+ this . reset ( ) ;
202+ this . form . connection_id = '' ;
203+ this . form . reset ( ) ;
204+ this . authMethod = null ;
205+ this . authOpen = false ;
206+ } ,
192207
193208 /**
194209 * Triggers when the auth methods has changed (or set back to null)
@@ -221,21 +236,15 @@ var ConnectView = View.extend({
221236 * a list item like in `./sidebar`.
222237 *
223238 * @param {Connection } model
224- * @param {Object } [options]
225- * @option {Boolean} close - Close the connect dialog on success [Default: `false`].
226239 * @api public
227240 */
228- connect : function ( model , options ) {
229- options = _ . defaults ( options || { } , {
230- close : false
231- } ) ;
232-
241+ connect : function ( model ) {
233242 app . statusbar . show ( ) ;
234243
235244 debug ( 'testing credentials are usable...' ) ;
236245 model . test ( function ( err ) {
237246 if ( ! err ) {
238- this . onConnectionSuccessful ( model , options ) ;
247+ this . onConnectionSuccessful ( model ) ;
239248 return ;
240249 }
241250
@@ -256,7 +265,7 @@ var ConnectView = View.extend({
256265 this . onError ( new Error ( 'Could not connect to MongoDB.' ) , model ) ;
257266 return ;
258267 }
259- this . onConnectionSuccessful ( model , options ) ;
268+ this . onConnectionSuccessful ( model ) ;
260269 } . bind ( this ) ) ;
261270 } . bind ( this ) ) ;
262271 } ,
@@ -266,13 +275,12 @@ var ConnectView = View.extend({
266275 * view using it.
267276 *
268277 * @param {Connection } model
269- * @param {Object } [options]
270278 * @api private
271279 */
272- onConnectionSuccessful : function ( model , options ) {
273- options = _ . defaults ( options , {
274- close : true
275- } ) ;
280+ onConnectionSuccessful : function ( model ) {
281+ app . statusbar . hide ( ) ;
282+ this . form . connection_id = '' ;
283+
276284 /**
277285 * The save method will handle calling the correct method
278286 * of the sync being used by the model, whether that's
@@ -301,9 +309,7 @@ var ConnectView = View.extend({
301309 message : ''
302310 } ) , 500 ) ;
303311
304- if ( options . close ) {
305- setTimeout ( window . close , 1000 ) ;
306- }
312+ setTimeout ( window . close , 1000 ) ;
307313 } ,
308314 /**
309315 * If there is a validation or connection error show a nice message.
@@ -350,6 +356,7 @@ var ConnectView = View.extend({
350356
351357 if ( ! model . isValid ( ) ) {
352358 this . onError ( model . validationError ) ;
359+ return ;
353360 }
354361
355362 this . connect ( model ) ;
@@ -363,7 +370,7 @@ var ConnectView = View.extend({
363370 * @api public
364371 */
365372 onConnectionSelected : function ( model ) {
366- // If the new model has auth, expand the auth options container
373+ // If the new model has auth, expand the auth settings container
367374 // and select the correct tab.
368375 this . authMethod = model . auth_mechanism ;
369376
@@ -385,6 +392,8 @@ var ConnectView = View.extend({
385392 debug ( 'Populating form fields with keys' , keys ) ;
386393 var values = _ . pick ( model , keys ) ;
387394
395+ this . form . connection_id = model . getId ( ) ;
396+
388397 // Populates the form from values in the model.
389398 this . form . setValues ( values ) ;
390399 } ,
0 commit comments