-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(dashboards): sorting for table widget visualization #94570
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
Changes from all commits
3e246c8
2d4d6c1
191d5d9
37c7181
4f48d3e
8fef9d4
cd6f902
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,12 @@ import {space} from 'sentry/styles/space'; | |
import type {PageFilters} from 'sentry/types/core'; | ||
import type {Organization} from 'sentry/types/organization'; | ||
import {defined} from 'sentry/utils'; | ||
import {getSortField} from 'sentry/utils/dashboards/issueFieldRenderers'; | ||
import type {TableData} from 'sentry/utils/discover/discoverQuery'; | ||
import type {MetaType} from 'sentry/utils/discover/eventView'; | ||
import type {RenderFunctionBaggage} from 'sentry/utils/discover/fieldRenderers'; | ||
import {type RenderFunctionBaggage} from 'sentry/utils/discover/fieldRenderers'; | ||
import type {Sort} from 'sentry/utils/discover/fields'; | ||
import {decodeSorts} from 'sentry/utils/queryString'; | ||
import {getDatasetConfig} from 'sentry/views/dashboards/datasetConfig/base'; | ||
import {type Widget, WidgetType} from 'sentry/views/dashboards/types'; | ||
import {eventViewFromWidget} from 'sentry/views/dashboards/utils'; | ||
|
@@ -31,6 +34,7 @@ type Props = { | |
theme: Theme; | ||
widget: Widget; | ||
errorMessage?: string; | ||
onTableColumnSort?: (sort: Sort) => void; | ||
tableResults?: TableData[]; | ||
}; | ||
|
||
|
@@ -43,6 +47,7 @@ export function IssueWidgetCard({ | |
organization, | ||
location, | ||
theme, | ||
onTableColumnSort, | ||
}: Props) { | ||
const datasetConfig = getDatasetConfig(WidgetType.ISSUE); | ||
|
||
|
@@ -70,6 +75,7 @@ export function IssueWidgetCard({ | |
name: column.name, | ||
width: column.width, | ||
type: column.type === 'never' ? null : column.type, | ||
sortable: !!getSortField(column.key), | ||
})); | ||
const aliases = decodeColumnAliases(columns, fieldAliases, fieldHeaderMap); | ||
const tableData = convertTableDataToTabularData(tableResults?.[0]); | ||
|
@@ -78,6 +84,11 @@ export function IssueWidgetCard({ | |
const getCustomFieldRenderer = (field: string, meta: MetaType, org?: Organization) => { | ||
return datasetConfig.getCustomFieldRenderer?.(field, meta, widget, org) || null; | ||
}; | ||
// This is to match the widget viewer modal, which always displays the arrow pointing down | ||
const sort: Sort = { | ||
field: decodeSorts(widget.queries[0]?.orderby)[0]?.field || '', | ||
kind: 'desc', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above about the issues widget default sort stuff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be purely visual since that I'm honestly thinking it might be better to omit sorting for issue widgets for now/make a separate PR to address it. Might want to get design's opinion as well since the arrow direction lowkey makes no sense |
||
}; | ||
|
||
return organization.features.includes('dashboards-use-widget-table-visualization') ? ( | ||
<TableContainer> | ||
|
@@ -88,6 +99,8 @@ export function IssueWidgetCard({ | |
scrollable | ||
fit="max-content" | ||
aliases={aliases} | ||
onSortChange={onTableColumnSort} | ||
sort={sort} | ||
getRenderer={(field, _dataRow, meta) => { | ||
const customRenderer = datasetConfig.getCustomFieldRenderer?.( | ||
field, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this gonna be an issue with some of the issue widget fields? (referencing one of your previous prs) Just curious, not sure if that needs to be taken into account here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fine, issues fields omit the '-' regardless of order that it is sorted by. So when updating the widget query, we want to make sure it's never included