Skip to content

Commit f712d05

Browse files
committed
address feedback
1 parent 3b4f9ce commit f712d05

File tree

11 files changed

+113
-109
lines changed

11 files changed

+113
-109
lines changed

config/sample-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ frontend:
292292
- id: SrcK8S_OwnerObject
293293
group: Source
294294
name: Owner Kubernetes Object
295-
calculated: kubeObject(SrcK8S_OwnerType,SrcK8S_Namespace,SrcK8S_OwnerName,1) or concat(SrcAddr,':',SrcPort)
295+
calculated: kubeObject(SrcK8S_OwnerType,SrcK8S_Namespace,SrcK8S_OwnerName,1)
296296
default: false
297297
width: 15
298298
- id: SrcAddrPort

web/package-lock.json

Lines changed: 1 addition & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@
8686
"webpack": "^5.94.0",
8787
"webpack-cli": "^4.10.0",
8888
"webpack-dev-server": "^4.6.0",
89-
"webpack-node-externals": "^3.0.0",
90-
"yaml": "^2.6.0"
89+
"webpack-node-externals": "^3.0.0"
9190
},
9291
"consolePlugin": {
9392
"name": "netobserv-plugin",

web/src/components/__tests-data__/columns.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const ColumnConfigSampleDefs = [
4545
docURL: 'http://kubernetes.io/docs/user-guide/identifiers#names',
4646
field: 'SrcK8S_Name',
4747
filter: 'src_name',
48+
calculated: 'kubeObject(SrcK8S_Type,SrcK8S_Namespace,SrcK8S_Name,0)',
4849
default: true,
4950
width: 15
5051
},
@@ -66,6 +67,7 @@ export const ColumnConfigSampleDefs = [
6667
docURL: 'https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/',
6768
field: 'SrcK8S_OwnerName',
6869
filter: 'src_owner_name',
70+
calculated: 'kubeObject(SrcK8S_OwnerType,SrcK8S_Namespace,SrcK8S_OwnerName,0)',
6971
default: false,
7072
width: 15
7173
},
@@ -88,6 +90,7 @@ export const ColumnConfigSampleDefs = [
8890
docURL: 'http://kubernetes.io/docs/user-guide/identifiers#namespaces',
8991
field: 'SrcK8S_Namespace',
9092
filter: 'src_namespace',
93+
calculated: `kubeObject('Namespace','',SrcK8S_Namespace,0)`,
9194
default: true,
9295
width: 15
9396
},
@@ -139,27 +142,31 @@ export const ColumnConfigSampleDefs = [
139142
docURL: 'https://kubernetes.io/docs/concepts/architecture/nodes/',
140143
field: 'SrcK8S_HostName',
141144
filter: 'src_host_name',
145+
calculated: `kubeObject('Node','',SrcK8S_HostName,0)`,
142146
default: false,
143147
width: 15
144148
},
145149
{
146150
id: 'SrcK8S_Object',
147151
group: 'Source',
148152
name: 'Kubernetes Object',
153+
calculated: `kubeObject(SrcK8S_Type,SrcK8S_Namespace,SrcK8S_Name,1) or concat(SrcAddr,':',SrcPort)`,
149154
default: false,
150155
width: 15
151156
},
152157
{
153158
id: 'SrcK8S_OwnerObject',
154159
group: 'Source',
155160
name: 'Owner Kubernetes Object',
161+
calculated: `kubeObject(SrcK8S_OwnerType,SrcK8S_Namespace,SrcK8S_OwnerName,1)`,
156162
default: false,
157163
width: 15
158164
},
159165
{
160166
id: 'SrcAddrPort',
161167
group: 'Source',
162168
name: 'IP & Port',
169+
calculated: `concat(SrcAddr,':',SrcPort)`,
163170
default: false,
164171
width: 15
165172
},
@@ -171,6 +178,7 @@ export const ColumnConfigSampleDefs = [
171178
docURL: 'http://kubernetes.io/docs/user-guide/identifiers#names',
172179
field: 'DstK8S_Name',
173180
filter: 'dst_name',
181+
calculated: `kubeObject(DstK8S_Type,DstK8S_Namespace,DstK8S_Name,0)`,
174182
default: true,
175183
width: 15
176184
},
@@ -192,6 +200,7 @@ export const ColumnConfigSampleDefs = [
192200
docURL: 'https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/',
193201
field: 'DstK8S_OwnerName',
194202
filter: 'dst_owner_name',
203+
calculated: `kubeObject(DstK8S_OwnerType,DstK8S_Namespace,DstK8S_OwnerName,0)`,
195204
default: false,
196205
width: 15
197206
},
@@ -214,6 +223,7 @@ export const ColumnConfigSampleDefs = [
214223
docURL: 'http://kubernetes.io/docs/user-guide/identifiers#namespaces',
215224
field: 'DstK8S_Namespace',
216225
filter: 'dst_namespace',
226+
calculated: `kubeObject('Namespace','',DstK8S_Namespace,0)`,
217227
default: true,
218228
width: 15
219229
},
@@ -265,105 +275,122 @@ export const ColumnConfigSampleDefs = [
265275
docURL: 'https://kubernetes.io/docs/concepts/architecture/nodes/',
266276
field: 'DstK8S_HostName',
267277
filter: 'dst_host_name',
278+
calculated: `kubeObject('Node','',DstK8S_HostName,0)`,
268279
default: false,
269280
width: 15
270281
},
271282
{
272283
id: 'DstK8S_Object',
273284
group: 'Destination',
274285
name: 'Kubernetes Object',
286+
calculated: `kubeObject(DstK8S_Type,DstK8S_Namespace,DstK8S_Name,1) or concat(DstAddr,':',DstPort)`,
275287
default: false,
276288
width: 15
277289
},
278290
{
279291
id: 'DstK8S_OwnerObject',
280292
group: 'Destination',
281293
name: 'Owner Kubernetes Object',
294+
calculated: `kubeObject(DstK8S_OwnerType,DstK8S_Namespace,DstK8S_OwnerName,1)`,
282295
default: false,
283296
width: 15
284297
},
285298
{
286299
id: 'DstAddrPort',
287300
group: 'Destination',
288301
name: 'IP & Port',
302+
calculated: `concat(DstAddr,':',DstPort)`,
289303
default: false,
290304
width: 15
291305
},
292306
{
293307
id: 'K8S_Name',
294308
name: 'Names',
309+
calculated: '[SrcK8S_Name,DstK8S_Name]',
295310
default: false,
296311
width: 15
297312
},
298313
{
299314
id: 'K8S_Type',
300315
name: 'Kinds',
316+
calculated: '[SrcK8S_Type,DstK8S_Type]',
301317
default: false,
302318
width: 10
303319
},
304320
{
305321
id: 'K8S_OwnerName',
306322
name: 'Owners',
323+
calculated: '[SrcK8S_OwnerName,DstK8S_OwnerName]',
307324
default: false,
308325
width: 15
309326
},
310327
{
311328
id: 'K8S_OwnerType',
312329
name: 'Owner Kinds',
330+
calculated: '[SrcK8S_OwnerType,DstK8S_OwnerType]',
313331
default: false,
314332
width: 10
315333
},
316334
{
317335
id: 'K8S_Namespace',
318336
name: 'Namespaces',
337+
calculated: '[SrcK8S_Namespace,DstK8S_Namespace]',
319338
default: false,
320339
width: 15
321340
},
322341
{
323342
id: 'Addr',
324343
name: 'IP',
344+
calculated: '[SrcAddr,DstAddr]',
325345
default: false,
326346
width: 10
327347
},
328348
{
329349
id: 'Port',
330350
name: 'Ports',
351+
calculated: '[SrcPort,DstPort]',
331352
default: false,
332353
width: 10
333354
},
334355
{
335356
id: 'Mac',
336357
name: 'MAC',
358+
calculated: '[SrcMac,DstMac]',
337359
default: false,
338360
width: 10
339361
},
340362
{
341363
id: 'K8S_HostIP',
342364
name: 'Node IP',
365+
calculated: '[SrcK8S_HostIP,DstK8S_HostIP]',
343366
default: false,
344367
width: 10
345368
},
346369
{
347370
id: 'K8S_HostName',
348371
name: 'Node Name',
372+
calculated: '[SrcK8S_HostName,DstK8S_HostName]',
349373
default: false,
350374
width: 15
351375
},
352376
{
353377
id: 'K8S_Object',
354378
name: 'Kubernetes Objects',
379+
calculated: '[column.SrcK8S_Object,column.DstK8S_Object]',
355380
default: false,
356381
width: 15
357382
},
358383
{
359384
id: 'K8S_OwnerObject',
360385
name: 'Owner Kubernetes Objects',
386+
calculated: '[column.SrcK8S_OwnerObject,column.DstK8S_OwnerObject]',
361387
default: false,
362388
width: 15
363389
},
364390
{
365391
id: 'AddrPort',
366392
name: 'IPs & Ports',
393+
calculated: '[column.SrcAddrPort,column.DstAddrPort]',
367394
default: false,
368395
width: 15
369396
},

web/src/components/drawer/record/__tests__/record-field.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('<RecordField />', () => {
4747
name: 'DNS Latency',
4848
isSelected: true,
4949
value: f => (f.fields.DnsLatencyMs === undefined ? Number.NaN : f.fields.DnsLatencyMs),
50-
sort: (a, b, col) => compareNumbers(col.value(a) as number, col.value(b) as number),
50+
sort: (a, b, col) => compareNumbers(col.value!(a) as number, col.value!(b) as number),
5151
width: 5
5252
}}
5353
{...mocks}

web/src/components/drawer/record/record-field.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export const RecordField: React.FC<RecordFieldProps> = ({
129129
<TextContent className={`co-resource-item ${size} netobserv-no-child-margin`}>
130130
<ResourceIcon kind={kind} />
131131
<Text component={TextVariants.p} className="co-resource-item__resource-name" data-test-id={value}>
132-
&nbsp;{value}
132+
{value}
133133
</Text>
134134
</TextContent>
135135
)
@@ -150,23 +150,28 @@ export const RecordField: React.FC<RecordFieldProps> = ({
150150
return (
151151
<div data-test={`field-resource-${kind}.${ns}.${value}`} className="force-truncate">
152152
{resourceIconText(value, kind, ns)}
153-
<TextContent className="record-field-tooltip netobserv-no-child-margin">
154-
{/* Note: THIS IS THE TOOLTIP */}
155-
{ns && (
156-
<>
157-
<Text component={TextVariants.h4}>{t('Namespace')}</Text>
158-
<Text component={TextVariants.p}>{ns}</Text>
159-
</>
160-
)}
161-
<Text component={TextVariants.h4}>{kind}</Text>
162-
<Text component={TextVariants.p}>{value}</Text>
163-
</TextContent>
153+
{kubeTooltip(value, kind, ns)}
164154
</div>
165155
);
166156
}
167157
return undefined;
168158
};
169159

160+
const kubeTooltip = (value: string, kind: string, ns: string | undefined) => {
161+
return (
162+
<TextContent className="record-field-tooltip netobserv-no-child-margin">
163+
{ns && (
164+
<>
165+
<Text component={TextVariants.h4}>{t('Namespace')}</Text>
166+
<Text component={TextVariants.p}>{ns}</Text>
167+
</>
168+
)}
169+
<Text component={TextVariants.h4}>{kind}</Text>
170+
<Text component={TextVariants.p}>{value}</Text>
171+
</TextContent>
172+
);
173+
};
174+
170175
const kindContent = (kind: 'Namespace' | 'Node', value?: string) => {
171176
if (value) {
172177
return (
@@ -280,6 +285,10 @@ export const RecordField: React.FC<RecordFieldProps> = ({
280285
};
281286

282287
const content = (c: Column) => {
288+
if (!c.value) {
289+
// Value function not configured
290+
return emptyText();
291+
}
283292
const value = c.value(flow);
284293
switch (c.id) {
285294
case ColumnsId.collectiontime:

web/src/components/drawer/record/record-panel.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,11 @@ export const RecordPanel: React.FC<RecordDrawerProps> = ({
8181
const getVisibleColumns = React.useCallback(() => {
8282
const forbiddenColumns = [ColumnsId.ifdirs, ColumnsId.interfaces];
8383
return columns.filter((c: Column) => {
84+
if (!c.value) {
85+
return false;
86+
}
8487
const value = c.value(record);
85-
return (
86-
!forbiddenColumns.includes(c.id) &&
87-
value !== undefined &&
88-
value !== null &&
89-
value !== '' &&
90-
!Number.isNaN(value)
91-
);
88+
return !forbiddenColumns.includes(c.id) && value !== '' && !Number.isNaN(value);
9289
});
9390
}, [columns, record]);
9491

@@ -103,7 +100,7 @@ export const RecordPanel: React.FC<RecordDrawerProps> = ({
103100
);
104101

105102
const getFilter = (col: Column) => {
106-
if (record) {
103+
if (record && col.value) {
107104
const value = col.value(record);
108105
switch (col.id) {
109106
case ColumnsId.endtime:

web/src/components/tabs/netflow-table/netflow-table-row.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const NetflowTableRow: React.FC<NetflowTableRowProps> = ({
5555
<Td
5656
data-test={`td-${flow.key}`}
5757
data-test-td-column-id={c.id}
58-
data-test-td-value={c.value(flow)}
58+
data-test-td-value={c.value && c.value(flow)}
5959
key={c.id}
6060
style={{ height: '100%', width: `${Math.floor((100 * c.width) / tableWidth)}%` }}
6161
>

0 commit comments

Comments
 (0)