fix: add human-readable labels for gadget data table columns - #62
Open
Jeph-150 wants to merge 2 commits into
Open
fix: add human-readable labels for gadget data table columns#62Jeph-150 wants to merge 2 commits into
Jeph-150 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves gadget data table readability by introducing a centralized mapping from raw API field names to human-friendly column labels, and applying it where table columns are rendered.
Changes:
- Add a
columnLabelsmapping insrc/common/helpers.tsxfor common gadget field names. - Use
columnLabelsas the source of displayed column headers inGadgetWithDataSourceandresourcegadgets(with fallback to the raw column name). - Update
package-lock.jsonmetadata (including version alignment).
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/common/helpers.tsx |
Adds centralized columnLabels mapping for display labels. |
src/common/GadgetWithDataSource/index.tsx |
Applies columnLabels when constructing table column headers. |
src/gadgets/resourcegadgets.tsx |
Applies columnLabels when rendering resource gadget table columns. |
package-lock.json |
Lockfile updates (including version alignment). |
Comments suppressed due to low confidence (1)
src/gadgets/resourcegadgets.tsx:472
GadgetDataViewbuildsheaderfromcolumnLabels[column] || column, but later metric detection usesfield.header === 'isMetric'. Sinceheaderis now a display label (not a stable column identifier), use theIS_METRICconstant and/or detect metrics based on the originalcolumnvalue instead of the rendered header to avoid brittle behavior when labels are added/changed.
header: columnLabels[column] || column, // Use label if available, otherwise fallback to column name
accessorFn: data =>
column === 'timestamp' ? <DateLabel date={data[column]} /> : data[column],
})) || []
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } from '@mui/material'; | ||
| import { useEffect, useMemo, useRef, useState } from 'react'; | ||
| import { HEADLAMP_KEY, HEADLAMP_METRIC_UNIT, HEADLAMP_VALUE, IS_METRIC } from '../common/helpers'; | ||
| import { columnLabels,HEADLAMP_KEY, HEADLAMP_METRIC_UNIT, HEADLAMP_VALUE, IS_METRIC } from '../common/helpers'; |
Comment on lines
82
to
86
| columns?.map(column => ({ | ||
| header: column, | ||
| header: columnLabels[column] || column, // Use label if available, otherwise fallback to column name | ||
| accessorFn: (data: any) => | ||
| column === 'timestamp' ? <DateLabel date={data[column]} /> : data[column], | ||
| })), |
Jeph-150
force-pushed
the
fix/human-readable-column-headers
branch
from
March 21, 2026 17:36
1ab2065 to
8a7400d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added a
columnLabelsmapping insrc/common/helpers.tsxthat translates raw APIfield names to human-friendly labels (e.g.
proc.comm→Process Name,k8s.podName→Pod Name). Applied this mapping in bothGadgetWithDataSourceand
resourcegadgetswhere table columns are rendered, with a fallback to the rawfield name for unmapped columns.
A more scalable long-term solution would read labels directly from the gadget's
field annotations in
gadgetInfo, which would work automatically across all gadgets.This PR is a first step toward improving data readability UX.
Relates to #17
How to use
ghcr.io/inspektor-gadget/gadget/trace_open:latest)Testing done
Ran
trace_opengadget locally against a kind cluster. Confirmed column headersnow display as "Process Name", "Process ID", "File Name", etc. instead of
proc.comm,proc.pid,fname.