Skip to content

Commit 63e2dbb

Browse files
committed
refine type of special fields
1 parent 83f9719 commit 63e2dbb

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/sentry/static/sentry/app/views/organizationEventsV2/data.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ type RenderFunctionBaggage = {
100100
location: ReactRouterLocation;
101101
};
102102

103-
type RenderFunction = (
103+
type FieldFormatterRenderFunction = (
104104
field: string,
105105
data: EventData,
106106
baggage: RenderFunctionBaggage
107107
) => React.ReactNode;
108108

109109
type FieldFormatter = {
110110
sortField: boolean;
111-
renderFunc: RenderFunction;
111+
renderFunc: FieldFormatterRenderFunction;
112112
};
113113

114114
type FieldFormatters = {
@@ -185,12 +185,32 @@ export const FIELD_FORMATTERS: FieldFormatters = {
185185
},
186186
};
187187

188+
type SpecialFieldRenderFunc = (
189+
data: EventData,
190+
baggage: RenderFunctionBaggage
191+
) => React.ReactNode;
192+
193+
type SpecialField = {
194+
sortField: boolean;
195+
renderFunc: SpecialFieldRenderFunc;
196+
};
197+
198+
type SpecialFields = {
199+
transaction: SpecialField;
200+
title: SpecialField;
201+
type: SpecialField;
202+
project: SpecialField;
203+
user: SpecialField;
204+
issue_title: SpecialField;
205+
last_seen: SpecialField;
206+
};
207+
188208
/**
189209
* "Special fields" do not map 1:1 to an single column in the event database,
190210
* they are a UI concept that combines the results of multiple fields and
191211
* displays with a custom render function.
192212
*/
193-
export const SPECIAL_FIELDS = {
213+
export const SPECIAL_FIELDS: SpecialFields = {
194214
transaction: {
195215
sortField: 'transaction',
196216
renderFunc: (data, {location}) => {

src/sentry/static/sentry/app/views/organizationEventsV2/table.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ export default class Table extends React.Component<Props> {
7474

7575
let sortKey: string | null = field;
7676
if (SPECIAL_FIELDS.hasOwnProperty(field)) {
77-
sortKey = SPECIAL_FIELDS[field].sortField || null;
77+
sortKey =
78+
SPECIAL_FIELDS[field as keyof typeof SPECIAL_FIELDS].sortField || null;
7879
} else if (FIELD_FORMATTERS.hasOwnProperty(field)) {
7980
sortKey = FIELD_FORMATTERS[field as keyof typeof FIELD_FORMATTERS].sortField
8081
? field

0 commit comments

Comments
 (0)