Skip to content

Commit 5069c12

Browse files
committed
fix fmt/lint/test
1 parent 779616e commit 5069c12

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

web/src/components/netflow-traffic.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Filters, getDisabledFiltersRecord, getEnabledFilters } from '../model/f
1010
import { filtersToString, FlowQuery, MetricType } from '../model/flow-query';
1111
import { netflowTrafficModel } from '../model/netflow-traffic';
1212
import { parseQuickFilters } from '../model/quick-filters';
13+
import { resolveGroupTypes } from '../model/scope';
1314
import { getFetchFunctions as getBackAndForthFetch } from '../utils/back-and-forth';
1415
import { ColumnsId, getDefaultColumns } from '../utils/columns';
1516
import { loadConfig } from '../utils/config';
@@ -58,7 +59,6 @@ import { FiltersToolbar } from './toolbar/filters-toolbar';
5859
import ChipsPopover from './toolbar/filters/chips-popover';
5960
import HistogramToolbar from './toolbar/histogram-toolbar';
6061
import ViewOptionsToolbar from './toolbar/view-options-toolbar';
61-
import { resolveGroupTypes } from '../model/scope';
6262

6363
export type ViewId = 'overview' | 'table' | 'topology';
6464

@@ -312,7 +312,8 @@ export const NetflowTraffic: React.FC<NetflowTrafficProps> = ({
312312
model.selectedViewId,
313313
model.topologyMetricType,
314314
model.metricScope,
315-
model.topologyOptions.groupTypes
315+
model.topologyOptions.groupTypes,
316+
getAvailableScopes
316317
]);
317318

318319
const getFetchFunctions = React.useCallback(() => {

web/src/model/__tests__/topology.spec.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ScopeDefSample } from '../../components/__tests-data__/scopes';
22
import { ContextSingleton } from '../../utils/context';
3-
import { getGroupName, getGroupsForScope, getStepInto } from '../scope';
3+
import { getGroupName, getGroupsForScope, getStepInto, resolveGroupTypes } from '../scope';
44

55
describe('Check enabled groups', () => {
66
beforeEach(() => {
@@ -9,14 +9,15 @@ describe('Check enabled groups', () => {
99

1010
it('should get group from scope', () => {
1111
let groups = getGroupsForScope('cluster', ScopeDefSample);
12-
expect(groups).toEqual(['none']);
12+
expect(groups).toEqual(['none', 'auto']);
1313

1414
groups = getGroupsForScope('host', ScopeDefSample);
15-
expect(groups).toEqual(['none', 'clusters', 'zones', 'clusters+zones']);
15+
expect(groups).toEqual(['none', 'auto', 'clusters', 'zones', 'clusters+zones']);
1616

1717
groups = getGroupsForScope('owner', ScopeDefSample);
1818
expect(groups).toEqual([
1919
'none',
20+
'auto',
2021
'clusters',
2122
'clusters+zones',
2223
'clusters+hosts',
@@ -30,6 +31,23 @@ describe('Check enabled groups', () => {
3031
]);
3132
});
3233

34+
it('should resolve auto group', () => {
35+
let group = resolveGroupTypes('auto', 'resource', ScopeDefSample);
36+
expect(group).toEqual('namespaces');
37+
38+
group = resolveGroupTypes('auto', 'owner', ScopeDefSample);
39+
expect(group).toEqual('namespaces');
40+
41+
group = resolveGroupTypes('auto', 'namespace', ScopeDefSample);
42+
expect(group).toEqual('none');
43+
44+
group = resolveGroupTypes('auto', 'host', ScopeDefSample);
45+
expect(group).toEqual('none');
46+
47+
group = resolveGroupTypes('hosts', 'resource', ScopeDefSample);
48+
expect(group).toEqual('hosts');
49+
});
50+
3351
it('should get group name', () => {
3452
let name = getGroupName('hosts', ScopeDefSample, (s: string) => s);
3553
expect(name).toEqual('Node');

web/src/model/scope.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export const getGroupsForScope = (scopeId: FlowScope, scopes: ScopeConfigDef[]):
3131
return ['none', 'auto'];
3232
};
3333

34-
export const resolveGroupTypes = (inGroupTypes: TopologyGroupTypes, scopeId: FlowScope, scopes: ScopeConfigDef[]): TopologyGroupTypes => {
34+
export const resolveGroupTypes = (
35+
inGroupTypes: TopologyGroupTypes,
36+
scopeId: FlowScope,
37+
scopes: ScopeConfigDef[]
38+
): TopologyGroupTypes => {
3539
if (inGroupTypes === 'auto') {
3640
const groups = getGroupsForScope(scopeId, scopes);
3741
if (groups.includes('namespaces')) {

0 commit comments

Comments
 (0)