Skip to content

Commit 8a47e19

Browse files
author
Robert Jackson
committed
Make slow-node-times component focused on broccoli nodes.
1 parent 35ad691 commit 8a47e19

File tree

2 files changed

+9
-62
lines changed

2 files changed

+9
-62
lines changed

app/components/slow-node-times.js

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,19 @@ const {
44
computed
55
} = Ember;
66

7-
function filterForAddonInitializationNodes(nodes) {
8-
return nodes.filter((node) => node.label.addonInitializationNode);
9-
}
10-
11-
function filterForAddonDiscoveryNodes(nodes) {
12-
return nodes.filter((node) => node.label.addonDiscoveryNode);
13-
}
14-
15-
function filterForBroccoliNodes(nodes, instance) {
16-
let pluginName = instance.get('pluginNameFilter');
17-
18-
return nodes.filter((node) => {
19-
if (!node.label.broccoliNode) { return false; }
20-
if (pluginName && node.label.broccoliPluginName !== pluginName) { return false; }
21-
22-
return true;
23-
})
24-
}
25-
267
export default Ember.Component.extend({
27-
init() {
28-
this._super(...arguments);
29-
this.filterType = 'broccoli-node';
30-
},
31-
32-
filter: filterForBroccoliNodes,
33-
348
nodes: computed('data', 'filter', 'pluginNameFilter', 'groupByPluginName', function() {
359
let data = this.get('data');
36-
let filter = this.get('filter');
3710
let groupByPluginName = this.get('groupByPluginName');
11+
let pluginName = this.get('pluginNameFilter');
3812
if (!data) { return []; }
3913

40-
let nodes = data.nodes;
14+
let nodes = data.nodes.filter((node) => {
15+
if (!node.label.broccoliNode) { return false; }
16+
if (pluginName && node.label.broccoliPluginName !== pluginName) { return false; }
4117

42-
if (filter) {
43-
nodes = filter(nodes, this);
44-
}
18+
return true;
19+
})
4520

4621
if (groupByPluginName) {
4722
let pluginNameMap = nodes.reduce((memo, node) => {
@@ -80,24 +55,5 @@ export default Ember.Component.extend({
8055
}),
8156

8257
actions: {
83-
updateFilter(event) {
84-
let filter;
85-
let filterType = event.target.value;
86-
87-
switch(filterType) {
88-
case 'addon-discovery':
89-
filter = filterForAddonDiscoveryNodes;
90-
break;
91-
case 'addon-initialization':
92-
filter = filterForAddonInitializationNodes;
93-
break;
94-
case 'broccoli-node':
95-
filter = filterForBroccoliNodes;
96-
break;
97-
}
98-
99-
this.set('filter', filter);
100-
this.set('filterType', filterType);
101-
}
10258
}
10359
});

app/templates/components/slow-node-times.hbs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
<select onchange={{action 'updateFilter'}}>
2-
<option value="addon-discovery">Show Addon Discovery</option>
3-
<option value="addon-initialization">Show Addon Initialization</option>
4-
<option selected value="broccoli-node">Show Broccoli Nodes</option>
5-
</select>
6-
7-
{{#if (eq filterType 'broccoli-node')}}
8-
{{input value=pluginNameFilter placeholder="Filter by plugin name..."}}
9-
<label>Group by Plugin Name{{input type="checkbox" checked=groupByPluginName}}</label>
10-
<button {{action (action (mut pluginNameFilter) '')}}>Clear</button>
11-
{{/if}}
12-
1+
{{input value=pluginNameFilter placeholder="Filter by plugin name..."}}
2+
<label>Group by Plugin Name{{input type="checkbox" checked=groupByPluginName}}</label>
3+
<button {{action (action (mut pluginNameFilter) '')}}>Clear</button>
134

145
<table>
156
<thead>

0 commit comments

Comments
 (0)