Skip to content

Commit 6067a2d

Browse files
committed
🧹 Update views for new connection model
1 parent 682b6ec commit 6067a2d

File tree

6 files changed

+51
-45
lines changed

6 files changed

+51
-45
lines changed

gulpfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ gulp.task('build:pages', function() {
191191
* ## electron
192192
*/
193193
gulp.task('electron:start', function() {
194-
var child = spawn(path.resolve(platform.ELECTRON), []);
194+
var child = spawn(path.resolve(platform.ELECTRON), [], {
195+
env: process.env
196+
});
195197
child.stderr.pipe(process.stderr);
196198
child.stdout.pipe(process.stdout);
197199
child.on('exit', function(code) {

src/connect/auth-fields.js

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var inputTemplate = require('./input-default.jade');
1414
/**
1515
* Input field for username. Stores its result in `mongodb_username`.
1616
*/
17-
var username = new InputView({
17+
var mongodb_username = new InputView({
1818
template: inputTemplate,
1919
name: 'mongodb_username',
2020
label: 'Username',
@@ -25,9 +25,9 @@ var username = new InputView({
2525
/**
2626
* Input field for authentication database. Stores its result in `database_name`.
2727
*/
28-
var database_name = new InputView({
28+
var mongodb_database_name = new InputView({
2929
template: inputTemplate,
30-
name: 'database_name',
30+
name: 'mongodb_database_name',
3131
label: 'Authentication Database',
3232
placeholder: 'admin',
3333
required: false
@@ -37,7 +37,7 @@ var database_name = new InputView({
3737
* Input field for password. Stores its result in `mongodb_password`. Uses type='password' to
3838
* hide input.
3939
*/
40-
var password = new InputView({
40+
var mongodb_password = new InputView({
4141
template: inputTemplate,
4242
type: 'password',
4343
name: 'mongodb_password',
@@ -49,34 +49,45 @@ var password = new InputView({
4949
/**
5050
* Input field for GSSAPI service name (Kerberos). Stores its result in `gssapi_service_name`.
5151
*/
52-
var service_name = new InputView({
52+
var kerberos_service_name = new InputView({
5353
template: inputTemplate,
54-
name: 'gssapi_service_name',
54+
name: 'kerberos_service_name',
5555
label: 'Kerberos Service Name',
56+
placeholder: 'mongodb',
57+
required: false
58+
});
59+
60+
var kerberos_principal = new InputView({
61+
template: inputTemplate,
62+
name: 'kerberos_principal',
63+
label: 'Kerberos Principal',
5664
placeholder: '',
5765
required: true
5866
});
5967

68+
var kerberos_password = new InputView({
69+
template: inputTemplate,
70+
type: 'password',
71+
name: 'kerberos_password',
72+
label: 'Password',
73+
placeholder: '',
74+
required: false
75+
});
6076

6177
/**
6278
* Define fields for each auth method here
6379
*/
6480
module.exports = {
65-
'SCRAM-SHA-1': [
66-
username,
67-
password,
68-
database_name
81+
MONGODB: [
82+
mongodb_username,
83+
mongodb_password,
84+
mongodb_database_name
6985
],
70-
GSSAPI: [
71-
username,
72-
service_name
86+
KERBEROS: [
87+
kerberos_service_name,
88+
kerberos_principal,
89+
kerberos_password
7390
],
74-
75-
'MONGODB-X509': [
76-
// @todo what do we need here? nothing?
77-
],
78-
79-
PLAIN: [
80-
// @todo what do we need here? username/pw?
81-
]
91+
X509: [],
92+
PLAIN: []
8293
};

src/connect/connect-form-view.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ var ConnectFormView = FormView.extend({
3131
// clean up the form values here, e.g. conversion to numbers etc.
3232

3333
// get auth mechanism from parent view
34-
obj.auth_mechanism = this.parent.authMethod;
34+
obj.authentication = this.parent.authMethod;
3535

3636
// is SSL enabled (options are open)
37-
obj.ssl = this.parent.sslOpen;
37+
// obj.ssl = this.parent.sslOpen;
3838

3939
// fill in all default fields
4040
obj.hostname = obj.hostname || 'localhost';
@@ -43,7 +43,7 @@ var ConnectFormView = FormView.extend({
4343
// port number must be numeric
4444
obj.port = Number(obj.port);
4545

46-
if (obj.auth_mechanism) {
46+
if (obj.authentication !== 'NONE') {
4747
// default fields for auth
4848
obj.database_name = obj.database_name || 'admin';
4949
}

src/connect/index.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ var ConnectView = View.extend({
154154
evt.preventDefault();
155155
this.toggle('authOpen');
156156
if (this.authOpen) {
157-
this.authMethod = this.previousAuthMethod || 'SCRAM-SHA-1';
157+
this.authMethod = this.previousAuthMethod || 'MONGODB';
158158
} else {
159159
this.authMethod = null;
160160
}
@@ -285,7 +285,7 @@ var ConnectView = View.extend({
285285
* and accoutrement people are actually using IRL.
286286
*
287287
* metrics.trackEvent('connect success', {
288-
* auth_mechanism: model.auth_mechanism,
288+
* authentication: model.authentication,
289289
* ssl: model.ssl
290290
* });
291291
*/
@@ -309,7 +309,7 @@ var ConnectView = View.extend({
309309
* @api private
310310
*/
311311
onError: function(err, model) {
312-
// @todo (imlucas): `metrics.trackEvent('connect error', auth_mechanism + ssl boolean)`
312+
// @todo (imlucas): `metrics.trackEvent('connect error', authentication + ssl boolean)`
313313
debug('showing error message', {
314314
err: err,
315315
model: model
@@ -362,16 +362,9 @@ var ConnectView = View.extend({
362362
onConnectionSelected: function(model) {
363363
// If the new model has auth, expand the auth settings container
364364
// and select the correct tab.
365-
// @note (imlucas): gross, but `this.authMethod` is only used
366-
// for managing auth-fields.js so make this pretty when
367-
// there's more time.
368-
if (model.auth_mechanism === 'MONGODB-CR') {
369-
this.authMethod = 'SCRAM-SHA-1';
370-
} else {
371-
this.authMethod = model.auth_mechanism;
372-
}
365+
this.authMethod = model.authentication;
373366

374-
if (model.auth_mechanism !== null) {
367+
if (model.authentication !== 'NONE') {
375368
this.authOpen = true;
376369
} else {
377370
this.authOpen = false;
@@ -382,7 +375,7 @@ var ConnectView = View.extend({
382375
// so we need to get a list of what keys are currently
383376
// available to set.
384377
var keys = ['name', 'port', 'hostname'];
385-
if (model.auth_mechanism) {
378+
if (model.authentication !== 'NONE') {
386379
keys.push.apply(keys, _.pluck(authFields[this.authMethod], 'name'));
387380
}
388381

@@ -398,22 +391,22 @@ var ConnectView = View.extend({
398391
// @todo (imlucas): Consolidate w/ `./auth-fields.js`.
399392
var authMethods = [
400393
{
401-
_id: 'SCRAM-SHA-1',
394+
_id: 'MONGODB',
402395
title: 'User/Password',
403396
enabled: true
404397
},
405398
{
406-
_id: 'GSSAPI',
399+
_id: 'KERBEROS',
407400
title: 'Kerberos',
408401
enabled: app.isFeatureEnabled('Connect with Kerberos')
409402
},
410403
{
411-
_id: 'PLAIN',
404+
_id: 'LDAP',
412405
title: 'LDAP',
413406
enabled: app.isFeatureEnabled('Connect with LDAP')
414407
},
415408
{
416-
_id: 'MONGODB-X509',
409+
_id: 'X509',
417410
title: 'X.509',
418411
enabled: app.isFeatureEnabled('Connect with X.509')
419412
}

src/connect/sidebar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ var SidebarItemView = View.extend({
3838
},
3939
derived: {
4040
has_auth: {
41-
deps: ['model.auth_mechanism'],
41+
deps: ['model.authentication'],
4242
fn: function() {
43-
return this.model.auth_mechanism !== null;
43+
return this.model.authentication !== 'NONE';
4444
}
4545
}
4646
},

src/models/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = Connection.extend({
3434

3535
debug('test worked!');
3636
debug('making sure we can get collection list...');
37-
client.instance(function(err, res) {
37+
client(app.endpoint, this).instance(function(err, res) {
3838
if (!err) {
3939
debug('woot. all gravy! able to see %s collections', res.collections.length);
4040
done(null, model);

0 commit comments

Comments
 (0)