Skip to content

Commit

Permalink
[#noissue] Display jvm info only when it exists in inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
binDongKim committed Jul 8, 2024
1 parent fedcd6d commit 0e9fae9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { useGetInspectorAgentInfoData } from '@pinpoint-fe/hooks';
import { InspectorAgentInfoServiceType } from './InspectorAgentInfoServiceType';
import { LuChevronsUpDown } from 'react-icons/lu';
import { insertIf } from '@pinpoint-fe/utils';

export type InfoDefinition = {
key: string;
Expand Down Expand Up @@ -48,11 +49,15 @@ export const InspectorAgentInfoFetcher = () => {
label: 'Hostname',
value: data.hostName,
},
{
key: 'jvmInfo',
label: 'JVM (GC Type)',
value: `${data.jvmInfo.jvmVersion} (${data.jvmInfo.gcTypeName})`,
},
...insertIf(!!data.jvmInfo, () => {
return [
{
key: 'jvmInfo',
label: 'JVM (GC Type)',
value: `${data.jvmInfo.jvmVersion} (${data.jvmInfo.gcTypeName})`,
},
];
}),
{
key: 'ip',
label: 'IP',
Expand Down
3 changes: 3 additions & 0 deletions web-frontend/src/main/v3/packages/utils/src/array.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function insertIf<T>(condition: boolean | (() => boolean), element: () => T[]): T[] {
return (typeof condition === 'function' ? condition() : condition) ? element() : [];
}
1 change: 1 addition & 0 deletions web-frontend/src/main/v3/packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './array';
export * from './date';
export * from './dom';
export * from './format';
Expand Down

0 comments on commit 0e9fae9

Please sign in to comment.