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:
Michael Klein 2022-06-30 16:47:04 +02:00 committed by GitHub
parent 90577810cc
commit 362670f98f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 2 deletions

View File

@ -165,6 +165,9 @@ as |nonDefaultPartitions|}}
{{t (concat "common.brand." source)}}
</Option>
{{/each}}
<Option class="consul" @value='consul' @selected={{includes 'consul' @filter.source.value}}>
{{t 'common.brand.consul'}}
</Option>
</Optgroup>
{{/if}}
{{/let}}

View File

@ -88,7 +88,7 @@ export default class TopologyMetrics extends Component {
});
} else if (downstreams.length === 0) {
items.push({
Name: 'No downstreams.',
Name: 'No downstreams, or the downstreams are imported services.',
Datacenter: '',
Namespace: '',
});

View File

@ -20,9 +20,20 @@ export default {
'not-registered': (item, value) => item.InstanceCount === 0,
},
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 (
setHelpers.intersectionSize(values, new Set(item.ExternalSources || [])) !== 0 ||
values.includes(item.Partition)
values.includes(item.Partition) ||
includeBecauseNoExternalSourcesOrPeered
);
},
};

View File

@ -169,4 +169,50 @@ module('Unit | Filter | Predicates | service', function() {
);
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`');
});
});