@@ -4,7 +4,7 @@ import ReactTable, {
4
4
ComponentPropsGetter0 ,
5
5
} from 'react-table' ;
6
6
import 'react-table/react-table.css' ;
7
- import { FaTimes } from 'react-icons/fa' ;
7
+ import { FaTimes , FaSort , FaSortUp , FaSortDown } from 'react-icons/fa' ;
8
8
import { Button } from '../../../../../new-components/Button' ;
9
9
import { FilterTableProps , GridHeadingProps } from './types' ;
10
10
import { ordinalColSort } from '../../../Data/utils' ;
@@ -42,6 +42,7 @@ interface Props extends FilterTableProps {
42
42
onSuccess : ( ) => void
43
43
) => void ;
44
44
triggerType ?: SupportedEvents ;
45
+ triggerOp ?: 'pending' | 'processed' | 'invocation' ;
45
46
}
46
47
const EventsTable : React . FC < Props > = props => {
47
48
const {
@@ -52,23 +53,27 @@ const EventsTable: React.FC<Props> = props => {
52
53
identifier,
53
54
onCancelEvent,
54
55
triggerType,
56
+ triggerOp,
55
57
} = props ;
56
58
const [ , setCurrentPage ] = React . useState ( 0 ) ;
57
59
const [ , setPageSize ] = React . useState ( filterState . limit ?? 10 ) ;
58
60
const sortedColumns = columns . sort ( ordinalColSort ) ;
59
61
let shouldSortColumn = true ;
62
+
63
+ // For debugging - log the props to see what's being passed
64
+ React . useEffect ( ( ) => {
65
+ console . log ( 'EventsTable props:' , { triggerType, triggerOp } ) ;
66
+ } , [ triggerType , triggerOp ] ) ;
60
67
const sortByColumn = ( col : string ) => {
61
- // Remove all the existing order_bys
62
68
const existingColSort = filterState . sorts . find ( s => s . column === col ) ;
63
- if ( existingColSort && existingColSort . type === 'asc' ) {
64
- runQuery ( {
65
- sorts : [ makeOrderBy ( col , 'desc' ) ] ,
66
- } ) ;
67
- } else {
68
- runQuery ( {
69
- sorts : [ makeOrderBy ( col , 'asc' ) ] ,
70
- } ) ;
71
- }
69
+ const newSort =
70
+ existingColSort && existingColSort . type === 'asc'
71
+ ? makeOrderBy ( col , 'desc' )
72
+ : makeOrderBy ( col , 'asc' ) ;
73
+
74
+ runQuery ( {
75
+ sorts : [ newSort ] ,
76
+ } ) ;
72
77
} ;
73
78
const changePage = ( page : number ) => {
74
79
if ( filterState . offset !== page * filterState . limit ) {
@@ -119,20 +124,72 @@ const EventsTable: React.FC<Props> = props => {
119
124
const gridHeadings = [ expanderActions ] ;
120
125
sortedColumns . forEach ( column => {
121
126
if ( column !== 'actions' ) {
122
- gridHeadings . push ( {
123
- Header : column ,
124
- accessor : column ,
125
- } ) ;
127
+ // Only add sort icons for one-off and cron triggers
128
+ // and not for event triggers (data)
129
+ if ( triggerType && triggerType !== 'data' ) {
130
+ // For debugging - always show sort icons regardless of triggerOp
131
+ const existingSort = filterState . sorts . find ( s => s . column === column ) ;
132
+
133
+ // Create a header with the column name and sort icon
134
+ const headerContent = (
135
+ < div
136
+ style = { {
137
+ display : 'flex' ,
138
+ alignItems : 'center' ,
139
+ justifyContent : 'space-between' ,
140
+ width : '100%' ,
141
+ } }
142
+ >
143
+ < span > { column } </ span >
144
+ { existingSort ? (
145
+ existingSort . type === 'asc' ? (
146
+ < FaSortUp style = { { marginLeft : '5px' , fontSize : '16px' } } />
147
+ ) : (
148
+ < FaSortDown style = { { marginLeft : '5px' , fontSize : '16px' } } />
149
+ )
150
+ ) : (
151
+ < FaSort
152
+ style = { { marginLeft : '5px' , opacity : 0.5 , fontSize : '16px' } }
153
+ />
154
+ ) }
155
+ </ div >
156
+ ) ;
157
+
158
+ gridHeadings . push ( {
159
+ Header : headerContent ,
160
+ accessor : column ,
161
+ id : column , // Ensure we have an id for the column
162
+ } ) ;
163
+ } else {
164
+ // For event triggers or other cases, just use the column name
165
+ gridHeadings . push ( {
166
+ Header : column ,
167
+ accessor : column ,
168
+ id : column , // Ensure we have an id for the column
169
+ } ) ;
170
+ }
126
171
}
127
172
} ) ;
128
173
const invocationColumns = [ 'http_status' , 'id' , 'created_at' ] ;
129
174
const invocationDataTriggerColumns = [ 'http_status' , 'id' , 'created_at' ] ;
130
- const invocationGridHeadings : GridHeadingProps [ ] = [ expanderActions ] ;
175
+ const invocationGridHeadings : {
176
+ Header : string | React . ReactNode ;
177
+ accessor : string ;
178
+ id ?: string ;
179
+ width ?: number ;
180
+ expander ?: boolean ;
181
+ Expander ?: React . FC < {
182
+ isExpanded : boolean ;
183
+ viewIndex : number ;
184
+ } > ;
185
+ } [ ] = [ expanderActions ] ;
186
+
131
187
const addToGridHeadings = ( headAccArr : string [ ] ) => {
132
188
headAccArr . forEach ( column => {
133
189
invocationGridHeadings . push ( {
134
190
Header : column ,
135
191
accessor : column ,
192
+ id : column ,
136
193
} ) ;
137
194
} ) ;
138
195
} ;
@@ -161,25 +218,41 @@ const EventsTable: React.FC<Props> = props => {
161
218
} ;
162
219
} ) ;
163
220
const getTheadThProps : ComponentPropsGetterC = (
164
- finalState ,
165
- some ,
221
+ _finalState ,
222
+ _some ,
166
223
column
167
- ) => ( {
168
- onClick : ( ) => {
169
- if (
170
- column &&
171
- column . Header &&
172
- shouldSortColumn &&
173
- column . Header !== 'Actions'
174
- ) {
175
- sortByColumn ( column . Header as string ) ;
176
- }
177
- shouldSortColumn = true ;
178
- } ,
179
- } ) ;
224
+ ) => {
225
+ if ( ! column ) {
226
+ return { } ;
227
+ }
228
+
229
+ // Get the column ID or Header text
230
+ const columnId =
231
+ column . id || ( typeof column . Header === 'string' ? column . Header : '' ) ;
232
+
233
+ // Only enable sorting for one-off and cron triggers (not for event triggers)
234
+ if ( triggerType && triggerType !== 'data' ) {
235
+ return {
236
+ onClick : ( ) => {
237
+ if (
238
+ column . Header &&
239
+ shouldSortColumn &&
240
+ column . Header !== 'Actions'
241
+ ) {
242
+ sortByColumn ( columnId ) ;
243
+ }
244
+ shouldSortColumn = true ;
245
+ } ,
246
+ style : { cursor : 'pointer' } ,
247
+ } ;
248
+ }
249
+
250
+ // For event triggers or other cases, don't add click handler
251
+ return { } ;
252
+ } ;
180
253
const getResizerProps : ComponentPropsGetter0 = (
181
- finalState ,
182
- none ,
254
+ _finalState ,
255
+ _none ,
183
256
column ,
184
257
ctx
185
258
) => ( {
0 commit comments