Skip to content

Commit 0e9fae9

Browse files
committed
[#noissue] Display jvm info only when it exists in inspector
1 parent fedcd6d commit 0e9fae9

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

web-frontend/src/main/v3/packages/ui/src/components/Inspector/agent-info/InspectorAgentInfoFetcher.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { useGetInspectorAgentInfoData } from '@pinpoint-fe/hooks';
1313
import { InspectorAgentInfoServiceType } from './InspectorAgentInfoServiceType';
1414
import { LuChevronsUpDown } from 'react-icons/lu';
15+
import { insertIf } from '@pinpoint-fe/utils';
1516

1617
export type InfoDefinition = {
1718
key: string;
@@ -48,11 +49,15 @@ export const InspectorAgentInfoFetcher = () => {
4849
label: 'Hostname',
4950
value: data.hostName,
5051
},
51-
{
52-
key: 'jvmInfo',
53-
label: 'JVM (GC Type)',
54-
value: `${data.jvmInfo.jvmVersion} (${data.jvmInfo.gcTypeName})`,
55-
},
52+
...insertIf(!!data.jvmInfo, () => {
53+
return [
54+
{
55+
key: 'jvmInfo',
56+
label: 'JVM (GC Type)',
57+
value: `${data.jvmInfo.jvmVersion} (${data.jvmInfo.gcTypeName})`,
58+
},
59+
];
60+
}),
5661
{
5762
key: 'ip',
5863
label: 'IP',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function insertIf<T>(condition: boolean | (() => boolean), element: () => T[]): T[] {
2+
return (typeof condition === 'function' ? condition() : condition) ? element() : [];
3+
}

web-frontend/src/main/v3/packages/utils/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './array';
12
export * from './date';
23
export * from './dom';
34
export * from './format';

0 commit comments

Comments
 (0)