@@ -189,6 +189,14 @@ var ConnectView = View.extend({
189
189
onAuthTabClicked : function ( evt ) {
190
190
this . authMethod = $ ( evt . target ) . data ( 'method' ) ;
191
191
} ,
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
+ } ,
192
200
193
201
/**
194
202
* Triggers when the auth methods has changed (or set back to null)
@@ -221,21 +229,15 @@ var ConnectView = View.extend({
221
229
* a list item like in `./sidebar`.
222
230
*
223
231
* @param {Connection } model
224
- * @param {Object } [options]
225
- * @option {Boolean} close - Close the connect dialog on success [Default: `false`].
226
232
* @api public
227
233
*/
228
- connect : function ( model , options ) {
229
- options = _ . defaults ( options || { } , {
230
- close : false
231
- } ) ;
232
-
234
+ connect : function ( model ) {
233
235
app . statusbar . show ( ) ;
234
236
235
237
debug ( 'testing credentials are usable...' ) ;
236
238
model . test ( function ( err ) {
237
239
if ( ! err ) {
238
- this . onConnectionSuccessful ( model , options ) ;
240
+ this . onConnectionSuccessful ( model ) ;
239
241
return ;
240
242
}
241
243
@@ -256,7 +258,7 @@ var ConnectView = View.extend({
256
258
this . onError ( new Error ( 'Could not connect to MongoDB.' ) , model ) ;
257
259
return ;
258
260
}
259
- this . onConnectionSuccessful ( model , options ) ;
261
+ this . onConnectionSuccessful ( model ) ;
260
262
} . bind ( this ) ) ;
261
263
} . bind ( this ) ) ;
262
264
} ,
@@ -266,13 +268,12 @@ var ConnectView = View.extend({
266
268
* view using it.
267
269
*
268
270
* @param {Connection } model
269
- * @param {Object } [options]
270
271
* @api private
271
272
*/
272
- onConnectionSuccessful : function ( model , options ) {
273
- options = _ . defaults ( options , {
274
- close : true
275
- } ) ;
273
+ onConnectionSuccessful : function ( model ) {
274
+ app . statusbar . hide ( ) ;
275
+ this . form . connection_id = '' ;
276
+
276
277
/**
277
278
* The save method will handle calling the correct method
278
279
* of the sync being used by the model, whether that's
@@ -301,9 +302,7 @@ var ConnectView = View.extend({
301
302
message : ''
302
303
} ) , 500 ) ;
303
304
304
- if ( options . close ) {
305
- setTimeout ( window . close , 1000 ) ;
306
- }
305
+ setTimeout ( window . close , 1000 ) ;
307
306
} ,
308
307
/**
309
308
* If there is a validation or connection error show a nice message.
@@ -350,6 +349,7 @@ var ConnectView = View.extend({
350
349
351
350
if ( ! model . isValid ( ) ) {
352
351
this . onError ( model . validationError ) ;
352
+ return ;
353
353
}
354
354
355
355
this . connect ( model ) ;
@@ -363,7 +363,7 @@ var ConnectView = View.extend({
363
363
* @api public
364
364
*/
365
365
onConnectionSelected : function ( model ) {
366
- // If the new model has auth, expand the auth options container
366
+ // If the new model has auth, expand the auth settings container
367
367
// and select the correct tab.
368
368
this . authMethod = model . auth_mechanism ;
369
369
@@ -385,6 +385,8 @@ var ConnectView = View.extend({
385
385
debug ( 'Populating form fields with keys' , keys ) ;
386
386
var values = _ . pick ( model , keys ) ;
387
387
388
+ this . form . connection_id = model . getId ( ) ;
389
+
388
390
// Populates the form from values in the model.
389
391
this . form . setValues ( values ) ;
390
392
} ,
0 commit comments