Skip to content

fix(explore): Always render column for incomplete equations #94918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions static/app/views/explore/tables/aggregatesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,14 @@ export function AggregatesTable({aggregatesTableResult}: AggregatesTableProps) {
);

const columns = useMemo(() => {
const cols = eventView.getColumns().reduce(
return eventView.getColumns().reduce(
(acc, col) => {
acc[col.key] = col;
return acc;
},
{} as Record<string, TableColumn<string>>
);

return visibleAggregateFields
.map(aggregateField => {
const key = isGroupBy(aggregateField)
? aggregateField.groupBy
: aggregateField.yAxis;
return cols[key];
})
.filter(defined);
}, [visibleAggregateFields, eventView]);
}, [eventView]);

return (
<Fragment>
Expand All @@ -129,21 +120,25 @@ export function AggregatesTable({aggregatesTableResult}: AggregatesTableProps) {
<TableHeadCell isFirst={false}>
<TableHeadCellContent />
</TableHeadCell>
{columns.map((column, i) => {
{visibleAggregateFields.map((aggregateField, i) => {
// Hide column names before alignment is determined
if (result.isPending) {
return <TableHeadCell key={i} isFirst={i === 0} />;
}

const fieldType = meta.fields?.[column.key];
const align = fieldAlignment(column.key, fieldType);
const label = prettifyField(column.key, stringTags, numberTags);
const field = isGroupBy(aggregateField)
? aggregateField.groupBy
: aggregateField.yAxis;

const fieldType = meta.fields?.[field];
const align = fieldAlignment(field, fieldType);
const label = prettifyField(field, stringTags, numberTags);

const direction = sorts.find(s => s.field === column.key)?.kind;
const direction = sorts.find(s => s.field === field)?.kind;

function updateSort() {
const kind = direction === 'desc' ? 'asc' : 'desc';
setSorts([{field: column.key, kind}]);
setSorts([{field, kind}]);
}

return (
Expand All @@ -165,7 +160,7 @@ export function AggregatesTable({aggregatesTableResult}: AggregatesTableProps) {
/>
)}
</TableHeadCellContent>
{i !== columns.length - 1 && (
{i !== visibleAggregateFields.length - 1 && (
<GridResizer
dataRows={
!result.isError && !result.isPending && result.data
Expand Down Expand Up @@ -213,13 +208,17 @@ export function AggregatesTable({aggregatesTableResult}: AggregatesTableProps) {
</StyledLink>
</Tooltip>
</TableBodyCell>
{columns.map((column, j) => {
{visibleAggregateFields.map((aggregateField, j) => {
const field = isGroupBy(aggregateField)
? aggregateField.groupBy
: aggregateField.yAxis;

return (
<TableBodyCell key={j}>
<FieldRenderer
column={column}
column={columns[field]}
data={row}
unit={meta?.units?.[column.key]}
unit={meta?.units?.[field]}
meta={meta}
/>
</TableBodyCell>
Expand Down
10 changes: 8 additions & 2 deletions static/app/views/explore/tables/fieldRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ExternalLink from 'sentry/components/links/externalLink';
import TimeSince from 'sentry/components/timeSince';
import {space} from 'sentry/styles/space';
import type {Project} from 'sentry/types/project';
import {defined} from 'sentry/utils';
import type {TableDataRow} from 'sentry/utils/discover/discoverQuery';
import type {EventData, MetaType} from 'sentry/utils/discover/eventView';
import EventView from 'sentry/utils/discover/eventView';
Expand Down Expand Up @@ -37,9 +38,9 @@ import {TraceViewSources} from 'sentry/views/performance/newTraceDetails/traceHe
import {getTraceDetailsUrl} from 'sentry/views/performance/traceDetails/utils';

interface FieldProps {
column: TableColumn<keyof TableDataRow>;
data: EventData;
meta: MetaType;
column?: TableColumn<keyof TableDataRow>;
unit?: string;
}

Expand Down Expand Up @@ -104,7 +105,6 @@ function BaseExploreFieldRenderer({
const theme = useTheme();
const dateSelection = EventView.fromLocation(location).normalizeDateSelection(location);
const query = new MutableSearch(userQuery);
const field = String(column.key);
const {projects} = useProjects();
const projectsMap = useMemo(() => {
return projects.reduce(
Expand All @@ -116,6 +116,12 @@ function BaseExploreFieldRenderer({
);
}, [projects]);

if (!defined(column)) {
return nullableValue(null);
}

const field = String(column.key);

const renderer = getExploreFieldRenderer(field, meta, projectsMap);

let rendered = renderer(data, {
Expand Down
Loading