@@ -10,74 +10,131 @@ import { getNavSteps, RunSteps } from '../model/DefaultNavSteps'
1010import { useDispatch , useSelector } from 'react-redux'
1111import { AppState } from '../store/configureStore'
1212import { RuleListPanel } from '../components/RuleListPanel'
13+ import { CapabilitiesTreePanel } from '../components/CapabilitiesTreePanel'
1314import { ConfigurationsDataSrv } from '../services/Configurations'
1415import { FilterTestCaseActions } from '../actions/FilterTestCaseAction'
1516import { TestSuitesDataSrv } from '../services/TestSuites'
1617import { SelectedRuleGroup } from '../model/RuleGroup'
17- import { IStackItemTokens , IStackTokens , PrimaryButton , Stack } from '@fluentui/react'
18+ import { IStackItemTokens , IStackTokens , PrimaryButton , Stack , Dropdown , Label } from '@fluentui/react'
1819import { ConfigurationMethod_AutoDetection } from './ConfigureMethod'
1920import { PropertyGroupsActions } from '../actions/PropertyGroupsAction'
2021import { InvalidAppStateNotification } from '../components/InvalidAppStateNotification'
22+ import { CapabilitiesDataSrv } from '../services/Capabilities'
2123
2224export const FilterTestCase : React . FC < any > = ( props : any ) => {
23- const wizardProps : StepWizardChildProps = props as StepWizardChildProps
25+ const wizardProps : StepWizardChildProps = props as StepWizardChildProps
2426
25- const dispatch = useDispatch ( )
26- const testSuiteInfo = useSelector ( ( state : AppState ) => state . testSuiteInfo )
27- const configuration = useSelector ( ( state : AppState ) => state . configurations )
28- const filterInfo = useSelector ( ( state : AppState ) => state . filterInfo )
29- const configureMethod = useSelector ( ( state : AppState ) => state . configureMethod )
30- const detectionResult = useSelector ( ( state : AppState ) => state . detectResult )
27+ const dispatch = useDispatch ( )
28+ const testSuiteInfo = useSelector ( ( state : AppState ) => state . testSuiteInfo )
29+ const configuration = useSelector ( ( state : AppState ) => state . configurations )
30+ const filterInfo = useSelector ( ( state : AppState ) => state . filterInfo )
31+ const configureMethod = useSelector ( ( state : AppState ) => state . configureMethod )
32+ const detectionResult = useSelector ( ( state : AppState ) => state . detectResult )
33+ const capabilitiesListState = useSelector ( ( state : AppState ) => state . capabilitiesList )
3134
32- const navSteps = getNavSteps ( wizardProps , configureMethod )
33- const wizard = WizardNavBar ( wizardProps , navSteps )
35+ const navSteps = getNavSteps ( wizardProps , configureMethod )
36+ const wizard = WizardNavBar ( wizardProps , navSteps )
3437
35- useEffect ( ( ) => {
36- dispatch ( ConfigurationsDataSrv . getRules ( ) )
37- dispatch ( TestSuitesDataSrv . getTestSuiteTestCases ( ) )
38- } , [ dispatch ] )
38+ useEffect ( ( ) => {
39+ dispatch ( ConfigurationsDataSrv . getRules ( ) )
40+ dispatch ( TestSuitesDataSrv . getTestSuiteTestCases ( ) )
41+ dispatch ( CapabilitiesDataSrv . getCapabilitiesFiles ( ) )
42+ } , [ dispatch ] )
3943
40- if ( testSuiteInfo . selectedTestSuite === undefined || configuration . selectedConfiguration === undefined ) {
41- return < InvalidAppStateNotification
44+ if ( testSuiteInfo . selectedTestSuite === undefined || configuration . selectedConfiguration === undefined ) {
45+ return < InvalidAppStateNotification
4246 testSuite = { testSuiteInfo . selectedTestSuite }
4347 configuration = { configuration . selectedConfiguration }
4448 wizard = { wizard }
4549 wizardProps = { wizardProps } />
50+ }
51+
52+ const onPreviousButtonClick : React . MouseEventHandler < unknown > = ( ) => {
53+ if ( configureMethod ?. selectedMethod === ConfigurationMethod_AutoDetection && detectionResult . detectionResult !== undefined ) {
54+ wizardProps . previousStep ( )
55+ } else {
56+ wizardProps . goToStep ( RunSteps . CONFIGURE_METHOD )
4657 }
58+ }
59+
60+ const onNextButtonClick : React . MouseEventHandler < unknown > = ( ) => {
61+ dispatch ( ConfigurationsDataSrv . setRules ( ( ) => {
62+ wizardProps . nextStep ( )
63+ } ) )
64+ }
65+
66+ const checkedAction = ( data : SelectedRuleGroup ) : void => {
67+ dispatch ( FilterTestCaseActions . setSelectedRuleAction ( data ) )
68+ }
69+
70+ const stackTokens : IStackTokens = {
71+ maxHeight : '100%'
72+ }
4773
48- const onPreviousButtonClick : React . MouseEventHandler < unknown > = ( ) => {
49- if ( configureMethod ?. selectedMethod === ConfigurationMethod_AutoDetection && detectionResult . detectionResult !== undefined ) {
50- wizardProps . previousStep ( )
51- } else {
52- wizardProps . goToStep ( RunSteps . CONFIGURE_METHOD )
74+ const stackItemTokens : IStackItemTokens = {
75+ padding : '0 10px'
76+ }
77+
78+ const buildCapabilitiesDropdownOptions = ( ) => {
79+ const testSuiteName = testSuiteInfo . selectedTestSuite ?. Name ?? ''
80+ const testSuiteVersion = testSuiteInfo . selectedTestSuite ?. Version ?? ''
81+ const options = capabilitiesListState . displayList
82+ . filter ( c => c . TestSuiteName === testSuiteName && c . TestSuiteVersion === testSuiteVersion )
83+ . map ( c => {
84+ return {
85+ key : c . Id ,
86+ text : `${ c . Name } `
5387 }
54- }
88+ } )
5589
56- const onNextButtonClick : React . MouseEventHandler < unknown > = ( ) => {
57- dispatch ( ConfigurationsDataSrv . setRules ( ( ) => {
58- wizardProps . nextStep ( )
59- } ) )
60- }
90+ options . unshift ( {
91+ key : - 1 ,
92+ text : '(None)'
93+ } )
6194
62- const checkedAction = ( data : SelectedRuleGroup ) : void => {
63- dispatch ( FilterTestCaseActions . setSelectedRuleAction ( data ) )
64- }
95+ return options
96+ }
6597
66- const stackTokens : IStackTokens = {
67- maxHeight : '100%'
68- }
98+ const onCategoriesSelected = ( values : string [ ] ) : void => {
99+ dispatch ( FilterTestCaseActions . selectCapabilitiesFileCategoriesAction ( values ) )
100+ }
101+
102+ const onCategoriesExpanded = ( values : string [ ] ) : void => {
103+ dispatch ( FilterTestCaseActions . expandCapabilitiesFileCategoriesAction ( values ) )
104+ }
69105
70- const stackItemTokens : IStackItemTokens = {
71- padding : '0 10px'
106+ const setCapabilitiesFileId = ( value : any ) => {
107+ dispatch ( FilterTestCaseActions . selectCapabilitiesFileAction ( value ) )
108+
109+ if ( value !== - 1 ) {
110+ dispatch ( TestSuitesDataSrv . getCapabilitiesConfig ( value ) )
72111 }
112+ }
73113
74- return (
114+ return (
75115 < StepPanel leftNav = { wizard } isLoading = { filterInfo . isRulesLoading || filterInfo . isCasesLoading } errorMsg = { filterInfo . errorMsg } >
76116 < Stack tokens = { stackTokens } verticalFill >
77117 < Stack . Item grow style = { { overflowY : 'hidden' } } >
78118 < Stack horizontal tokens = { stackTokens } >
79119 < Stack . Item grow tokens = { stackItemTokens } style = { { overflowY : 'auto' } } >
80- < RuleListPanel ruleGroups = { filterInfo . ruleGroup } selected = { filterInfo . selectedRules } checkedAction = { checkedAction } />
120+
121+ < Dropdown
122+ key = { props . key }
123+ style = { { alignSelf : 'center' } }
124+ placeholder = 'Kindly select a capabilities file'
125+ label = 'Using the following capabilities file:'
126+ options = { buildCapabilitiesDropdownOptions ( ) }
127+ selectedKey = { filterInfo . selectedCapabilitiesFileId }
128+ onChange = { ( _ , newValue , __ ) => { const value : any = newValue ?. key ; setCapabilitiesFileId ( value ) } } />
129+ {
130+ filterInfo . selectedCapabilitiesFileId === - 1
131+ ? < RuleListPanel ruleGroups = { filterInfo . ruleGroup } selected = { filterInfo . selectedRules } checkedAction = { checkedAction } />
132+ : < CapabilitiesTreePanel groups = { filterInfo . groups } onChecked = { ( values ) => onCategoriesSelected ( values ) }
133+ selectedCategories = { filterInfo . selectedCategories }
134+ onExpanded = { ( values ) => onCategoriesExpanded ( values ) }
135+ expandedCategories = { filterInfo . expandedCategoriesByFile . get ( filterInfo . selectedCapabilitiesFileId ) ! } />
136+ }
137+
81138 </ Stack . Item >
82139 < Stack . Item grow tokens = { stackItemTokens } style = { { overflowY : 'auto' } } >
83140 < div > Selected Test Cases { filterInfo . listSelectedCases . length } </ div >
@@ -95,5 +152,5 @@ export const FilterTestCase: React.FC<any> = (props: any) => {
95152 </ Stack . Item >
96153 </ Stack >
97154 </ StepPanel >
98- )
155+ )
99156}
0 commit comments