Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,9 @@ function useWidgetBuilderState(): {
* Returns the default display type if the value is not a valid display type
*/
function deserializeDisplayType(value: string): DisplayType {
if (value === DisplayType.TOP_N) {
return DisplayType.AREA;
}
if (Object.values(DisplayType).includes(value as DisplayType)) {
return value as DisplayType;
}
Expand Down
3 changes: 2 additions & 1 deletion static/app/views/dashboards/widgetCard/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,10 @@ describe('Dashboards > WidgetCard', () => {
);

await userEvent.click(await screen.findByLabelText('Widget actions'));
// TOP_N is converted to AREA, so the discover URL no longer has display=top5
expect(screen.getByRole('menuitemradio', {name: 'Open in Discover'})).toHaveAttribute(
'href',
'/organizations/org-slug/explore/discover/results/?display=top5&environment=prod&field=transaction&field=count%28%29&name=Errors&project=1&query=event.type%3Aerror&queryDataset=error-events&statsPeriod=14d&yAxis=count%28%29'
'/organizations/org-slug/explore/discover/results/?environment=prod&field=transaction&field=count%28%29&name=Errors&project=1&query=event.type%3Aerror&queryDataset=error-events&statsPeriod=14d&yAxis=count%28%29'
);
});

Expand Down
11 changes: 1 addition & 10 deletions static/app/views/dashboards/widgetCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import {
WidgetType,
} from 'sentry/views/dashboards/types';
import {widgetCanUseTimeSeriesVisualization} from 'sentry/views/dashboards/utils/widgetCanUseTimeSeriesVisualization';
import {DEFAULT_RESULTS_LIMIT} from 'sentry/views/dashboards/widgetBuilder/utils';
import {WidgetCardChartContainer} from 'sentry/views/dashboards/widgetCard/widgetCardChartContainer';
import type WidgetLegendSelectionState from 'sentry/views/dashboards/widgetLegendSelectionState';
import type {TabularColumn} from 'sentry/views/dashboards/widgets/common/types';
Expand Down Expand Up @@ -191,15 +190,7 @@ function WidgetCard(props: Props) {
} = props;

if (widget.displayType === DisplayType.TOP_N) {
const queries = widget.queries.map(query => ({
...query,
// Use the last aggregate because that's where the y-axis is stored
aggregates: query.aggregates.length
? [query.aggregates[query.aggregates.length - 1]!]
: [],
}));
widget.queries = queries;
widget.limit = DEFAULT_RESULTS_LIMIT;
widget.displayType = DisplayType.AREA;
}

const hasSessionDuration = widget.queries.some(query =>
Expand Down
Loading