@@ -10,6 +10,8 @@ import SearchField from "components/forms/fields/SearchField";
10
10
import Pagination from "components/Pagination" ;
11
11
import Button from "components/buttons/Button" ;
12
12
import Icon from "components/Icon/Icon" ;
13
+ import GitOpsModeTooltipWrapper from "components/GitOpsModeTooltipWrapper" ;
14
+
13
15
import { COLORS } from "styles/var/colors" ;
14
16
15
17
import DataTable from "./DataTable/DataTable" ;
@@ -30,6 +32,10 @@ interface IRowProps extends Row {
30
32
} ;
31
33
}
32
34
35
+ interface ITableContainerActionButtonProps extends IActionButtonProps {
36
+ gitOpsModeCompatible ?: boolean ;
37
+ }
38
+
33
39
interface ITableContainerProps < T = any > {
34
40
columnConfigs : any ; // TODO: Figure out type
35
41
data : any ; // TODO: Figure out type
@@ -41,7 +47,7 @@ interface ITableContainerProps<T = any> {
41
47
defaultPageIndex ?: number ;
42
48
defaultSelectedRows ?: Record < string , boolean > ;
43
49
/** Button visible above the table container next to search bar */
44
- actionButton ?: IActionButtonProps ;
50
+ actionButton ?: ITableContainerActionButtonProps ;
45
51
inputPlaceHolder ?: string ;
46
52
disableActionButton ?: boolean ;
47
53
disableMultiRowSelect ?: boolean ;
@@ -284,6 +290,47 @@ const TableContainer = <T,>({
284
290
onPaginationChange ,
285
291
] ) ;
286
292
293
+ const renderFilterActionButton = ( ) => {
294
+ // always !!actionButton here, this is for type checker
295
+ if ( actionButton ) {
296
+ if ( actionButton . gitOpsModeCompatible ) {
297
+ return (
298
+ < GitOpsModeTooltipWrapper
299
+ tipOffset = { 8 }
300
+ renderChildren = { ( disableChildren ) => (
301
+ < Button
302
+ disabled = { disableActionButton || disableChildren }
303
+ onClick = { actionButton . onActionButtonClick }
304
+ variant = { actionButton . variant || "brand" }
305
+ className = { `${ baseClass } __table-action-button` }
306
+ >
307
+ < >
308
+ { actionButton . buttonText }
309
+ { actionButton . iconSvg && < Icon name = { actionButton . iconSvg } /> }
310
+ </ >
311
+ </ Button >
312
+ ) }
313
+ />
314
+ ) ;
315
+ }
316
+ return (
317
+ < Button
318
+ disabled = { disableActionButton }
319
+ onClick = { actionButton . onActionButtonClick }
320
+ variant = { actionButton . variant || "brand" }
321
+ className = { `${ baseClass } __table-action-button` }
322
+ >
323
+ < >
324
+ { actionButton . buttonText }
325
+ { actionButton . iconSvg && < Icon name = { actionButton . iconSvg } /> }
326
+ </ >
327
+ </ Button >
328
+ ) ;
329
+ }
330
+ // should never reach here
331
+ return null ;
332
+ } ;
333
+
287
334
const renderFilters = useCallback ( ( ) => {
288
335
const opacity = isLoading ? { opacity : 0.4 } : { opacity : 1 } ;
289
336
@@ -306,19 +353,7 @@ const TableContainer = <T,>({
306
353
</ div >
307
354
308
355
{ actionButton && ! actionButton . hideButton && (
309
- < div className = "stackable-header" >
310
- < Button
311
- disabled = { disableActionButton }
312
- onClick = { actionButton . onActionButtonClick }
313
- variant = { actionButton . variant || "brand" }
314
- className = { `${ baseClass } __table-action-button` }
315
- >
316
- < >
317
- { actionButton . buttonText }
318
- { actionButton . iconSvg && < Icon name = { actionButton . iconSvg } /> }
319
- </ >
320
- </ Button >
321
- </ div >
356
+ < div className = "stackable-header" > { renderFilterActionButton ( ) } </ div >
322
357
) }
323
358
< div className = "stackable-header top-shift-header" >
324
359
{ customControl && customControl ( ) }
@@ -386,21 +421,9 @@ const TableContainer = <T,>({
386
421
</ div >
387
422
) }
388
423
< span className = "controls" >
389
- { actionButton && ! actionButton . hideButton && (
390
- < Button
391
- disabled = { disableActionButton }
392
- onClick = { actionButton . onActionButtonClick }
393
- variant = { actionButton . variant || "brand" }
394
- className = { `${ baseClass } __table-action-button` }
395
- >
396
- < >
397
- { actionButton . buttonText }
398
- { actionButton . iconSvg && (
399
- < Icon name = { actionButton . iconSvg } />
400
- ) }
401
- </ >
402
- </ Button >
403
- ) }
424
+ { actionButton &&
425
+ ! actionButton . hideButton &&
426
+ renderFilterActionButton ( ) }
404
427
{ customControl && customControl ( ) }
405
428
</ span >
406
429
</ div >
0 commit comments