1
1
import { Grid , Typography } from '@mui/material' ;
2
2
import React from 'react' ;
3
- import { useForm } from 'react-hook-form' ;
4
3
import { PIPELINE_TYPES } from '../../../../../../../../constants/pipelineTypes' ;
5
- import { PIPELINE_RUN_LABEL_SELECTOR_PIPELINE_TYPE } from '../../../../../../../../k8s/groups/Tekton/PipelineRun/labels' ;
6
- import { PipelineRunKubeObjectInterface } from '../../../../../../../../k8s/groups/Tekton/PipelineRun/types' ;
7
- import { FormSelect } from '../../../../../../../../providers/Form/components/FormSelect' ;
4
+ import { FilterContextProvider } from '../../../../../../../../providers/Filter' ;
8
5
import { ResourceActionListContextProvider } from '../../../../../../../../providers/ResourceActionList' ;
9
- import { capitalizeFirstLetter } from '../../../../../../../../utils/format/capitalizeFirstLetter ' ;
6
+ import { getDefaultNamespace } from '../../../../../../../../utils/getDefaultNamespace ' ;
10
7
import { rem } from '../../../../../../../../utils/styling/rem' ;
11
8
import { PipelineRunList } from '../../../../../../../../widgets/PipelineRunList' ;
9
+ import {
10
+ FILTER_CONTROLS ,
11
+ matchFunctions ,
12
+ } from '../../../../../../../../widgets/PipelineRunList/constants' ;
12
13
import { usePermissionsContext } from '../../../../../../providers/Permissions/hooks' ;
13
14
import { DetailsProps } from './types' ;
14
15
15
- const pipelineRunTypes = Object . entries ( PIPELINE_TYPES ) . filter (
16
- ( [ , value ] ) => value !== PIPELINE_TYPES . DEPLOY && value !== PIPELINE_TYPES . AUTOTEST_RUNNER
17
- ) ;
18
- const pipelineRunTypeSelectOptions = pipelineRunTypes . map ( ( [ , value ] ) => ( {
19
- label : capitalizeFirstLetter ( value ) ,
20
- value : value ,
21
- } ) ) ;
22
-
23
- const filterPipelineRunsByType = (
24
- pipelineRunType : PIPELINE_TYPES ,
25
- pipelineRuns : PipelineRunKubeObjectInterface [ ]
26
- ) =>
27
- pipelineRunType === PIPELINE_TYPES . ALL
28
- ? pipelineRuns
29
- : pipelineRuns . filter (
30
- ( { metadata : { labels } } ) =>
31
- labels [ PIPELINE_RUN_LABEL_SELECTOR_PIPELINE_TYPE ] === pipelineRunType
32
- ) ;
33
-
34
16
export const Details = ( { pipelineRuns } : DetailsProps ) => {
35
- const [ pipelineRunType , setPipelineRunType ] = React . useState < PIPELINE_TYPES > ( PIPELINE_TYPES . ALL ) ;
36
- const filteredPipelineRunsByType = React . useMemo (
37
- ( ) => filterPipelineRunsByType ( pipelineRunType , pipelineRuns . all ) ,
38
- [ pipelineRunType , pipelineRuns . all ]
39
- ) ;
40
-
41
- const {
42
- register,
43
- control,
44
- formState : { errors } ,
45
- } = useForm ( ) ;
46
-
47
17
const { pipelineRun : pipelineRunPermissions } = usePermissionsContext ( ) ;
48
18
49
19
return (
@@ -53,29 +23,25 @@ export const Details = ({ pipelineRuns }: DetailsProps) => {
53
23
< Grid item >
54
24
< Typography variant = { 'h6' } > Pipeline Runs</ Typography >
55
25
</ Grid >
56
- { ! ! pipelineRuns ?. all ?. length ? (
57
- < Grid item style = { { minWidth : rem ( 300 ) , marginLeft : 'auto' } } >
58
- < FormSelect
59
- { ...register ( 'type' , {
60
- onChange : ( { target : { value } } ) => setPipelineRunType ( value ) ,
61
- } ) }
62
- control = { control }
63
- errors = { errors }
64
- name = { 'type' }
65
- label = { 'Type' }
66
- options = { pipelineRunTypeSelectOptions }
67
- defaultValue = { PIPELINE_TYPES . ALL }
68
- />
69
- </ Grid >
70
- ) : null }
71
26
< Grid item xs = { 12 } >
72
27
< ResourceActionListContextProvider >
73
- < PipelineRunList
74
- pipelineRuns = { filteredPipelineRunsByType }
75
- isLoading = { pipelineRuns . all === null }
76
- filterFunction = { null }
77
- permissions = { pipelineRunPermissions }
78
- />
28
+ < FilterContextProvider
29
+ entityID = { `PIPELINE_RUN_LIST_BRANCH_DETAILS::${ getDefaultNamespace ( ) } ` }
30
+ matchFunctions = { matchFunctions }
31
+ saveToLocalStorage
32
+ >
33
+ < PipelineRunList
34
+ pipelineRuns = { pipelineRuns . all }
35
+ isLoading = { pipelineRuns . all === null }
36
+ permissions = { pipelineRunPermissions }
37
+ pipelineRunTypes = { [
38
+ PIPELINE_TYPES . ALL ,
39
+ PIPELINE_TYPES . REVIEW ,
40
+ PIPELINE_TYPES . BUILD ,
41
+ ] }
42
+ filterControls = { [ FILTER_CONTROLS . PIPELINE_TYPE , FILTER_CONTROLS . STATUS ] }
43
+ />
44
+ </ FilterContextProvider >
79
45
</ ResourceActionListContextProvider >
80
46
</ Grid >
81
47
</ Grid >
0 commit comments