Merge pull request #5748 from hashicorp/b-ui/prefix-regex

Include the _ prefix separator in both regexes
This commit is contained in:
Michael Lange 2019-05-21 14:44:14 -07:00 committed by GitHub
commit 99205e1865
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 11 deletions

View File

@ -61,11 +61,7 @@ export default Controller.extend(Sortable, Searchable, {
optionsDatacenter: computed('visibleJobs.[]', function() { optionsDatacenter: computed('visibleJobs.[]', function() {
const flatten = (acc, val) => acc.concat(val); const flatten = (acc, val) => acc.concat(val);
const allDatacenters = new Set( const allDatacenters = new Set(this.visibleJobs.mapBy('datacenters').reduce(flatten, []));
this.visibleJobs
.mapBy('datacenters')
.reduce(flatten, [])
);
// Remove any invalid datacenters from the query param/selection // Remove any invalid datacenters from the query param/selection
const availableDatacenters = Array.from(allDatacenters).compact(); const availableDatacenters = Array.from(allDatacenters).compact();
@ -88,7 +84,7 @@ export default Controller.extend(Sortable, Searchable, {
const allNames = this.visibleJobs.mapBy('name'); const allNames = this.visibleJobs.mapBy('name');
const nameHistogram = allNames.reduce((hist, name) => { const nameHistogram = allNames.reduce((hist, name) => {
if (hasPrefix.test(name)) { if (hasPrefix.test(name)) {
const prefix = name.match(/(.+?)[-.]/)[1]; const prefix = name.match(/(.+?)[-._]/)[1];
hist[prefix] = hist[prefix] ? hist[prefix] + 1 : 1; hist[prefix] = hist[prefix] ? hist[prefix] + 1 : 1;
} }
return hist; return hist;

View File

@ -230,13 +230,13 @@ module('Acceptance | jobs list', function(hooks) {
async beforeEach() { async beforeEach() {
[ [
'pre-one', 'pre-one',
'hashi-one', 'hashi_one',
'nmd-one', 'nmd.one',
'one-alone', 'one-alone',
'pre-two', 'pre_two',
'hashi-two', 'hashi.two',
'hashi-three', 'hashi-three',
'nmd-two', 'nmd_two',
'noprefix', 'noprefix',
].forEach(name => { ].forEach(name => {
server.create('job', { name, createAllocations: false, childrenCount: 0 }); server.create('job', { name, createAllocations: false, childrenCount: 0 });