Skip to content

Commit d89c2ac

Browse files
rueckstiesskangas
authored andcommitted
more error checking and feedback to user
1 parent 81a966c commit d89c2ac

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/connect/index.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
input.form-control(type='number', name='port', placeholder='27017', data-hook='port')
1515
.form-group
1616
label.col-sm-2.control-label Connection Name (optional)
17-
a.btn.btn-info.btn-circle.btn-circle-micro(tabindex="0", role="button", data-toggle="popover", data-trigger="focus", title="Connection Name", data-content="You can choose a friendly connection name for this connection, for example \"Development Server\". The connection will appear on the left side under this name.")
18-
i.fa.fa-question
17+
i.fa.fa-info-circle(tabindex="0", role="button", data-toggle="popover", data-trigger="focus", title="Connection Name", data-content="You can choose a friendly connection name for this connection, for example \"Development Server\". The connection will appear on the left side under this name.")
18+
1919
.col-sm-10
2020
input.form-control(type='text', name='name', placeholder='My Localhost', data-hook='name')
2121
.form-group

src/connect/index.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,25 @@ var ConnectView = View.extend({
157157
+ 'under the name "%s". Click "Connect" again to connect to this host.',
158158
existingConnection.name);
159159
this.displayedConnection.name = existingConnection.name;
160-
} else {
161-
// now test if the server is reachable
162-
app.statusbar.show();
163-
this.message = format('Testing connection...');
164-
this.displayedConnection.test(this.onConnectionTested.bind(this));
160+
return;
165161
}
162+
163+
// now test if the connection name already exists with another uri
164+
existingConnection = this.connections.get(this.displayedConnection.name, 'name');
165+
if (existingConnection && existingConnection.uri !== this.displayedConnection.uri) {
166+
// the connection name exists already, but with a different uri
167+
app.statusbar.hide();
168+
this.has_error = true;
169+
this.message = format('A different connection with the name "%s" already exists. Please '
170+
+ 'choose a different name.',
171+
existingConnection.name);
172+
return;
173+
}
174+
175+
// now test if the server is reachable
176+
app.statusbar.show();
177+
this.message = format('Testing connection...');
178+
this.displayedConnection.test(this.onConnectionTested.bind(this));
166179
},
167180
onConnectionTested: function(err, model) {
168181
app.statusbar.hide();

src/models/connection-collection.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ module.exports = Collection.extend(lodashMixin, restMixin, {
99
model: Connection,
1010
comparator: 'last_used',
1111
mainIndex: 'uri',
12+
indexes: ['name'],
1213
sync: connectionSync
1314
});

0 commit comments

Comments
 (0)