@@ -9,10 +9,15 @@ import {
99import { RepositoriesSearch } from "./RepositoriesSearch" ;
1010import { RepositoriesSort } from "./RepositoriesSort" ;
1111import { RepositoriesFilter } from "./RepositoriesFilter" ;
12+ import { RepositoriesResultFormat } from "./RepositoriesResultFormat" ;
13+ import { ResultFormat } from "../../variant-analysis/shared/variant-analysis-result-format" ;
1214
1315type Props = {
14- value : RepositoriesFilterSortState ;
15- onChange : Dispatch < SetStateAction < RepositoriesFilterSortState > > ;
16+ filterSortValue : RepositoriesFilterSortState ;
17+ resultFormatValue : ResultFormat ;
18+ onFilterSortChange : Dispatch < SetStateAction < RepositoriesFilterSortState > > ;
19+ onResultFormatChange : Dispatch < SetStateAction < ResultFormat > > ;
20+ variantAnalysisQueryKind : string | undefined ;
1621} ;
1722
1823const Container = styled . div `
@@ -35,51 +40,83 @@ const RepositoriesSortColumn = styled(RepositoriesSort)`
3540 flex: 1;
3641` ;
3742
38- export const RepositoriesSearchSortRow = ( { value, onChange } : Props ) => {
43+ const RepositoriesResultFormatColumn = styled ( RepositoriesResultFormat ) `
44+ flex: 1;
45+ ` ;
46+
47+ function showResultFormatColumn (
48+ variantAnalysisQueryKind : string | undefined ,
49+ ) : boolean {
50+ return (
51+ variantAnalysisQueryKind === "problem" ||
52+ variantAnalysisQueryKind === "path-problem"
53+ ) ;
54+ }
55+
56+ export const RepositoriesSearchSortRow = ( {
57+ filterSortValue,
58+ resultFormatValue,
59+ onFilterSortChange,
60+ onResultFormatChange,
61+ variantAnalysisQueryKind,
62+ } : Props ) => {
3963 const handleSearchValueChange = useCallback (
4064 ( searchValue : string ) => {
41- onChange ( ( oldValue ) => ( {
65+ onFilterSortChange ( ( oldValue ) => ( {
4266 ...oldValue ,
4367 searchValue,
4468 } ) ) ;
4569 } ,
46- [ onChange ] ,
70+ [ onFilterSortChange ] ,
4771 ) ;
4872
4973 const handleFilterKeyChange = useCallback (
5074 ( filterKey : FilterKey ) => {
51- onChange ( ( oldValue ) => ( {
75+ onFilterSortChange ( ( oldValue ) => ( {
5276 ...oldValue ,
5377 filterKey,
5478 } ) ) ;
5579 } ,
56- [ onChange ] ,
80+ [ onFilterSortChange ] ,
5781 ) ;
5882
5983 const handleSortKeyChange = useCallback (
6084 ( sortKey : SortKey ) => {
61- onChange ( ( oldValue ) => ( {
85+ onFilterSortChange ( ( oldValue ) => ( {
6286 ...oldValue ,
6387 sortKey,
6488 } ) ) ;
6589 } ,
66- [ onChange ] ,
90+ [ onFilterSortChange ] ,
91+ ) ;
92+
93+ const handleResultFormatChange = useCallback (
94+ ( resultFormat : ResultFormat ) => {
95+ onResultFormatChange ( resultFormat ) ;
96+ } ,
97+ [ onResultFormatChange ] ,
6798 ) ;
6899
69100 return (
70101 < Container >
71102 < RepositoriesSearchColumn
72- value = { value . searchValue }
103+ value = { filterSortValue . searchValue }
73104 onChange = { handleSearchValueChange }
74105 />
75106 < RepositoriesFilterColumn
76- value = { value . filterKey }
107+ value = { filterSortValue . filterKey }
77108 onChange = { handleFilterKeyChange }
78109 />
79110 < RepositoriesSortColumn
80- value = { value . sortKey }
111+ value = { filterSortValue . sortKey }
81112 onChange = { handleSortKeyChange }
82113 />
114+ { showResultFormatColumn ( variantAnalysisQueryKind ) && (
115+ < RepositoriesResultFormatColumn
116+ value = { resultFormatValue }
117+ onChange = { handleResultFormatChange }
118+ />
119+ ) }
83120 </ Container >
84121 ) ;
85122} ;
0 commit comments