Skip to content

Commit 3438b3d

Browse files
committed
Merge pull request #140 from 10gen/INT-647_ns-filter
🐛 INT-647 collection filterable mixing got lost at some point
2 parents efb71f2 + 7861803 commit 3438b3d

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/models/mongodb-instance.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
var MongoDBInstance = require('mongodb-instance-model');
22
var MongoDBCollection = require('./mongodb-collection');
33
var scoutClientMixin = require('./scout-client-mixin');
4+
var filterableMixin = require('ampersand-collection-filterable');
45
var selectableMixin = require('./selectable-collection-mixin');
56
var toNS = require('mongodb-ns');
67

78
/**
89
* A user selectable collection of `MongoDBCollection`'s with `specialish`
910
* collections filtered out.
1011
*/
11-
var MongoDBCollectionOnInstanceCollection = MongoDBCollection.Collection.extend(selectableMixin, {
12+
var MongoDBCollectionOnInstanceCollection = MongoDBCollection.Collection.extend({
1213
namespace: 'MongoDBCollectionOnInstanceCollection',
1314
model: MongoDBCollection,
1415
parse: function(res) {
1516
return res.filter(function(d) {
1617
return !toNS(d._id).specialish;
1718
});
1819
}
19-
});
20+
}, filterableMixin, selectableMixin);
2021

2122
/**
2223
* Metadata for a MongoDB Instance, such as a `db.hostInfo()`, `db.listDatabases()`,

src/sidebar/collection-filter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var View = require('ampersand-view');
2+
var debug = require('debug')('scout:sidebar:collection-filter');
23

34
var CollectionFilterView = View.extend({
45
template: require('./collection-filter.jade'),
@@ -22,7 +23,9 @@ var CollectionFilterView = View.extend({
2223
this.search = this.input.value.trim();
2324
},
2425
applyFilter: function() {
26+
debug('applying filter for `%s`', this.search);
2527
this.parent.filterCollections(this.search);
28+
debug('filter applied');
2629
}
2730
});
2831
module.exports = CollectionFilterView;

src/sidebar/index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
var View = require('ampersand-view');
2-
var _ = require('lodash');
32
var mousetrap = require('mousetrap');
43
var CollectionFilterView = require('./collection-filter');
54
var CollectionListView = require('./collection-list');
65

7-
function fast_filter_collection(collection, pattern) {
8-
var re = new RegExp(pattern || '.*');
9-
collection.filter(function(model) {
10-
return re.test(model.getId());
11-
});
12-
}
13-
146
var SidebarView = View.extend({
157
props: {
168
open: {
@@ -63,7 +55,11 @@ var SidebarView = View.extend({
6355
}
6456
},
6557
filterCollections: function(pattern) {
66-
_.defer(fast_filter_collection, this.collection, pattern);
58+
var re = new RegExp(pattern);
59+
60+
this.collection.filter(function(model) {
61+
return re.test(model.getId());
62+
});
6763
}
6864
});
6965

0 commit comments

Comments
 (0)