Skip to content

Commit 90d821c

Browse files
Zylphrexharshithadurai
authored andcommitted
feat(explore): Ensure id column is present in samples mode (#81195)
It's possible for users to remove the id column in the column editor. But if they do so, the result isn't very useful since it won't link to a trace. So we ensure the id column is always present no matter what columns are selected.
1 parent 51b7326 commit 90d821c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

static/app/views/explore/tables/spansTable.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ export function SpansTable({setError}: SpansTableProps) {
103103
userQuery: query,
104104
});
105105

106+
const visibleFields = useMemo(
107+
() => (fields.includes('id') ? fields : ['id', ...fields]),
108+
[fields]
109+
);
110+
106111
const {tableStyles} = useTableStyles({
107-
items: fields.map(field => {
112+
items: visibleFields.map(field => {
108113
return {
109114
label: field,
110115
value: field,
@@ -122,7 +127,7 @@ export function SpansTable({setError}: SpansTableProps) {
122127
<Table style={tableStyles}>
123128
<TableHead>
124129
<TableRow>
125-
{fields.map((field, i) => {
130+
{visibleFields.map((field, i) => {
126131
// Hide column names before alignment is determined
127132
if (result.isPending) {
128133
return <TableHeadCell key={i} isFirst={i === 0} />;
@@ -176,7 +181,7 @@ export function SpansTable({setError}: SpansTableProps) {
176181
) : result.isFetched && result.data?.length ? (
177182
result.data?.slice(0, 50)?.map((row, i) => (
178183
<TableRow key={i}>
179-
{fields.map((field, j) => {
184+
{visibleFields.map((field, j) => {
180185
return (
181186
<TableBodyCell key={j}>
182187
<FieldRenderer

0 commit comments

Comments
 (0)