ui: peering chores (#13636)
* Update empty state topology downstreams to included peer info * Add filter for filtering for service without ExternalSources
This commit is contained in:
parent
90577810cc
commit
362670f98f
|
@ -165,6 +165,9 @@ as |nonDefaultPartitions|}}
|
||||||
{{t (concat "common.brand." source)}}
|
{{t (concat "common.brand." source)}}
|
||||||
</Option>
|
</Option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
<Option class="consul" @value='consul' @selected={{includes 'consul' @filter.source.value}}>
|
||||||
|
{{t 'common.brand.consul'}}
|
||||||
|
</Option>
|
||||||
</Optgroup>
|
</Optgroup>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/let}}
|
{{/let}}
|
||||||
|
|
|
@ -88,7 +88,7 @@ export default class TopologyMetrics extends Component {
|
||||||
});
|
});
|
||||||
} else if (downstreams.length === 0) {
|
} else if (downstreams.length === 0) {
|
||||||
items.push({
|
items.push({
|
||||||
Name: 'No downstreams.',
|
Name: 'No downstreams, or the downstreams are imported services.',
|
||||||
Datacenter: '',
|
Datacenter: '',
|
||||||
Namespace: '',
|
Namespace: '',
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,9 +20,20 @@ export default {
|
||||||
'not-registered': (item, value) => item.InstanceCount === 0,
|
'not-registered': (item, value) => item.InstanceCount === 0,
|
||||||
},
|
},
|
||||||
source: (item, values) => {
|
source: (item, values) => {
|
||||||
|
let includeBecauseNoExternalSourcesOrPeered = false;
|
||||||
|
|
||||||
|
if (values.includes('consul')) {
|
||||||
|
includeBecauseNoExternalSourcesOrPeered =
|
||||||
|
!item.ExternalSources ||
|
||||||
|
item.ExternalSources.length === 0 ||
|
||||||
|
(item.ExternalSources.length === 1 && item.ExternalSources[0] === '') ||
|
||||||
|
item.PeerName;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
setHelpers.intersectionSize(values, new Set(item.ExternalSources || [])) !== 0 ||
|
setHelpers.intersectionSize(values, new Set(item.ExternalSources || [])) !== 0 ||
|
||||||
values.includes(item.Partition)
|
values.includes(item.Partition) ||
|
||||||
|
includeBecauseNoExternalSourcesOrPeered
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -169,4 +169,50 @@ module('Unit | Filter | Predicates | service', function() {
|
||||||
);
|
);
|
||||||
assert.deepEqual(actual, expected);
|
assert.deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('it returns items without an External Source or items with a peer name when source `consul` is specified', function(assert) {
|
||||||
|
const items = [
|
||||||
|
{
|
||||||
|
_Name: 'external',
|
||||||
|
ExternalSources: ['aws'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_Name: 'empty-array',
|
||||||
|
ExternalSources: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_Name: 'peered-external',
|
||||||
|
ExternalSources: ['terraform'],
|
||||||
|
PeerName: 'peer-1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_Name: 'peered',
|
||||||
|
ExternalSources: [],
|
||||||
|
PeerName: 'peer-2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_Name: 'undefined',
|
||||||
|
ExternalSources: undefined,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_Name: 'empty-string',
|
||||||
|
ExternalSources: [''],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_Name: 'empty-string-with-additional-source',
|
||||||
|
ExternalSources: ['', 'nomad'],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const filteredItems = items.filter(
|
||||||
|
predicate({
|
||||||
|
source: ['consul'],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const actual = filteredItems.map(i => i._Name);
|
||||||
|
|
||||||
|
const expected = ['empty-array', 'peered-external', 'peered', 'undefined', 'empty-string'];
|
||||||
|
assert.deepEqual(actual, expected, 'filtering works with source `consul`');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue