File tree 3 files changed +26
-9
lines changed
static/app/views/explore/contexts/logs
3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -12,5 +12,9 @@ export function defaultLogFields(): OurLogKnownFieldKey[] {
12
12
}
13
13
14
14
export function getLogFieldsFromLocation ( location : Location ) : OurLogFieldKey [ ] {
15
- return decodeList ( location . query [ LOGS_FIELDS_KEY ] ) ;
15
+ const fields = decodeList ( location . query [ LOGS_FIELDS_KEY ] ) ;
16
+ if ( fields . length ) {
17
+ return fields ;
18
+ }
19
+ return defaultLogFields ( ) ;
16
20
}
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ export function LogsPageParamsProvider({
89
89
: getLogFieldsFromLocation ( location ) ;
90
90
const sortBys = isTableEditingFrozen
91
91
? [ logsTimestampDescendingSortBy ]
92
- : getLogSortBysFromLocation ( location ) ;
92
+ : getLogSortBysFromLocation ( location , fields ) ;
93
93
const projectIds = isOnEmbeddedView
94
94
? ( limitToProjectIds ?? [ - 1 ] )
95
95
: decodeProjects ( location ) ;
Original file line number Diff line number Diff line change @@ -12,18 +12,31 @@ export const logsTimestampDescendingSortBy: Sort = {
12
12
kind : 'desc' as const ,
13
13
} ;
14
14
15
- function defaultLogSortBys ( ) : Sort [ ] {
16
- return [ logsTimestampDescendingSortBy ] ;
17
- }
18
-
19
- export function getLogSortBysFromLocation ( location : Location ) : Sort [ ] {
15
+ export function getLogSortBysFromLocation ( location : Location , fields : string [ ] ) : Sort [ ] {
20
16
const sortBys = decodeSorts ( location . query [ LOGS_SORT_BYS_KEY ] ) ;
21
17
22
18
if ( sortBys . length > 0 ) {
23
- return sortBys ;
19
+ if ( sortBys . every ( sortBy => fields . includes ( sortBy . field ) ) ) {
20
+ return sortBys ;
21
+ }
22
+ }
23
+
24
+ if ( fields . includes ( OurLogKnownFieldKey . TIMESTAMP ) ) {
25
+ return [ logsTimestampDescendingSortBy ] ;
26
+ }
27
+
28
+ if ( ! fields [ 0 ] ) {
29
+ throw new Error (
30
+ 'fields should not be empty - did you somehow delete all of the fields?'
31
+ ) ;
24
32
}
25
33
26
- return defaultLogSortBys ( ) ;
34
+ return [
35
+ {
36
+ field : fields [ 0 ] ,
37
+ kind : 'desc' as const ,
38
+ } ,
39
+ ] ;
27
40
}
28
41
29
42
export function updateLocationWithLogSortBys (
You can’t perform that action at this time.
0 commit comments